33 #include "ui_htmlpageinfo.h" 44 #include "html/html_documentimpl.h" 45 #include "html/html_baseimpl.h" 46 #include "html/html_objectimpl.h" 47 #include "html/html_miscimpl.h" 48 #include "html/html_imageimpl.h" 49 #include "imload/imagemanager.h" 50 #include "rendering/render_text.h" 51 #include "rendering/render_frames.h" 52 #include "rendering/render_layer.h" 53 #include "rendering/render_position.h" 54 #include "misc/loader.h" 55 #include "misc/khtml_partaccessor.h" 56 #include "xml/dom2_eventsimpl.h" 57 #include "xml/dom2_rangeimpl.h" 58 #include "xml/xml_tokenizer.h" 59 #include "css/cssstyleselector.h" 66 #include "ecma/kjs_proxy.h" 67 #include "ecma/kjs_window.h" 68 #include "ecma/kjs_events.h" 72 #include <kjs/function.h> 73 #include <kjs/interpreter.h> 75 #include <sys/types.h> 105 #include <kde_file.h> 119 #include <QtGui/QClipboard> 120 #include <QtGui/QToolTip> 121 #include <QtCore/QFile> 122 #include <QtCore/QMetaEnum> 123 #include <QtGui/QTextDocument> 124 #include <QtCore/QDate> 125 #include <QtNetwork/QSslCertificate> 131 #include "rendering/render_form.h" 135 #include "ecma/debugger/debugwindow.h" 151 class PartStyleSheetLoader :
public CachedObjectClient
157 m_cachedSheet = dl->requestStyleSheet(url, QString(),
"text/css",
160 m_cachedSheet->ref(
this );
162 virtual ~PartStyleSheetLoader()
164 if ( m_cachedSheet ) m_cachedSheet->deref(
this);
173 virtual void error(
int,
const QString& ) {
176 QPointer<KHTMLPart> m_part;
177 khtml::CachedCSSStyleSheet *m_cachedSheet;
187 init(
new KHTMLView(
this, parentWidget ), prof );
198 view->setPart(
this );
215 widget->setObjectName(
"khtml_part_widget");
216 QVBoxLayout *layout =
new QVBoxLayout( widget );
217 layout->setContentsMargins( 0, 0, 0, 0 );
218 layout->setSpacing( 0 );
219 widget->setLayout( layout );
225 layout->addWidget( d->
m_view );
228 widget->setFocusProxy( d->
m_view );
235 d->
m_extension->setObjectName(
"KHTMLBrowserExtension" );
253 connect( d->
m_paViewDocument, SIGNAL(triggered(
bool)),
this, SLOT(slotViewDocumentSource()) );
260 connect( d->
m_paViewFrame, SIGNAL(triggered(
bool)),
this, SLOT(slotViewFrameSource()) );
270 connect( d->
m_paViewInfo, SIGNAL(triggered(
bool)),
this, SLOT(slotViewPageInfo()) );
274 connect( d->
m_paSaveBackground, SIGNAL(triggered(
bool)),
this, SLOT(slotSaveBackground()) );
277 this, SLOT(slotSaveDocument()) );
283 connect( d->
m_paSaveFrame, SIGNAL(triggered(
bool)),
this, SLOT(slotSaveFrame()) );
295 connect( d->
m_paSecurity, SIGNAL(triggered(
bool)),
this, SLOT(slotSecurity()) );
299 connect( d->
m_paDebugRenderTree, SIGNAL(triggered(
bool)),
this, SLOT(slotDebugRenderTree()) );
303 connect( d->
m_paDebugDOMTree, SIGNAL(triggered(
bool)),
this, SLOT(slotDebugDOMTree()) );
305 KAction* paDebugFrameTree =
new KAction(
i18n(
"Print frame tree to STDOUT" ),
this );
307 connect( paDebugFrameTree, SIGNAL(triggered(
bool)),
this, SLOT(slotDebugFrameTree()) );
311 connect( d->
m_paStopAnimations, SIGNAL(triggered(
bool)),
this, SLOT(slotStopAnimations()) );
317 connect( d->
m_paSetEncoding, SIGNAL(triggered(QString)),
this, SLOT(slotSetEncoding(QString)));
327 if (name.endsWith(
"1251")||name.startsWith(
"koi")||name==
"iso-8859-5")
329 else if (name.endsWith(
"1256")||name==
"iso-8859-6")
331 else if (name.endsWith(
"1257")||name==
"iso-8859-13"||name==
"iso-8859-4")
333 else if (name.endsWith(
"1250")|| name==
"ibm852" || name==
"iso-8859-2" || name==
"iso-8859-3" )
335 else if (name.endsWith(
"1253")|| name==
"iso-8859-7" )
337 else if (name.endsWith(
"1255")|| name==
"iso-8859-8" || name==
"iso-8859-8-i" )
339 else if (name==
"jis7" || name==
"eucjp" || name==
"sjis" )
341 else if (name.endsWith(
"1254")|| name==
"iso-8859-9" )
343 else if (name.endsWith(
"1252")|| name==
"iso-8859-1" || name==
"iso-8859-15" )
354 connect( d->
m_paUseStylesheet, SIGNAL(triggered(
int)),
this, SLOT(slotUseStylesheet()) );
359 connect(d->
m_paIncZoomFactor, SIGNAL(triggered(
bool)), SLOT(slotIncFontSizeFast()));
361 "Make the font in this window bigger. " 362 "Click and hold down the mouse button for a menu with all available font sizes.</qt>" ) );
366 connect(d->
m_paDecZoomFactor, SIGNAL(triggered(
bool)), SLOT(slotDecFontSizeFast()));
368 "Make the font in this window smaller. " 369 "Click and hold down the mouse button for a menu with all available font sizes.</qt>" ) );
382 d->
m_paFind->setWhatsThis(
i18n(
"<qt>Find text<br /><br />" 383 "Shows a dialog that allows you to find text on the displayed page.</qt>" ) );
387 "Find the next occurrence of the text that you " 388 "have found using the <b>Find Text</b> function.</qt>" ) );
391 this, SLOT(slotFindPrev()) );
393 "Find the previous occurrence of the text that you " 394 "have found using the <b>Find Text</b> function.</qt>" ) );
400 d->
m_paFindAheadText->
setHelpText(
i18n(
"This shortcut shows the find bar, for finding text in the displayed page. It cancels the effect of \"Find Links as You Type\", which sets the \"Find links only\" option."));
401 connect( d->
m_paFindAheadText, SIGNAL(triggered(
bool)),
this, SLOT(slotFindAheadText()) );
410 connect( d->
m_paFindAheadLinks, SIGNAL(triggered(
bool)),
this, SLOT(slotFindAheadLink()) );
424 connect( d->
m_paPrintFrame, SIGNAL(triggered(
bool)),
this, SLOT(slotPrintFrame()) );
426 "Some pages have several frames. To print only a single frame, click " 427 "on it and then use this function.</qt>" ) );
435 this, SLOT(slotSelectAll()) );
442 connect( d->
m_paToggleCaretMode, SIGNAL(triggered(
bool)),
this, SLOT(slotToggleCaretMode()) );
483 action->setShortcutContext ( Qt::WidgetWithChildrenShortcut );
487 connect( view, SIGNAL(zoomView(
int)), SLOT(slotZoomView(
int)) );
490 this, SLOT(updateActions()) );
492 this, SLOT(updateActions()) );
494 this, SLOT(updateActions()) );
499 connect( khtml::Cache::loader(), SIGNAL(requestStarted(khtml::DocLoader*,khtml::CachedObject*)),
500 this, SLOT(slotLoaderRequestStarted(khtml::DocLoader*,khtml::CachedObject*)) );
501 connect( khtml::Cache::loader(), SIGNAL(requestDone(khtml::DocLoader*,khtml::CachedObject*)),
502 this, SLOT(slotLoaderRequestDone(khtml::DocLoader*,khtml::CachedObject*)) );
503 connect( khtml::Cache::loader(), SIGNAL(requestFailed(khtml::DocLoader*,khtml::CachedObject*)),
504 this, SLOT(slotLoaderRequestDone(khtml::DocLoader*,khtml::CachedObject*)) );
511 this, SLOT(slotRedirect()) );
513 if (QDBusConnection::sessionBus().isConnected()) {
515 for (
int i = 1; ; ++i)
516 if (QDBusConnection::sessionBus().registerObject(QString(
"/KHTML/%1/widget").arg(i),
this))
518 else if (i == 0xffff)
519 kFatal() <<
"Something is very wrong in KHTMLPart!";
544 removeJSErrorExtension();
553 disconnect( khtml::Cache::loader(), SIGNAL(requestStarted(khtml::DocLoader*,khtml::CachedObject*)),
554 this, SLOT(slotLoaderRequestStarted(khtml::DocLoader*,khtml::CachedObject*)) );
555 disconnect( khtml::Cache::loader(), SIGNAL(requestDone(khtml::DocLoader*,khtml::CachedObject*)),
556 this, SLOT(slotLoaderRequestDone(khtml::DocLoader*,khtml::CachedObject*)) );
557 disconnect( khtml::Cache::loader(), SIGNAL(requestFailed(khtml::DocLoader*,khtml::CachedObject*)),
558 this, SLOT(slotLoaderRequestDone(khtml::DocLoader*,khtml::CachedObject*)) );
576 d->
m_frame->m_run.data()->abort();
581 bool KHTMLPart::restoreURL(
const KUrl &
url )
610 disconnect(d->
m_view, SIGNAL(finishedLayout()),
this, SLOT(restoreScrollPosition()));
611 connect(d->
m_view, SIGNAL(finishedLayout()),
this, SLOT(restoreScrollPosition()));
624 if (url.
protocol() == QLatin1String(
"help"))
635 emit m_extension->openUrlNotify();
637 DOM::HashChangeEventImpl *hashChangeEvImpl = 0;
638 const QString &oldRef = q->url().ref();
639 const QString &newRef = url.
ref();
640 if ((oldRef != newRef) || (oldRef.isNull() && newRef.isEmpty())) {
641 hashChangeEvImpl =
new DOM::HashChangeEventImpl();
642 hashChangeEvImpl->initHashChangeEvent(
"hashchange",
651 q->gotoAnchor( url.
htmlRef() );
654 emit m_extension->setLocationBarUrl( url.
prettyUrl() );
656 if (hashChangeEvImpl) {
657 m_doc->dispatchWindowEvent(hashChangeEvImpl);
663 kDebug( 6050 ) <<
this <<
"opening" <<
url;
664 #ifndef KHTML_NO_WALLET 691 if ( !urls.isEmpty() ) {
692 const KUrl mainURL = urls.first();
693 int error = mainURL.
queryItem(
"error" ).toInt();
696 const QString errorText = mainURL.
queryItem(
"errText" );
707 QString host = url.
isLocalFile() ?
"localhost" : url.host();
712 d->
m_statusBarUALabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum));
736 bool isFrameSet =
false;
737 if ( d->
m_doc && d->
m_doc->isHTMLDocument() ) {
738 HTMLDocumentImpl* htmlDoc =
static_cast<HTMLDocumentImpl*
>(d->
m_doc);
739 isFrameSet = htmlDoc->body() && (htmlDoc->body()->id() == ID_FRAMESET);
746 for (; it !=
end; ++it) {
761 if ( url.
hasRef() && !isFrameSet )
763 bool noReloadForced = !args.reload() && !browserArgs.redirectedRequest() && !browserArgs.doPost();
766 kDebug( 6050 ) <<
"jumping to anchor. m_url = " <<
url;
775 d->
m_doc->setParsing(
false);
777 kDebug( 6050 ) <<
"completed...";
786 args.setXOffset( d->
m_view->contentsX() );
787 args.setYOffset( d->
m_view->contentsY() );
795 disconnect(d->
m_view, SIGNAL(finishedLayout()),
this, SLOT(restoreScrollPosition()));
796 connect(d->
m_view, SIGNAL(finishedLayout()),
this, SLOT(restoreScrollPosition()));
807 begin(url, args.xOffset(), args.yOffset());
808 write(QString::fromLatin1(
"<html><head></head><body>"));
810 write(QString::fromLatin1(
"<img "));
812 write(QString::fromLatin1(
"<embed "));
813 write(QString::fromLatin1(
"src=\""));
818 write(QString::fromLatin1(
"\">"));
827 if(url.
protocol().startsWith(
"http" ) && !url.host().isEmpty() &&
828 url.
path().isEmpty()) {
835 metaData.insert(
"main_frame_request",
parentPart() == 0 ?
"TRUE" :
"FALSE" );
838 metaData.insert(
"PropagateHttpHeader",
"true");
839 metaData.insert(
"ssl_was_in_use", d->
m_ssl_in_use ?
"TRUE" :
"FALSE" );
840 metaData.insert(
"ssl_activate_warnings",
"TRUE" );
848 else if (args.reload() && !browserArgs.softReload)
853 if ( browserArgs.doPost() && (url.
protocol().startsWith(
"http")) )
868 connect( d->
m_job, SIGNAL(result(
KJob*)),
871 SLOT(slotData(
KIO::Job*,QByteArray)) );
872 connect ( d->
m_job, SIGNAL(infoMessage(
KJob*,QString,QString)),
873 SLOT(slotInfoMessage(
KJob*,QString)) );
893 connect( d->
m_job, SIGNAL(speed(
KJob*,ulong)),
894 this, SLOT(slotJobSpeed(
KJob*,ulong)) );
896 connect( d->
m_job, SIGNAL(percent(
KJob*,ulong)),
897 this, SLOT(slotJobPercent(
KJob*,ulong)) );
899 connect( d->
m_job, SIGNAL(result(
KJob*)),
900 this, SLOT(slotJobDone(
KJob*)) );
909 connect( job, SIGNAL(result(
KJob*)),
910 this, SLOT(slotUserSheetStatDone(
KJob*)) );
927 if ( d->
m_doc && d->
m_doc->isHTMLDocument() ) {
928 HTMLDocumentImpl* hdoc =
static_cast<HTMLDocumentImpl*
>( d->
m_doc );
931 hdoc->body()->dispatchWindowEvent( EventImpl::UNLOAD_EVENT,
false,
false );
933 d->
m_doc->updateRendering();
942 disconnect(d->
m_view, SIGNAL(finishedLayout()),
this, SLOT(restoreScrollPosition()));
947 kDebug( 6050 ) <<
" was still parsing... calling end ";
948 slotFinishedParsing();
949 d->
m_doc->setParsing(
false);
955 kDebug( 6050 ) <<
"Aborted before starting to render, reverting location bar to " <<
url().
prettyUrl();
962 khtml::Cache::loader()->cancelRequests( d->
m_doc->docLoader() );
968 for (; it !=
end; ++it )
971 (*it)->m_run.data()->abort();
972 if ( !( *it )->m_part.isNull() )
973 ( *it )->m_part.data()->closeUrl();
980 for (; it !=
end; ++it)
982 if ( !( *it )->m_part.isNull() )
983 ( *it )->m_part.data()->closeUrl();
995 d->
m_view->closeChildDialogs();
1003 return static_cast<HTMLDocumentImpl*>(d->
m_doc);
1005 return static_cast<HTMLDocumentImpl*
>(0);
1018 QByteArray sourceArray;
1019 QDataStream dataStream( &sourceArray, QIODevice::WriteOnly );
1021 QTextStream stream( sourceArray, QIODevice::ReadOnly );
1022 stream.setCodec( QTextCodec::codecForName(
encoding().toLatin1().constData() ) );
1023 sourceStr = stream.readAll();
1030 if ( f.open( QIODevice::ReadOnly ) )
1032 QTextStream stream( &f );
1033 stream.setCodec( QTextCodec::codecForName(
encoding().toLatin1().constData() ) );
1034 sourceStr = stream.readAll();
1062 if (const_cast<KHTMLPart*>(
this)->
parentPart())
1069 if (const_cast<KHTMLPart*>(
this)->
parentPart())
1082 if (!proxy || proxy->paused())
1085 return proxy->interpreter();
1096 d->
m_frame->m_jscript->clear();
1146 for (; it !=
end; ++it)
1147 if ((*it)->m_part.data() ==
this) {
1162 QVariant KHTMLPart::crossFrameExecuteScript(
const QString& target,
const QString& script)
1166 QString trg = target.toLower();
1168 if (target ==
"_top") {
1172 else if (target ==
"_parent") {
1176 else if (target ==
"_self" || target ==
"_blank") {
1186 if (destpart ==
this)
1190 if (destpart->checkFrameAccess(
this))
1223 d->
m_jsedlg->_clear->setIcon(
KIcon(
"edit-clear-locationbar-ltr"));
1230 void KHTMLPart::removeJSErrorExtension() {
1244 void KHTMLPart::disableJSErrorExtension() {
1245 removeJSErrorExtension();
1254 void KHTMLPart::jsErrorDialogContextMenu() {
1256 m->addAction(
i18n(
"&Hide Errors"),
this, SLOT(removeJSErrorExtension()));
1257 m->addAction(
i18n(
"&Disable Error Reporting"),
this, SLOT(disableJSErrorExtension()));
1258 m->popup(QCursor::pos());
1261 void KHTMLPart::launchJSErrorDialog() {
1269 void KHTMLPart::launchJSConfigDialog() {
1271 args <<
"khtml_java_js";
1279 kDebug(6070) <<
"executeScript: caller='" << objectName() <<
"' filename=" << filename <<
" baseLine=" << baseLine ;
1283 if (!proxy || proxy->paused())
1286 KJS::Completion comp;
1287 QVariant ret = proxy->evaluate(filename, baseLine, script, n, &comp);
1292 if (comp.complType() == KJS::Throw && comp.value()) {
1295 QString msg = KJSDebugger::DebugWindow::exceptionToString(
1296 proxy->interpreter()->globalExec(), comp.value());
1298 Qt::escape(filename), Qt::escape(msg)));
1305 kDebug(6070) <<
"executeScript done, handling immediate redirection NOW";
1307 khtml::Tokenizer* t = d->
m_doc->tokenizer();
1329 if (!proxy || proxy->paused())
1333 KJS::Completion comp;
1334 const QVariant ret = proxy->evaluate( QString(), 1, script, n, &comp );
1340 if (comp.complType() == KJS::Throw && comp.value()) {
1343 QString msg = KJSDebugger::DebugWindow::exceptionToString(
1344 proxy->interpreter()->globalExec(), comp.value());
1345 dlg->
addError(
i18n(
"<qt><b>Error</b>: node %1: %2</qt>",
1395 void KHTMLPart::slotDebugDOMTree()
1398 qDebug(
"%s", d->
m_doc->toString().string().toLatin1().constData());
1406 for (; it !=
end; ++it )
1407 if ( !( *it )->m_part.isNull() && (*it)->m_part.data()->inherits(
"KHTMLPart" ) ) {
1410 static_cast<KHTMLPart*
>( p )->slotDebugDOMTree();
1415 void KHTMLPart::slotDebugScript()
1418 jScript()->showDebugWindow();
1421 void KHTMLPart::slotDebugRenderTree()
1425 d->
m_doc->renderer()->printTree();
1436 void KHTMLPart::slotDebugFrameTree()
1441 void KHTMLPart::slotStopAnimations()
1448 if ( d->
m_doc && d->
m_doc->docLoader()->autoloadImages() == enable )
1452 d->
m_doc->docLoader()->setAutoloadImages( enable );
1464 connect( d->
m_paLoadImages, SIGNAL(triggered(
bool)),
this, SLOT(slotLoadImages()) );
1477 return d->
m_doc->docLoader()->autoloadImages();
1482 void KHTMLPart::clear()
1494 for(; it !=
end; ++it )
1498 (*it)->m_run.data()->abort();
1505 for(; it !=
end; ++it )
1509 (*it)->m_run.data()->abort();
1520 if (d->
m_doc->attached())
1526 d->
m_frame->m_jscript->clear();
1529 if (d->
m_doc && d->
m_doc->renderer() && d->
m_doc->renderer()->layer())
1530 d->
m_doc->renderer()->layer()->suspendMarquees();
1557 for(; it !=
end; ++it )
1559 if ( (*it)->m_part )
1562 delete (*it)->m_part.data();
1576 for (; oi != oiEnd; ++oi )
1578 delete (*oi)->m_part.data();
1600 #ifndef QT_NO_CLIPBOARD 1601 connect( qApp->clipboard(), SIGNAL(
selectionChanged()), SLOT(slotClearSelection()));
1629 DOM::HTMLDocumentImpl *KHTMLPart::docImpl()
const 1631 if ( d && d->
m_doc && d->
m_doc->isHTMLDocument() )
1632 return static_cast<HTMLDocumentImpl*>(d->
m_doc);
1636 DOM::DocumentImpl *KHTMLPart::xmlDocImpl()
const 1643 void KHTMLPart::slotInfoMessage(
KJob* kio_job,
const QString& msg)
1650 setStatusBarText(msg, BarDefaultText);
1658 void KHTMLPart::slotData(
KIO::Job* kio_job,
const QByteArray &data )
1694 d->
m_doc->docLoader()->setCacheCreationDate(cacheCreationDate);
1730 if( !qData.isEmpty())
1731 d->
m_doc->processHttpEquiv(
"refresh", qData);
1743 if (!language.isEmpty())
1744 d->
m_doc->setContentLanguage(language);
1746 if ( !
url().isLocalFile() )
1756 write( data.data(), data.size() );
1759 void KHTMLPart::slotRestoreData(
const QByteArray &data )
1775 write( data.data(), data.size() );
1777 if (data.size() == 0)
1805 kDebug(6050) <<
"errorCode" << errorCode <<
"text" << text;
1813 QString errorName, techName, description;
1814 QStringList causes, solutions;
1817 QDataStream stream(raw);
1819 stream >> errorName >> techName >> description >> causes >> solutions;
1821 QString
url, protocol, datetime;
1825 url = Qt::escape( Qt::escape( reqUrl.
prettyUrl() ) );
1831 QFile file( filename );
1832 bool isOpened = file.open( QIODevice::ReadOnly );
1834 kWarning(6050) <<
"Could not open error html template:" << filename;
1836 QString html = QString( QLatin1String( file.readAll() ) );
1838 html.replace( QLatin1String(
"TITLE" ),
i18n(
"Error: %1 - %2", errorName, url ) );
1839 html.replace( QLatin1String(
"DIRECTION" ), QApplication::isRightToLeft() ?
"rtl" :
"ltr" );
1842 QString doc = QLatin1String(
"<h1>" );
1843 doc +=
i18n(
"The requested operation could not be completed" );
1844 doc += QLatin1String(
"</h1><h2>" );
1846 doc += QLatin1String(
"</h2>" );
1847 if ( !techName.isNull() ) {
1848 doc += QLatin1String(
"<h2>" );
1849 doc +=
i18n(
"Technical Reason: " );
1851 doc += QLatin1String(
"</h2>" );
1853 doc += QLatin1String(
"<br clear=\"all\">" );
1854 doc += QLatin1String(
"<h3>" );
1855 doc +=
i18n(
"Details of the Request:" );
1856 doc += QLatin1String(
"</h3><ul><li>" );
1857 doc +=
i18n(
"URL: %1" , url );
1858 doc += QLatin1String(
"</li><li>" );
1859 if ( !protocol.isNull() ) {
1860 doc +=
i18n(
"Protocol: %1", protocol );
1861 doc += QLatin1String(
"</li><li>" );
1863 doc +=
i18n(
"Date and Time: %1" , datetime );
1864 doc += QLatin1String(
"</li><li>" );
1865 doc +=
i18n(
"Additional Information: %1" , text );
1866 doc += QLatin1String(
"</li></ul><h3>" );
1867 doc +=
i18n(
"Description:" );
1868 doc += QLatin1String(
"</h3><p>" );
1870 doc += QLatin1String(
"</p>" );
1871 if ( causes.count() ) {
1872 doc += QLatin1String(
"<h3>" );
1873 doc +=
i18n(
"Possible Causes:" );
1874 doc += QLatin1String(
"</h3><ul><li>" );
1875 doc += causes.join(
"</li><li>" );
1876 doc += QLatin1String(
"</li></ul>" );
1878 if ( solutions.count() ) {
1879 doc += QLatin1String(
"<h3>" );
1880 doc +=
i18n(
"Possible Solutions:" );
1881 doc += QLatin1String(
"</h3><ul><li>" );
1882 doc += solutions.join(
"</li><li>" );
1883 doc += QLatin1String(
"</li></ul>" );
1886 html.replace( QLatin1String(
"TEXT"), doc );
1934 HTMLPartContainerElementImpl *elt = d->
m_frame ?
1935 d->
m_frame->m_partContainerElement.data() : 0;
1940 elt->partLoadingErrorNotify();
1961 if (mimeStr ==
"application/xhtml+xml")
1963 if (mimeStr ==
"image/svg+xml")
1965 if (mimeStr ==
"text/html" || mimeStr.isEmpty())
1969 if ((mime && mime->
is(
"text/xml")) || mimeStr.endsWith(
"+xml"))
1972 if (mime && mime->
is(
"text/plain"))
1975 if (khtmlImLoad::ImageManager::loaderDatabase()->supportedMimeTypes().contains(mimeStr))
1991 if ( d->
m_view->underMouse() )
1992 QToolTip::hideText();
1996 removeJSErrorExtension();
2001 KJS::Window *w = KJS::Window::retrieveWindow( part );
2003 w->forgetSuppressedWindows();
2016 QString urlString = url.
url();
2019 if ( urlString != urlString2 ) {
2043 d->
m_doc = DOMImplementationImpl::createSVGDocument( d->
m_view );
2047 d->
m_doc = DOMImplementationImpl::createXMLDocument( d->
m_view );
2055 d->
m_doc = DOMImplementationImpl::createHTMLDocument( d->
m_view );
2057 static_cast<HTMLDocumentImpl *
>(d->
m_doc)->setHTMLRequested( type !=
MimeXHTML );
2063 if (!d->
m_doc->attached())
2064 d->
m_doc->attach( );
2074 if ( !userStyleSheet.isEmpty() )
2078 connect(d->
m_doc,SIGNAL(finishedParsing()),
this,SLOT(slotFinishedParsing()));
2082 d->
m_doc->setParsing(
true);
2091 len = strlen( data );
2098 if(decoded.isEmpty())
2104 khtml::Tokenizer* t = d->
m_doc->tokenizer();
2106 t->write( decoded,
true );
2123 d->
m_doc->setParseMode( DocumentImpl::Strict );
2129 khtml::Tokenizer* t = d->
m_doc->tokenizer();
2131 t->write( str,
true );
2142 if (!decoded.isEmpty())
2145 d->
m_doc->finishParsing();
2149 void KHTMLPart::onFirstData()
2154 d->
m_doc->determineParseMode();
2160 d->
m_doc->setVisuallyOrdered();
2163 d->
m_doc->recalcStyle( NodeImpl::Force );
2169 if ( mime && ( mime->
is(
"text/html" ) || mime->
is(
"text/xml" ) ) )
2179 write( data.data(), data.size() );
2193 d->
m_view->paint(p, rc, yOff, more);
2203 for (; it !=
end; ++it ) {
2204 if (
KHTMLPart* p = qobject_cast<KHTMLPart*>((*it)->m_part.data()) )
2205 p->stopAnimations();
2209 void KHTMLPart::resetFromScript()
2214 disconnect(d->
m_doc,SIGNAL(finishedParsing()),
this,SLOT(slotFinishedParsing()));
2215 connect(d->
m_doc,SIGNAL(finishedParsing()),
this,SLOT(slotFinishedParsing()));
2216 d->
m_doc->setParsing(
true);
2221 void KHTMLPart::slotFinishedParsing()
2223 d->
m_doc->setParsing(
false);
2224 d->
m_doc->dispatchHTMLEvent(EventImpl::KHTML_CONTENTLOADED_EVENT,
true,
false);
2225 checkEmitLoadEvent();
2226 disconnect(d->
m_doc,SIGNAL(finishedParsing()),
this,SLOT(slotFinishedParsing()));
2234 void KHTMLPart::slotLoaderRequestStarted( khtml::DocLoader* dl, khtml::CachedObject *obj )
2236 if ( obj && obj->type() == khtml::CachedObject::Image && d->
m_doc && d->
m_doc->docLoader() == dl ) {
2261 void KHTMLPart::slotLoaderRequestDone( khtml::DocLoader* dl, khtml::CachedObject *obj )
2263 if ( obj && obj->type() == khtml::CachedObject::Image && d->
m_doc && d->
m_doc->docLoader() == dl ) {
2283 void KHTMLPart::slotProgressUpdate()
2304 void KHTMLPart::slotJobSpeed(
KJob* ,
unsigned long speed )
2311 void KHTMLPart::slotJobPercent(
KJob* ,
unsigned long percent )
2321 void KHTMLPart::slotJobDone(
KJob* )
2331 void KHTMLPart::slotUserSheetStatDone(
KJob *_job )
2333 using namespace KIO;
2335 if ( _job->
error() ) {
2345 if ( lastModified != static_cast<time_t>(-1) ) {
2346 if (
d->m_userStyleSheetLastModified >= lastModified ) {
2357 *pendingRedirections =
false;
2362 for (; it !=
end; ++it ) {
2363 if ( !(*it)->m_bCompleted || (*it)->m_run )
2369 if ( (*it)->m_bPendingRedirection )
2370 *pendingRedirections =
true;
2378 for (; oi != oiEnd; ++oi )
2379 if ( !(*oi)->m_bCompleted )
2384 if ( m_doc && m_doc->parsing() )
2389 if ( m_doc && m_doc->docLoader() )
2390 requests = khtml::Cache::loader()->numRequests( m_doc->docLoader() );
2401 void KHTMLPart::checkCompleted()
2408 if (
d->m_doc && !
d->m_doc->parsing() && !
d->m_focusNodeRestored)
2410 if (
d->m_focusNodeNumber >= 0)
2411 d->m_doc->setFocusNode(
d->m_doc->nodeWithAbsIndex(
d->m_focusNodeNumber));
2413 d->m_focusNodeRestored =
true;
2416 bool fullyLoaded, pendingChildRedirections;
2417 fullyLoaded =
d->isFullyLoaded(&pendingChildRedirections);
2420 if (!fullyLoaded ||
d->m_bComplete)
2425 d->m_bComplete =
true;
2427 d->m_totalObjectCount = 0;
2428 d->m_loadedObjects = 0;
2440 checkEmitLoadEvent();
2442 bool pendingAction =
false;
2444 if ( !
d->m_redirectURL.isEmpty() )
2450 d->m_redirectionTimer.setSingleShot(
true );
2451 d->m_redirectionTimer.start( qMax(0, 1000 *
d->m_delayRedirect) );
2456 pendingAction =
true;
2458 else if ( pendingChildRedirections )
2460 pendingAction =
true;
2467 d->m_view->complete( pendingAction );
2472 sheets =
d->m_doc->availableStyleSheets();
2473 sheets.prepend(
i18n(
"Automatic Detection" ) );
2474 d->m_paUseStylesheet->setItems( sheets );
2476 d->m_paUseStylesheet->setEnabled( sheets.count() > 2);
2477 if (sheets.count() > 2)
2479 d->m_paUseStylesheet->setCurrentItem(qMax(sheets.indexOf(
d->m_sheetUsed), 0));
2480 slotUseStylesheet();
2487 kDebug(6080) <<
"DONE:" <<
d->m_parsetime.elapsed();
2491 void KHTMLPart::checkEmitLoadEvent()
2493 bool fullyLoaded, pendingChildRedirections;
2494 fullyLoaded =
d->isFullyLoaded(&pendingChildRedirections);
2497 if (
d->m_bLoadEventEmitted || !
d->m_doc || !fullyLoaded )
return;
2499 d->m_bLoadEventEmitted =
true;
2506 return d->m_settings;
2509 #ifndef KDE_NO_COMPAT // KDE5: remove this ifndef, keep the method (renamed to baseUrl) 2512 if ( !
d->m_doc )
return KUrl();
2514 return d->m_doc->baseURL();
2520 if ( !
d->m_doc )
return KUrl( url );
2524 return KUrl(
d->m_doc->completeURL(url),
d->m_decoder->codec()->mibEnum());
2527 return KUrl(
d->m_doc->completeURL( url ) );
2532 return KUrl::fromPercentEncoding( u.right( u.length() - 11 ).toUtf8() );
2537 QString script = codeForJavaScriptURL(u);
2538 kDebug( 6050 ) <<
"script=" << script;
2539 QVariant res = q->executeScript(
DOM::Node(), script );
2541 q->begin( q->url() );
2542 q->setAlwaysHonourDoctype();
2543 q->write( res.toString() );
2546 emit q->completed();
2551 return url.indexOf( QLatin1String(
"javascript:" ), 0, Qt::CaseInsensitive ) == 0;
2558 kDebug(6050) <<
"delay=" << delay <<
" url=" << url <<
" from=" << this->
url() <<
"parent=" <<
parentPart();
2559 kDebug(6050) <<
"current redirectURL=" <<
d->m_redirectURL <<
" with delay " <<
d->m_delayRedirect;
2564 if ( delay == -1 &&
d->isInPageURL(url) ) {
2565 d->executeInPageURL(url, doLockHistory);
2569 if( delay < 24*60*60 &&
2570 (
d->m_redirectURL.isEmpty() || delay <=
d->m_delayRedirect) ) {
2571 d->m_delayRedirect = delay;
2572 d->m_redirectURL =
url;
2573 d->m_redirectLockHistory = doLockHistory;
2574 kDebug(6050) <<
" d->m_bComplete=" <<
d->m_bComplete;
2576 if (
d->m_bComplete ) {
2577 d->m_redirectionTimer.stop();
2578 d->m_redirectionTimer.setSingleShot(
true );
2579 d->m_redirectionTimer.start( qMax(0, 1000 *
d->m_delayRedirect) );
2586 m_delayRedirect = 0;
2587 m_redirectURL.clear();
2588 m_redirectionTimer.stop();
2591 void KHTMLPart::slotRedirect()
2594 QString u =
d->m_redirectURL;
2596 d->clearRedirection();
2598 if (
d->isInPageURL(u) )
2600 d->executeInPageURL(u,
d->m_redirectLockHistory);
2608 if ( openedByJS() &&
d->m_opener )
2609 cUrl =
d->m_opener->url();
2613 kWarning(6050) <<
"KHTMLPart::scheduleRedirection: Redirection from " << cUrl <<
" to " << url <<
" REJECTED!";
2618 if ( url.
equals(this->url(),
2621 args.
metaData().insert(
"referrer",
d->m_pageReferrer);
2636 if ( !
urlSelected( u, 0, 0,
"_self", args, browserArgs ) ) {
2642 void KHTMLPart::slotRedirection(
KIO::Job*,
const KUrl& url)
2646 emit
d->m_extension->setLocationBarUrl( url.
prettyUrl() );
2647 d->m_workingURL =
url;
2652 d->m_encoding = name;
2653 d->m_haveEncoding =
override;
2655 if( !
url().isEmpty() ) {
2660 d->m_restored =
true;
2662 d->m_restored =
false;
2670 if(
d->m_haveEncoding && !
d->m_encoding.isEmpty())
2671 return d->m_encoding;
2673 if(
d->m_decoder &&
d->m_decoder->encoding())
2674 return QString(
d->m_decoder->encoding());
2676 return defaultEncoding();
2679 QString KHTMLPart::defaultEncoding()
const 2682 if ( !encoding.isEmpty() )
2687 return "iso-8859-1";
2694 if (
d->m_doc &&
d->m_doc->docLoader() )
2695 (
void)
new khtml::PartStyleSheetLoader(
this, url.
url(),
d->m_doc->docLoader());
2701 d->m_doc->setUserStyleSheet( styleSheet );
2709 HTMLCollectionImpl *anchors =
2710 new HTMLCollectionImpl(
d->m_doc, HTMLCollectionImpl::DOC_ANCHORS);
2712 NodeImpl *n = anchors->namedItem(name);
2716 n =
d->m_doc->getElementById( name );
2719 d->m_doc->setCSSTarget(n);
2722 bool quirkyName = !n && !
d->m_doc->inStrictMode() && (name.isEmpty() || name.toLower() ==
"top");
2725 d->m_view->setContentsPos(
d->m_view->contentsX(), 0);
2728 kDebug(6050) << name <<
"not found";
2734 HTMLElementImpl *a =
static_cast<HTMLElementImpl *
>(n);
2736 a->getUpperLeftCorner(x, y);
2737 if (x <= d->m_view->contentsX())
2740 gox =
d->m_view->contentsX();
2741 if ( x + 10 >
d->m_view->contentsX()+
d->m_view->visibleWidth()) {
2742 a->getLowerRightCorner(x, dummy);
2743 gox = x -
d->m_view->visibleWidth() + 10;
2747 d->m_view->setContentsPos(gox, y);
2756 d->m_view->focusNextPrevNode (
true );
2765 d->m_view->focusNextPrevNode (
false );
2772 d->m_settings->setStdFontName(name);
2777 d->m_settings->setFixedFontName(name);
2782 d->m_linkCursor = c;
2787 return d->m_linkCursor;
2792 return d->m_onlyLocalReferences;
2797 d->m_onlyLocalReferences = enable;
2802 return d->m_forcePermitLocalImages;
2807 d->m_forcePermitLocalImages = enable;
2814 this->*flag = value;
2820 for (; it != itEnd; ++it) {
2830 for (; it != itEnd; ++it) {
2838 void KHTMLPart::initCaret()
2841 if (
d->editor_context.m_selection.state() == Selection::NONE) {
2844 if (
d->m_doc->isHTMLDocument()) {
2845 HTMLDocumentImpl* htmlDoc =
static_cast<HTMLDocumentImpl*
>(
d->m_doc);
2846 node = htmlDoc->body();
2850 d->editor_context.m_selection.moveTo(Position(node, 0));
2851 d->editor_context.m_selection.setNeedsLayout();
2852 d->editor_context.m_selection.needsCaretRepaint();
2860 if (!khtml::KHTMLPartAccessor::caret(part).caretPos().node()->isContentEditable())
2883 return d->m_caretMode;
2903 return d->m_designMode;
2907 return &
d->editor_context;
2914 Q_UNUSED(extendSelection);
2915 #ifndef KHTML_NO_CARET 2917 kDebug(6200) <<
"node: " << node.
handle() <<
" nodeName: " 2919 <<
" extendSelection " << extendSelection;
2920 if (
view()->moveCaretTo(node.
handle(), offset, !extendSelection))
2921 emitSelectionChanged();
2922 view()->ensureCaretVisible();
2924 #endif // KHTML_NO_CARET 2930 #ifndef KHTML_NO_CARET 2932 #else // KHTML_NO_CARET 2934 #endif // KHTML_NO_CARET 2943 #ifndef KHTML_NO_CARET 2944 view()->setCaretDisplayPolicyNonFocused(policy);
2945 #endif // KHTML_NO_CARET 2952 NodeImpl *caretNode =
d->editor_context.m_selection.caretPos().node();
2953 if (
isCaretMode() || (caretNode && caretNode->isContentEditable())) {
2954 invalidateSelection();
2955 enableFindAheadActions(
false);
2959 if (
d->editor_context.m_caretBlinkTimer >= 0)
2960 killTimer(
d->editor_context.m_caretBlinkTimer);
2961 clearCaretRectIfNeeded();
2968 d->m_find.findTextBegin();
2971 bool KHTMLPart::initFindNode(
bool selection,
bool reverse,
bool fromCursor )
2973 return d->m_find.initFindNode(
selection, reverse, fromCursor);
2976 void KHTMLPart::slotFind()
2981 if (!part->inherits(
"KHTMLPart") )
2983 kError(6000) <<
"part is a" << part->metaObject()->className() <<
", can't do a search into it";
2989 void KHTMLPart::slotFindNext()
2994 if (!part->inherits(
"KHTMLPart") )
2996 kError(6000) <<
"part is a" << part->metaObject()->className() <<
", can't do a search into it";
3002 void KHTMLPart::slotFindPrev()
3007 if (!part->inherits(
"KHTMLPart") )
3009 kError(6000) <<
"part is a" << part->metaObject()->className() <<
", can't do a search into it";
3015 void KHTMLPart::slotFindDone()
3020 void KHTMLPart::slotFindAheadText()
3030 void KHTMLPart::slotFindAheadLink()
3040 void KHTMLPart::enableFindAheadActions(
bool )
3045 void KHTMLPart::slotFindDialogDestroyed()
3054 d->m_find.activate();
3061 d->m_find.createNewKFind(str, options, parent, findDialog );
3069 return d->m_find.findTextNext( reverse );
3072 bool KHTMLPart::pFindTextNextInThisFrame(
bool reverse )
3074 return d->m_find.findTextNext( reverse );
3079 const Selection &sel =
d->editor_context.m_selection;
3081 kDebug() <<
"Selection is not valid. Returning empty selection";
3084 if(sel.start().offset() < 0 || sel.end().offset() < 0) {
3085 kDebug() <<
"invalid values for end/startOffset " << sel.start().offset() <<
" " << sel.end().offset();
3091 int exceptioncode = 0;
3092 return r.
handle()->toHTML(exceptioncode).string();
3097 bool hasNewLine =
true;
3098 bool seenTDTag =
false;
3100 const Selection &sel =
d->editor_context.m_selection;
3104 DOM::DOMStringImpl *dstr =
static_cast<DOM::TextImpl*
>(n.
handle())->renderString();
3105 QString str(dstr->s, dstr->l);
3106 if(!str.isEmpty()) {
3112 if(n == sel.start().node() && n == sel.end().node()) {
3113 int s = khtml::RenderPosition::fromDOMPosition(sel.start()).renderedOffset();
3114 int e = khtml::RenderPosition::fromDOMPosition(sel.end()).renderedOffset();
3115 text = str.mid(s, e-s);
3116 }
else if(n == sel.start().node()) {
3117 text = str.mid(khtml::RenderPosition::fromDOMPosition(sel.start()).renderedOffset());
3118 }
else if(n == sel.end().node()) {
3119 text += str.left(khtml::RenderPosition::fromDOMPosition(sel.end()).renderedOffset());
3129 text +=
static_cast<HTMLTextAreaElementImpl*
>(n.
handle())->value().string();
3132 if (static_cast<HTMLInputElementImpl*>(n.
handle())->inputType() != HTMLInputElementImpl::PASSWORD)
3133 text += static_cast<HTMLInputElementImpl*>(n.
handle())->value().string();
3136 text +=
static_cast<HTMLSelectElementImpl*
>(n.
handle())->value().string();
3143 text +=
static_cast<HTMLImageElementImpl*
>(n.
handle())->altText().string();
3177 if(n == sel.end().node())
break;
3228 int end = text.length();
3231 while ((start < end) && (text[start] ==
'\n'))
3235 while ((start < (end-1)) && (text[end-1] ==
'\n') && (text[end-2] ==
'\n'))
3238 return text.mid(start, end-start);
3241 QString KHTMLPart::simplifiedSelectedText()
const 3244 text.replace(QChar(0xa0),
' ');
3246 while (!text.isEmpty() && text[0].isSpace())
3248 while (!text.isEmpty() && text[text.length()-1].isSpace())
3249 text.truncate(text.length()-1);
3255 return !
d->editor_context.m_selection.isEmpty() && !
d->editor_context.m_selection.isCollapsed();
3260 return d->editor_context.m_selection.toRange();
3265 DOM::Range r =
d->editor_context.m_selection.toRange();
3277 const Selection &KHTMLPart::caret()
const 3279 return d->editor_context.m_selection;
3282 const Selection &KHTMLPart::dragCaret()
const 3284 return d->editor_context.m_dragCaret;
3287 void KHTMLPart::setCaret(
const Selection &s,
bool closeTyping)
3289 if (
d->editor_context.m_selection != s) {
3290 clearCaretRectIfNeeded();
3291 setFocusNodeIfNeeded(s);
3292 d->editor_context.m_selection = s;
3293 notifySelectionChanged(closeTyping);
3297 void KHTMLPart::setDragCaret(
const DOM::Selection &dragCaret)
3299 if (
d->editor_context.m_dragCaret != dragCaret) {
3300 d->editor_context.m_dragCaret.needsCaretRepaint();
3301 d->editor_context.m_dragCaret = dragCaret;
3302 d->editor_context.m_dragCaret.needsCaretRepaint();
3306 void KHTMLPart::clearSelection()
3308 clearCaretRectIfNeeded();
3309 setFocusNodeIfNeeded(
d->editor_context.m_selection);
3310 #ifdef APPLE_CHANGES 3311 d->editor_context.m_selection.clear();
3313 d->editor_context.m_selection.collapse();
3315 notifySelectionChanged();
3318 void KHTMLPart::invalidateSelection()
3320 clearCaretRectIfNeeded();
3321 d->editor_context.m_selection.setNeedsLayout();
3322 selectionLayoutChanged();
3325 void KHTMLPart::setSelectionVisible(
bool flag)
3327 if (
d->editor_context.m_caretVisible == flag)
3330 clearCaretRectIfNeeded();
3331 setFocusNodeIfNeeded(
d->editor_context.m_selection);
3332 d->editor_context.m_caretVisible = flag;
3337 void KHTMLPart::slotClearSelection()
3340 &&
d->editor_context.m_selection.state() != Selection::NONE
3341 && !
d->editor_context.m_selection.caretPos().node()->isContentEditable())
3342 clearCaretRectIfNeeded();
3344 #ifdef APPLE_CHANGES 3345 d->editor_context.m_selection.clear();
3347 d->editor_context.m_selection.collapse();
3350 notifySelectionChanged();
3354 void KHTMLPart::clearCaretRectIfNeeded()
3356 if (
d->editor_context.m_caretPaint) {
3357 d->editor_context.m_caretPaint =
false;
3358 d->editor_context.m_selection.needsCaretRepaint();
3362 void KHTMLPart::setFocusNodeIfNeeded(
const Selection &s)
3364 if (!xmlDocImpl() || s.state() == Selection::NONE)
3367 NodeImpl *n = s.start().node();
3368 NodeImpl *target = (n && n->isContentEditable()) ? n : 0;
3370 while (n && n != s.end().node()) {
3371 if (n->isContentEditable()) {
3375 n = n->traverseNextNode();
3378 assert(target == 0 || target->isContentEditable());
3381 for ( ; target && !target->isFocusable(); target = target->parentNode())
3383 if (target && target->isMouseFocusable())
3384 xmlDocImpl()->setFocusNode(target);
3385 else if (!target || !target->focused())
3386 xmlDocImpl()->setFocusNode(0);
3390 void KHTMLPart::selectionLayoutChanged()
3393 if (
d->editor_context.m_caretBlinkTimer >= 0) {
3394 killTimer(
d->editor_context.m_caretBlinkTimer);
3395 d->editor_context.m_caretBlinkTimer = -1;
3399 if (
d->editor_context.m_caretVisible
3400 &&
d->editor_context.m_selection.state() != Selection::NONE) {
3402 ||
d->editor_context.m_selection.caretPos().node()->isContentEditable();
3403 if (
d->editor_context.m_caretBlinks &&
d->editor_context.m_caretPaint)
3404 d->editor_context.m_caretBlinkTimer = startTimer(qApp->cursorFlashTime() / 2);
3405 d->editor_context.m_selection.needsCaretRepaint();
3407 QRect r(
d->editor_context.m_selection.getRepaintRect());
3408 if (
d->editor_context.m_caretPaint)
3409 d->m_view->ensureVisible(r.x(), r.y());
3413 d->m_doc->updateSelection();
3417 d->editor_context.m_xPosForVerticalArrowNavigation =
d->editor_context.NoXPosForVerticalArrowNavigation;
3420 void KHTMLPart::notifySelectionChanged(
bool closeTyping)
3422 Editor *ed =
d->editor_context.m_editor;
3423 selectionLayoutChanged();
3431 emitSelectionChanged();
3436 if (e->timerId() ==
d->editor_context.m_caretBlinkTimer) {
3437 if (
d->editor_context.m_caretBlinks &&
3438 d->editor_context.m_selection.state() != Selection::NONE) {
3439 d->editor_context.m_caretPaint = !
d->editor_context.m_caretPaint;
3440 d->editor_context.m_selection.needsCaretRepaint();
3442 }
else if (e->timerId() ==
d->m_DNSPrefetchTimer) {
3445 if (
d->m_DNSPrefetchQueue.isEmpty()) {
3446 killTimer(
d->m_DNSPrefetchTimer );
3447 d->m_DNSPrefetchTimer = -1;
3449 }
else if (e->timerId() ==
d->m_DNSTTLTimer) {
3450 foreach (
const QString &
name,
d->m_lookedupHosts)
3451 d->m_DNSPrefetchQueue.enqueue(name);
3452 if (
d->m_DNSPrefetchTimer <= 0)
3466 int dots = name.count(
'.');
3467 if (dots > 2 || (dots == 2 && !name.startsWith(
"www.")))
3471 if (
d->m_lookedupHosts.contains( name ) )
3474 d->m_DNSPrefetchQueue.enqueue( name );
3475 d->m_lookedupHosts.insert( name );
3476 d->m_numDNSPrefetchedNames++;
3478 if (
d->m_DNSPrefetchTimer < 1)
3480 if (
d->m_DNSTTLTimer < 1)
3486 void KHTMLPart::paintCaret(QPainter *p,
const QRect &rect)
const 3488 if (
d->editor_context.m_caretPaint)
3489 d->editor_context.m_selection.paintCaret(p, rect);
3492 void KHTMLPart::paintDragCaret(QPainter *p,
const QRect &rect)
const 3494 d->editor_context.m_dragCaret.paintCaret(p, rect);
3498 if (!
d->editor_context.m_editor)
3499 const_cast<KHTMLPart *
>(
this)->
d->editor_context.m_editor =
new DOM::Editor(const_cast<KHTMLPart *>(
this));
3500 return d->editor_context.m_editor;
3503 void KHTMLPart::resetHoverText()
3505 if( !
d->m_overURL.isEmpty() )
3507 d->m_overURL.clear();
3508 d->m_overURLTarget.clear();
3509 emit
onURL( QString() );
3511 setStatusBarText(QString(), BarHoverText);
3512 emit
d->m_extension->mouseOverInfo(
KFileItem());
3516 void KHTMLPart::overURL(
const QString &url,
const QString &target,
bool )
3521 if ( url.isEmpty() )
3526 if ( url.isEmpty() ) {
3527 setStatusBarText(Qt::escape(u.
prettyUrl()), BarHoverText);
3531 if (
d->isJavaScriptURL(url) ) {
3532 QString jscode =
d->codeForJavaScriptURL( url );
3534 if (url.startsWith(
"javascript:window.open"))
3535 jscode +=
i18n(
" (In new window)");
3536 setStatusBarText( Qt::escape( jscode ), BarHoverText );
3541 emit
d->m_extension->mouseOverInfo(item);
3550 if ( !u.isValid() ) {
3551 setStatusBarText(Qt::escape(u.
prettyUrl()), BarHoverText);
3559 const QString path = QFile::encodeName( u.
toLocalFile() );
3561 KDE_struct_stat buff;
3564 KDE_struct_stat lbuff;
3567 QString text = Qt::escape(u.
prettyUrl());
3568 QString text2 = text;
3570 if (ok && S_ISLNK( lbuff.st_mode ) )
3574 tmp =
i18n(
"Symbolic Link");
3576 tmp =
i18n(
"%1 (Link)", com);
3577 char buff_two[1024];
3579 int n = readlink ( path.toLocal8Bit().data(), buff_two, 1022);
3584 setStatusBarText(text2, BarHoverText);
3593 else if ( ok && S_ISREG( buff.st_mode ) )
3595 if (buff.st_size < 1024)
3596 text =
i18np(
"%2 (%1 byte)",
"%2 (%1 bytes)", (
long) buff.st_size, text2);
3599 float d = (float) buff.st_size/1024.0;
3605 else if ( ok && S_ISDIR( buff.st_mode ) )
3615 setStatusBarText(text, BarHoverText);
3620 if (target.toLower() ==
"_blank")
3622 extra =
i18n(
" (In new window)");
3624 else if (!target.isEmpty() &&
3625 (target.toLower() !=
"_top") &&
3626 (target.toLower() !=
"_self") &&
3627 (target.toLower() !=
"_parent"))
3633 extra =
i18n(
" (In new window)");
3635 extra =
i18n(
" (In other frame)");
3638 if (u.
protocol() == QLatin1String(
"mailto")) {
3640 mailtoMsg +=
i18n(
"Email to: ") + KUrl::fromPercentEncoding(u.
path().toLatin1());
3641 const QStringList queries = u.
query().mid(1).split(
'&');
3642 QStringList::ConstIterator it = queries.begin();
3643 const QStringList::ConstIterator itEnd = queries.end();
3644 for (; it != itEnd; ++it)
3645 if ((*it).startsWith(QLatin1String(
"subject=")))
3646 mailtoMsg +=
i18n(
" - Subject: ") + KUrl::fromPercentEncoding((*it).mid(8).toLatin1());
3647 else if ((*it).startsWith(QLatin1String(
"cc=")))
3648 mailtoMsg +=
i18n(
" - CC: ") + KUrl::fromPercentEncoding((*it).mid(3).toLatin1());
3649 else if ((*it).startsWith(QLatin1String(
"bcc=")))
3650 mailtoMsg +=
i18n(
" - BCC: ") + KUrl::fromPercentEncoding((*it).mid(4).toLatin1());
3651 mailtoMsg = Qt::escape(mailtoMsg);
3652 mailtoMsg.replace(QRegExp(
"([\n\r\t]|[ ]{10})"), QString());
3653 setStatusBarText(
"<qt>"+mailtoMsg, BarHoverText);
3658 else if (u.
protocol() == QLatin1String(
"http")) {
3663 if (!hrefNode.
isNull()) {
3665 if (!hreflangNode.
isNull()) {
3668 if (countryCode == QLatin1String(
"en"))
3669 countryCode = QLatin1String(
"gb");
3670 QString flagImg = QLatin1String(
"<img src=%1>").arg(
3671 locate(
"locale", QLatin1String(
"l10n/")
3673 + QLatin1String(
"/flag.png")));
3674 emit setStatusBarText(flagImg + u.
prettyUrl() + extra);
3679 setStatusBarText(Qt::escape(u.
prettyUrl()) + extra, BarHoverText);
3691 bool hasTarget =
false;
3693 QString target = _target;
3694 if ( target.isEmpty() &&
d->m_doc )
3695 target =
d->m_doc->baseTarget();
3696 if ( !target.isEmpty() )
3699 if (
d->isJavaScriptURL(url) )
3701 crossFrameExecuteScript( target,
d->codeForJavaScriptURL(url) );
3707 if ( url.isEmpty() )
3710 if ( !cURL.isValid() )
3714 kDebug(6050) <<
this <<
"complete URL:" << cURL.
url() <<
"target=" << target;
3716 if ( state & Qt::ControlModifier )
3718 emit
d->m_extension->createNewWindow( cURL, args, browserArgs );
3722 if ( button == Qt::LeftButton && ( state & Qt::ShiftModifier ) )
3725 metaData.insert(
"referrer",
d->m_referrer );
3730 if (!checkLinkSecurity(cURL,
3731 ki18n(
"<qt>This untrusted page links to<br /><b>%1</b>.<br />Do you want to follow the link?</qt>" ),
3737 args.
metaData().insert(
"main_frame_request",
3739 args.
metaData().insert(
"ssl_parent_ip",
d->m_ssl_parent_ip);
3740 args.
metaData().insert(
"ssl_parent_cert",
d->m_ssl_parent_cert);
3741 args.
metaData().insert(
"PropagateHttpHeader",
"true");
3742 args.
metaData().insert(
"ssl_was_in_use",
d->m_ssl_in_use ?
"TRUE":
"FALSE");
3743 args.
metaData().insert(
"ssl_activate_warnings",
"TRUE");
3745 if ( hasTarget && target !=
"_self" && target !=
"_top" && target !=
"_blank" && target !=
"_parent" )
3748 khtml::ChildFrame *frame = recursiveFrameRequest(
this, cURL, args, browserArgs,
false );
3751 args.
metaData()[
"referrer"] =
d->m_referrer;
3752 requestObject( frame, cURL, args, browserArgs );
3757 if (!
d->m_referrer.isEmpty() && !args.
metaData().contains(
"referrer"))
3758 args.
metaData()[
"referrer"] =
d->m_referrer;
3760 if ( button == Qt::NoButton && (state & Qt::ShiftModifier) && (state & Qt::ControlModifier) )
3762 emit
d->m_extension->createNewWindow( cURL, args, browserArgs );
3766 if ( state & Qt::ShiftModifier)
3770 emit
d->m_extension->createNewWindow( cURL, args, browserArgs, winArgs );
3777 if (cURL.
hasRef() && (!hasTarget || target ==
"_self"))
3779 if (
d->isLocalAnchorJump(cURL))
3781 d->executeAnchorJump(cURL, browserArgs.
lockHistory() );
3786 if ( !
d->m_bComplete && !hasTarget )
3789 view()->viewport()->unsetCursor();
3790 emit
d->m_extension->openUrlRequest( cURL, args, browserArgs );
3794 void KHTMLPart::slotViewDocumentSource()
3797 bool isTempFile =
false;
3801 sourceFile.
setSuffix(defaultExtension());
3802 sourceFile.setAutoRemove(
false);
3803 if (sourceFile.open())
3805 QDataStream stream ( &sourceFile );
3807 currentUrl =
KUrl();
3808 currentUrl.
setPath(sourceFile.fileName());
3813 (void)
KRun::runUrl( currentUrl, QLatin1String(
"text/plain"),
view(), isTempFile );
3816 void KHTMLPart::slotViewPageInfo()
3821 dlg->setAttribute(Qt::WA_DeleteOnClose);
3822 dlg->setObjectName(
"KHTML Page Info Dialog");
3826 connect(ui._close, SIGNAL(clicked()), dlg, SLOT(accept()));
3829 ui._title->setText(
d->m_doc->title().string().trimmed());
3832 if (
parentPart() &&
d->m_doc &&
d->m_doc->isHTMLDocument() ) {
3833 dlg->setWindowTitle(
i18n(
"Frame Information"));
3838 if (!
d->m_pageServices.isEmpty())
3839 editStr =
i18n(
" <a href=\"%1\">[Properties]</a>",
d->m_pageServices);
3842 ui._url->setText(
"<a href=\"" +
url().
url() +
"\">" + squeezedURL +
"</a>" + editStr);
3845 ui._lastModified->hide();
3846 ui._lmLabel->hide();
3852 if (enc.isEmpty()) {
3854 ui._encoding->hide();
3856 ui._encoding->setText(enc);
3859 if (!xmlDocImpl() || xmlDocImpl()->parseMode() == DOM::DocumentImpl::Unknown) {
3861 ui._modeLabel->hide();
3863 switch (xmlDocImpl()->parseMode()) {
3864 case DOM::DocumentImpl::Compat:
3865 ui._mode->setText(
i18nc(
"HTML rendering mode (see http://en.wikipedia.org/wiki/Quirks_mode)",
"Quirks"));
3867 case DOM::DocumentImpl::Transitional:
3868 ui._mode->setText(
i18nc(
"HTML rendering mode (see http://en.wikipedia.org/wiki/Quirks_mode)",
"Almost standards"));
3870 case DOM::DocumentImpl::Strict:
3872 ui._mode->setText(
i18nc(
"HTML rendering mode (see http://en.wikipedia.org/wiki/Quirks_mode)",
"Strict"));
3878 const QStringList headers =
d->m_httpHeaders.split(
"\n");
3880 QStringList::ConstIterator it = headers.begin();
3881 const QStringList::ConstIterator itEnd = headers.end();
3883 for (; it != itEnd; ++it) {
3884 const QStringList
header = (*it).split(QRegExp(
":[ ]+"));
3885 if (header.count() != 2)
3887 QTreeWidgetItem *item =
new QTreeWidgetItem(ui._headers);
3888 item->setText(0, header[0]);
3889 item->setText(1, header[1]);
3897 void KHTMLPart::slotViewFrameSource()
3904 bool isTempFile =
false;
3905 if (!(url.
isLocalFile()) && frame->inherits(
"KHTMLPart"))
3907 long cacheId =
static_cast<KHTMLPart *
>(frame)->
d->m_cacheId;
3912 sourceFile.
setSuffix(defaultExtension());
3913 sourceFile.setAutoRemove(
false);
3914 if (sourceFile.open())
3916 QDataStream stream ( &sourceFile );
3919 url.
setPath(sourceFile.fileName());
3925 (void)
KRun::runUrl( url, QLatin1String(
"text/plain"),
view(), isTempFile );
3931 if (!
d->m_doc || !
d->m_doc->isHTMLDocument())
3934 QString relURL =
static_cast<HTMLDocumentImpl*
>(
d->m_doc)->body()->getAttribute( ATTR_BACKGROUND ).string();
3939 void KHTMLPart::slotSaveBackground()
3942 metaData[
"referrer"] =
d->m_referrer;
3946 void KHTMLPart::slotSaveDocument()
3951 srcURL.
setFileName(
"index" + defaultExtension() );
3958 void KHTMLPart::slotSecurity()
3982 const QStringList sl =
d->m_ssl_peer_chain.split(
'\n', QString::SkipEmptyParts);
3984 bool certChainOk =
d->m_ssl_in_use;
3986 foreach (
const QString &s, sl) {
3987 certChain.append(QSslCertificate(s.toLatin1()));
3988 if (certChain.last().isNull()) {
3989 certChainOk =
false;
3995 kid->setup(certChain,
3999 d->m_ssl_cipher_desc,
4000 d->m_ssl_cipher_version,
4001 d->m_ssl_cipher_used_bits.toInt(),
4002 d->m_ssl_cipher_bits.toInt(),
4011 QStringList sl =
d->m_ssl_peer_chain.split(
'\x01', QString::SkipEmptyParts);
4013 bool decodedOk =
true;
4014 foreach (
const QString &s, sl) {
4015 certChain.append(QSslCertificate(s.toLatin1()));
4016 if (certChain.last().isNull()) {
4022 if (decodedOk ||
true ) {
4026 d->m_ssl_protocol_version,
4028 d->m_ssl_cipher_used_bits.toInt(),
4029 d->m_ssl_cipher_bits.toInt(),
4031 kDebug(7024) <<
"Showing SSL Info dialog";
4033 kDebug(7024) <<
"SSL Info dialog closed";
4036 "appears to be corrupt."),
4041 void KHTMLPart::slotSaveFrame()
4050 srcURL.
setFileName(
"index" + defaultExtension() );
4057 void KHTMLPart::slotSetEncoding(
const QString &enc)
4065 d->m_autoDetectLanguage=scri;
4069 void KHTMLPart::slotUseStylesheet()
4073 bool autoselect = (
d->m_paUseStylesheet->currentItem() == 0);
4074 d->m_sheetUsed = autoselect ? QString() :
d->m_paUseStylesheet->currentText();
4075 d->m_doc->updateStyleSelector();
4079 void KHTMLPart::updateActions()
4085 for (; it !=
end; ++it )
4092 if (
d->m_paViewFrame)
4093 d->m_paViewFrame->setEnabled( frames );
4094 if (
d->m_paSaveFrame)
4095 d->m_paSaveFrame->setEnabled( frames );
4098 d->m_paFind->setText(
i18n(
"&Find in Frame..." ) );
4100 d->m_paFind->setText(
i18n(
"&Find..." ) );
4107 bool enableFindAndSelectAll =
true;
4110 enableFindAndSelectAll = frame->inherits(
"KHTMLPart" );
4112 d->m_paFind->setEnabled( enableFindAndSelectAll );
4113 d->m_paSelectAll->setEnabled( enableFindAndSelectAll );
4115 bool enablePrintFrame =
false;
4121 enablePrintFrame = ext->metaObject()->indexOfSlot(
"print()" ) != -1;
4124 d->m_paPrintFrame->setEnabled( enablePrintFrame );
4129 if (
d->m_doc &&
d->m_doc->isHTMLDocument() &&
static_cast<HTMLDocumentImpl*
>(
d->m_doc)->body() && !
d->m_bClearing )
4130 bgURL = static_cast<HTMLDocumentImpl*>(
d->m_doc)->body()->getAttribute( ATTR_BACKGROUND ).string();
4132 if (
d->m_paSaveBackground)
4133 d->m_paSaveBackground->setEnabled( !bgURL.isEmpty() );
4135 if (
d->m_paDebugScript )
4136 d->m_paDebugScript->setEnabled(
d->m_frame ?
d->m_frame->m_jscript : 0L );
4142 if ((*it)->m_partContainerElement.data() == frame)
4143 return (*it)->m_scriptable.data();
4147 void KHTMLPart::loadFrameElement( DOM::HTMLPartContainerElementImpl *frame,
const QString &url,
4148 const QString &frameName,
const QStringList ¶ms,
bool isIFrame )
4153 FrameIt it =
d->m_frames.find( frameName );
4154 if ( it ==
d->m_frames.end() ) {
4157 child->
m_name = frameName;
4158 d->m_frames.insert(
d->m_frames.end(), child );
4170 QString
khtml = QString::fromLatin1(
"khtml");
4172 QString::fromLatin1(
"text/html"),
4173 khtml, dummy, QStringList());
4179 navigateLocalProtocol(child, part,
KUrl(
"about:blank"));
4180 connectToChildPart(child, part,
"text/html" );
4190 if (!requestObject( child, u ) && !child->
m_run) {
4195 QString KHTMLPart::requestFrameName()
4197 return QString::fromLatin1(
"<!--frame %1-->").arg(
d->m_frameNameId++);
4200 bool KHTMLPart::loadObjectElement( DOM::HTMLPartContainerElementImpl *frame,
const QString &url,
4201 const QString &serviceType,
const QStringList ¶ms )
4205 FrameIt it =
d->m_objects.insert(
d->m_objects.end(), child );
4206 (*it)->m_partContainerElement = frame;
4208 (*it)->m_params = params;
4212 if (!requestObject( *it,
completeURL( url ), args ) && !(*it)->m_run) {
4213 (*it)->m_bCompleted =
true;
4224 if (!
d->isJavaScriptURL(url.
url()) && !checkLinkSecurity(url))
4226 kDebug(6031) <<
this <<
"checkLinkSecurity refused";
4248 if ( child->
m_run ) {
4249 kDebug(6031) <<
"navigating ChildFrame while mimetype resolution was in progress...";
4250 child->
m_run.data()->abort();
4266 if (!
d->m_referrer.isEmpty() && !child->
m_args.
metaData().contains(
"referrer" ))
4271 child->
m_args.
metaData().insert(
"ssl_parent_cert",
d->m_ssl_parent_cert);
4275 d->m_ssl_in_use ?
"TRUE":
"FALSE");
4276 child->
m_args.
metaData().insert(
"ssl_activate_warnings",
"TRUE");
4282 if ((url.isEmpty() || url.
url() ==
"about:blank" || url.
protocol() ==
"javascript") && args.
mimeType().isEmpty())
4286 kDebug(6031) <<
"Running new KHTMLRun for" <<
this <<
"and child=" << child;
4288 d->m_bComplete =
false;
4291 return processObjectRequest( child, url, args.
mimeType() );
4306 kDebug( 6031 ) <<
"trying to create part for" << mimetype << _url;
4316 if (
d->m_onlyLocalReferences || ( url.isEmpty() && mimetype.isEmpty() ) ) {
4317 childLoadFailure(child);
4329 emit
d->m_extension->openUrlNotify();
4343 (child->
m_run && child->
m_run.data()->serverSuggestsSave())) {
4361 QString suggestedFileName;
4362 int disposition = 0;
4364 suggestedFileName =
run->suggestedFileName();
4365 disposition =
run->serverSuggestsSave() ?
4396 if (mime->
is(
"text/html")
4397 || mime->
is(
"application/xml")) {
4401 childLoadFailure(child);
4411 childLoadFailure(child);
4415 connectToChildPart( child, part, mimetype );
4419 checkEmitLoadEvent();
4452 return navigateChild( child, url );
4458 if (!qobject_cast<KHTMLPart*>(inPart))
4466 d->propagateInitialDomainAndBaseTo(p);
4469 if (
d->isJavaScriptURL(url.
url())) {
4472 d->codeForJavaScriptURL(url.
url()));
4477 d->propagateInitialDomainAndBaseTo(p);
4478 p->
write( res.toString() );
4484 p->
write(
"<HTML><TITLE></TITLE><BODY></BODY></HTML>");
4494 if (url.
protocol() ==
"javascript" || url.
url() ==
"about:blank") {
4495 return navigateLocalProtocol(child, child->
m_part.data(),
url);
4496 }
else if ( !url.isEmpty() ) {
4497 kDebug( 6031 ) <<
"opening" << url <<
"in frame" << child->
m_part;
4498 bool b = child->
m_part.data()->openUrl( url );
4513 kDebug(6031) <<
"we:" <<
this <<
"kid:" << child << part << mimetype;
4515 part->setObjectName( child->
m_name );
4519 if (!qobject_cast<KHTMLPart*>(p) && child->
m_jscript)
4537 if (qobject_cast<KHTMLPart*>(part)) {
4538 static_cast<KHTMLPart*
>(part)->
d->m_frame = child;
4550 scriptExt->
setHost(
d->m_scriptableExtension);
4558 this, SLOT(slotChildStarted(
KIO::Job*)) );
4560 this, SLOT(slotChildCompleted()) );
4562 this, SLOT(slotChildCompleted(
bool)) );
4563 connect( part, SIGNAL(setStatusBarText(QString)),
4564 this, SIGNAL(setStatusBarText(QString)) );
4565 if ( part->inherits(
"KHTMLPart" ) )
4568 part, SLOT(slotParentCompleted()) );
4570 part, SLOT(slotParentCompleted()) );
4574 this, SLOT(slotChildDocCreated()) );
4581 connect( kidBrowserExt, SIGNAL(openUrlNotify()),
4582 d->m_extension, SIGNAL(openUrlNotify()) );
4595 connect( kidBrowserExt, SIGNAL(infoMessage(QString)),
4596 d->m_extension, SIGNAL(infoMessage(QString)) );
4601 kidBrowserExt->setBrowserInterface(
d->m_extension->browserInterface() );
4606 QObject *parent,
const QString &mimetype,
4607 QString &serviceName, QStringList &serviceTypes,
4608 const QStringList ¶ms )
4611 if ( !serviceName.isEmpty() )
4612 constr.append( QString::fromLatin1(
"DesktopEntryName == '%1'" ).arg( serviceName ) );
4616 if ( offers.isEmpty() ) {
4617 int pos = mimetype.indexOf(
"-plugin" );
4620 QString stripped_mime = mimetype.left( pos );
4622 if ( offers.isEmpty() )
4626 KService::List::ConstIterator it = offers.constBegin();
4627 const KService::List::ConstIterator itEnd = offers.constEnd();
4628 for ( ; it != itEnd; ++it )
4636 QVariantList variantlist;
4637 Q_FOREACH(
const QString& str, params)
4638 variantlist << QVariant(str);
4640 if ( service->
serviceTypes().contains(
"Browser/View" ) )
4641 variantlist << QString(
"Browser/View");
4646 serviceName = service->
name();
4651 kWarning() << QString(
"There was an error loading the module %1.\nThe diagnostics is:\n%2")
4660 if ( !
d->m_manager &&
d->m_view )
4663 d->m_manager->setObjectName(
"khtml part manager" );
4664 d->m_manager->setAllowNestedParts(
true );
4665 connect(
d->m_manager, SIGNAL(activePartChanged(
KParts::Part*)),
4671 return d->m_manager;
4674 void KHTMLPart::submitFormAgain()
4676 disconnect(
this, SIGNAL(
completed()),
this, SLOT(submitFormAgain()));
4677 if(
d->m_doc && !
d->m_doc->parsing() &&
d->m_submitForm)
4678 KHTMLPart::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 );
4680 delete d->m_submitForm;
4681 d->m_submitForm = 0;
4684 void KHTMLPart::submitFormProxy(
const char *
action,
const QString &url,
const QByteArray &formData,
const QString &_target,
const QString& contentType,
const QString& boundary )
4686 submitForm(action, url, formData, _target, contentType, boundary);
4689 void KHTMLPart::submitForm(
const char *
action,
const QString &url,
const QByteArray &formData,
const QString &_target,
const QString& contentType,
const QString& boundary )
4691 kDebug(6000) <<
this <<
"target=" << _target <<
"url=" <<
url;
4719 if (!
d->m_submitForm) {
4721 if (
d->m_ssl_in_use) {
4723 "\nA third party may be able to intercept and view this information." 4724 "\nAre you sure you wish to continue?"),
4732 i18n(
"Warning: Your data is about to be transmitted across the network unencrypted." 4733 "\nAre you sure you wish to continue?"),
4734 i18n(
"Network Transmission"),
4737 "WarnOnUnencryptedForm");
4739 QString grpNotifMsgs = QLatin1String(
"Notification Messages");
4742 if (!cg.
readEntry(
"WarnOnUnencryptedForm",
true)) {
4756 i18n(
"This site is attempting to submit form data via email.\n" 4757 "Do you want to continue?"),
4758 i18n(
"Network Transmission"),
4761 "WarnTriedEmailSubmit");
4772 QString urlstring = u.
url();
4774 if (
d->isJavaScriptURL(urlstring) ) {
4775 crossFrameExecuteScript( _target,
d->codeForJavaScriptURL(urlstring) );
4779 if (!checkLinkSecurity(u,
4780 ki18n(
"<qt>The form will be submitted to <br /><b>%1</b><br />on your local filesystem.<br />Do you want to submit the form?</qt>" ),
4786 d->clearRedirection();
4790 if (!
d->m_referrer.isEmpty())
4791 args.
metaData()[
"referrer"] =
d->m_referrer;
4793 args.
metaData().insert(
"PropagateHttpHeader",
"true");
4794 args.
metaData().insert(
"ssl_parent_ip",
d->m_ssl_parent_ip);
4795 args.
metaData().insert(
"ssl_parent_cert",
d->m_ssl_parent_cert);
4796 args.
metaData().insert(
"main_frame_request",
4798 args.
metaData().insert(
"ssl_was_in_use",
d->m_ssl_in_use ?
"TRUE":
"FALSE");
4799 args.
metaData().insert(
"ssl_activate_warnings",
"TRUE");
4804 browserArgs.
frameName = _target.isEmpty() ?
d->m_doc->baseTarget() : _target ;
4809 QString q = u.
query().mid(1);
4810 QStringList nvps = q.split(
"&");
4811 bool triedToAttach =
false;
4813 QStringList::Iterator nvp = nvps.begin();
4814 const QStringList::Iterator nvpEnd = nvps.end();
4819 while (nvp != nvpEnd) {
4820 const QStringList pair = (*nvp).split(
"=");
4821 if (pair.count() >= 2) {
4822 if (pair.first().toLower() ==
"attach") {
4823 nvp = nvps.erase(nvp);
4824 triedToAttach =
true;
4834 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(
"KDE"),
"WarnTriedAttach");
4838 if (contentType.toLower() ==
"multipart/form-data") {
4840 bodyEnc = QLatin1String( KUrl::toPercentEncoding(QString::fromLatin1(formData.data(),
4842 }
else if (contentType.toLower() ==
"text/plain") {
4844 QString tmpbody = QString::fromLatin1(formData.data(),
4846 tmpbody.replace(QRegExp(
"[&]"),
"\n");
4847 tmpbody.replace(QRegExp(
"[+]"),
" ");
4848 tmpbody = KUrl::fromPercentEncoding(tmpbody.toLatin1());
4849 bodyEnc = QLatin1String( KUrl::toPercentEncoding(tmpbody) );
4851 bodyEnc = QLatin1String( KUrl::toPercentEncoding(QString::fromLatin1(formData.data(),
4852 formData.size())) );
4855 nvps.append(QString(
"body=%1").arg(bodyEnc));
4862 u.
setQuery( QString::fromLatin1( formData.data(), formData.size() ) );
4870 if (contentType.isNull() || contentType ==
"application/x-www-form-urlencoded")
4871 browserArgs.
setContentType(
"Content-Type: application/x-www-form-urlencoded" );
4873 browserArgs.
setContentType(
"Content-Type: " + contentType +
"; boundary=" + boundary );
4876 if (
d->m_doc->parsing() ||
d->m_runningScripts > 0 ) {
4877 if(
d->m_submitForm ) {
4878 kDebug(6000) <<
"ABORTING!";
4882 d->m_submitForm->submitAction =
action;
4883 d->m_submitForm->submitUrl =
url;
4884 d->m_submitForm->submitFormData = formData;
4885 d->m_submitForm->target = _target;
4886 d->m_submitForm->submitContentType = contentType;
4887 d->m_submitForm->submitBoundary = boundary;
4888 connect(
this, SIGNAL(
completed()),
this, SLOT(submitFormAgain()));
4892 emit
d->m_extension->openUrlRequest( u, args, browserArgs );
4905 if ( linkUrl.isEmpty() ) {
4911 popupURL = khtmlPart->
url();
4919 linkKUrl = popupURL;
4923 if (!(
d->m_strSelectedURLTarget).isEmpty() &&
4924 (
d->m_strSelectedURLTarget.toLower() !=
"_top") &&
4925 (
d->m_strSelectedURLTarget.toLower() !=
"_self") &&
4926 (
d->m_strSelectedURLTarget.toLower() !=
"_parent")) {
4927 if (
d->m_strSelectedURLTarget.toLower() ==
"_blank")
4942 QPointer<QObject> guard( client );
4944 QString
mimetype = QLatin1String(
"text/html" );
4947 if (!linkUrl.isEmpty())
4956 if (!fname.isEmpty() && !popupURL.
hasRef() && popupURL.
query().isEmpty())
4965 !pmt->
is(
"application/x-perl") &&
4966 !pmt->
is(
"application/x-perl-module") &&
4967 !pmt->
is(
"application/x-php") &&
4968 !pmt->
is(
"application/x-python-bytecode") &&
4969 !pmt->
is(
"application/x-python") &&
4970 !pmt->
is(
"application/x-shellscript"))
4971 mimetype = pmt->
name();
4978 emit
d->m_extension->popupMenu( QCursor::pos(), popupURL, S_IFREG ,
4979 args, browserArgs, itemflags,
4982 if ( !guard.isNull() ) {
4984 emit
popupMenu(linkUrl, QCursor::pos());
4985 d->m_strSelectedURL.clear();
4986 d->m_strSelectedURLTarget.clear();
4990 void KHTMLPart::slotParentCompleted()
4993 if ( !
d->m_redirectURL.isEmpty() && !
d->m_redirectionTimer.isActive() )
4996 d->m_redirectionTimer.setSingleShot(
true );
4997 d->m_redirectionTimer.start( qMax(0, 1000 *
d->m_delayRedirect) );
5001 void KHTMLPart::slotChildStarted(
KIO::Job *job )
5009 if (
d->m_bComplete )
5015 emit
d->m_extension->openURLNotify();
5018 d->m_bComplete =
false;
5023 void KHTMLPart::slotChildCompleted()
5025 slotChildCompleted(
false );
5028 void KHTMLPart::slotChildCompleted(
bool pendingAction )
5040 if (!qobject_cast<KHTMLPart*>(child->
m_part))
5046 void KHTMLPart::slotChildDocCreated()
5051 if (
KHTMLPart* htmlFrame = qobject_cast<KHTMLPart*>(sender()))
5052 d->propagateInitialDomainAndBaseTo(htmlFrame);
5055 disconnect( sender(), SIGNAL(
docCreated()),
this, SLOT(slotChildDocCreated()) );
5062 if ( m_doc && kid->d->
m_doc ) {
5063 DocumentImpl* kidDoc = kid->d->
m_doc;
5064 if ( kidDoc->origin()->isEmpty() ) {
5065 kidDoc->setOrigin ( m_doc->origin() );
5066 kidDoc->setBaseURL( m_doc->baseURL() );
5077 QString urlStr = url.
url();
5078 if (
d->isJavaScriptURL(urlStr) ) {
5083 QString frameName = browserArgs.
frameName.toLower();
5084 if ( !frameName.isEmpty() ) {
5085 if ( frameName == QLatin1String(
"_top" ) )
5087 emit
d->m_extension->openUrlRequest( url, args, browserArgs );
5090 else if ( frameName == QLatin1String(
"_blank" ) )
5092 emit
d->m_extension->createNewWindow( url, args, browserArgs );
5095 else if ( frameName == QLatin1String(
"_parent" ) )
5099 emit
d->m_extension->openUrlRequest( url, args, newBrowserArgs );
5102 else if ( frameName != QLatin1String(
"_self" ) )
5104 khtml::ChildFrame *_frame = recursiveFrameRequest( callingHtmlPart, url, args, browserArgs );
5108 emit
d->m_extension->openUrlRequest( url, args, browserArgs );
5119 requestObject( child, url, args, browserArgs );
5120 }
else if ( frameName==
"_self" )
5124 emit
d->m_extension->openUrlRequest( url, args, newBrowserArgs );
5130 emit
d->m_extension->requestFocus(
this);
5135 assert( obj->inherits(
"KParts::ReadOnlyPart" ) );
5140 for (; it !=
end; ++it ) {
5141 if ((*it)->m_part.data() == part )
5146 const FrameIt oiEnd =
d->m_objects.end();
5147 for (; oi != oiEnd; ++oi ) {
5148 if ((*oi)->m_part.data() == part)
5157 bool KHTMLPart::checkFrameAccess(
KHTMLPart *callingHtmlPart)
5159 if (callingHtmlPart ==
this)
5162 if (!xmlDocImpl()) {
5163 #ifdef DEBUG_FINDFRAME 5164 kDebug(6050) <<
"Empty part" <<
this <<
"URL = " <<
url();
5170 if (callingHtmlPart && callingHtmlPart->xmlDocImpl() && xmlDocImpl()) {
5171 khtml::SecurityOrigin* actDomain = callingHtmlPart->xmlDocImpl()->origin();
5172 khtml::SecurityOrigin* destDomain = xmlDocImpl()->origin();
5174 if (actDomain->canAccess(destDomain))
5177 #ifdef DEBUG_FINDFRAME 5180 kDebug(6050) <<
"Unknown part/domain" << callingHtmlPart <<
"tries to access part" <<
this;
5189 return d->findFrameParent(callingPart, f, childFrame,
false);
5195 #ifdef DEBUG_FINDFRAME 5196 kDebug(6050) << q <<
"URL =" << q->url() <<
"name =" << q->objectName() <<
"findFrameParent(" << f <<
")";
5201 if (!callingHtmlPart)
5204 if (!checkForNavigation && !q->checkFrameAccess(callingHtmlPart))
5207 if (!childFrame && !q->parentPart() && (q->objectName() == f)) {
5208 if (!checkForNavigation || callingHtmlPart->d->
canNavigate(q))
5212 FrameIt it = m_frames.find( f );
5216 #ifdef DEBUG_FINDFRAME 5217 kDebug(6050) <<
"FOUND!";
5219 if (!checkForNavigation || callingHtmlPart->d->
canNavigate((*it)->m_part.data())) {
5226 it = m_frames.begin();
5227 for (; it !=
end; ++it )
5229 if (
KHTMLPart* p = qobject_cast<KHTMLPart*>((*it)->m_part.data()) )
5259 if (q->checkFrameAccess(b))
5263 if (q->parentPart() && top() == b)
5268 if (b->opener() && canNavigate(b->opener()))
5273 if (anc->checkFrameAccess(q))
5302 while ( part && part->inherits(
"KHTMLPart") &&
5303 static_cast<KHTMLPart *
>(part)->
d->m_frames.count() > 0 ) {
5306 if ( !part )
return frameset;
5313 FrameIt it =
d->m_frames.find( frameName );
5314 if ( it ==
d->m_frames.end() )
5320 return (!(*it)->m_partContainerElement.isNull());
5324 const QString& newName)
5326 for (
int i = 0; i < m_frames.size(); ++i) {
5337 return kp->jScript();
5340 const FrameIt itEnd =
d->m_frames.end();
5342 for (; it != itEnd; ++it) {
5344 if (framePart == frame->
m_part.data()) {
5355 return qobject_cast<
KHTMLPart*>( parent() );
5362 #ifdef DEBUG_FINDFRAME 5369 if (childPart ==
this)
5372 childPart->requestObject( childFrame, url, args, browserArgs );
5381 parentPart()->requestObject( res, url, args, browserArgs );
5387 #ifdef DEBUG_SAVESTATE 5388 static int s_saveStateIndentLevel = 0;
5393 #ifdef DEBUG_SAVESTATE 5394 QString
indent= QString().leftJustified( s_saveStateIndentLevel * 4,
' ' );
5395 const int indentLevel = s_saveStateIndentLevel++;
5396 kDebug( 6050 ) << indent <<
"saveState this=" <<
this <<
" '" << objectName() <<
"' saving URL " <<
url().
url();
5399 stream <<
url() << (qint32)
d->m_view->contentsX() << (qint32)
d->m_view->contentsY()
5400 << (qint32)
d->m_view->contentsWidth() << (qint32)
d->m_view->contentsHeight() << (qint32)
d->m_view->marginWidth() << (qint32)
d->m_view->marginHeight();
5403 int focusNodeNumber;
5404 if (!
d->m_focusNodeRestored)
5405 focusNodeNumber =
d->m_focusNodeNumber;
5406 else if (
d->m_doc &&
d->m_doc->focusNode())
5407 focusNodeNumber =
d->m_doc->nodeAbsIndex(
d->m_doc->focusNode());
5409 focusNodeNumber = -1;
5410 stream << focusNodeNumber;
5413 stream <<
d->m_cacheId;
5416 QStringList docState;
5419 docState =
d->m_doc->docState();
5421 stream <<
d->m_encoding <<
d->m_sheetUsed << docState;
5423 stream <<
d->m_zoomFactor;
5424 stream <<
d->m_fontScaleFactor;
5426 stream <<
d->m_httpHeaders;
5427 stream <<
d->m_pageServices;
5428 stream <<
d->m_pageReferrer;
5431 stream <<
d->m_ssl_in_use
5432 <<
d->m_ssl_peer_chain
5435 <<
d->m_ssl_protocol_version
5436 <<
d->m_ssl_cipher_used_bits
5437 <<
d->m_ssl_cipher_bits
5438 <<
d->m_ssl_cert_errors
5439 <<
d->m_ssl_parent_ip
5440 <<
d->m_ssl_parent_cert;
5443 QStringList frameNameLst, frameServiceTypeLst, frameServiceNameLst;
5450 for (; it !=
end; ++it )
5452 if ( !(*it)->m_part )
5455 frameNameLst << (*it)->m_name;
5456 frameServiceTypeLst << (*it)->m_serviceType;
5457 frameServiceNameLst << (*it)->m_serviceName;
5458 frameURLLst << (*it)->m_part.data()->url();
5461 QDataStream frameStream( &state, QIODevice::WriteOnly );
5463 if ( (*it)->m_extension )
5464 (*it)->m_extension.data()->saveState( frameStream );
5466 frameStateBufferLst << state;
5468 frameTypeLst << int( (*it)->m_type );
5472 stream << (quint32) frameNameLst.count();
5473 stream << frameNameLst << frameServiceTypeLst << frameServiceNameLst << frameURLLst << frameStateBufferLst << frameTypeLst;
5474 #ifdef DEBUG_SAVESTATE 5475 s_saveStateIndentLevel = indentLevel;
5482 qint32 xOffset, yOffset, wContents, hContents, mWidth, mHeight;
5484 QStringList
frameNames, frameServiceTypes, docState, frameServiceNames;
5490 long old_cacheId =
d->m_cacheId;
5492 stream >> u >> xOffset >> yOffset >> wContents >> hContents >> mWidth >> mHeight;
5494 d->m_view->setMarginWidth( mWidth );
5495 d->m_view->setMarginHeight( mHeight );
5499 stream >>
d->m_focusNodeNumber;
5500 d->m_focusNodeRestored =
false;
5502 stream >>
d->m_cacheId;
5504 stream >> encoding >> sheetUsed >> docState;
5507 d->m_sheetUsed = sheetUsed;
5517 stream >>
d->m_httpHeaders;
5518 stream >>
d->m_pageServices;
5519 stream >>
d->m_pageReferrer;
5522 stream >>
d->m_ssl_in_use
5523 >>
d->m_ssl_peer_chain
5526 >>
d->m_ssl_protocol_version
5527 >>
d->m_ssl_cipher_used_bits
5528 >>
d->m_ssl_cipher_bits
5529 >>
d->m_ssl_cert_errors
5530 >>
d->m_ssl_parent_ip
5531 >>
d->m_ssl_parent_cert;
5535 stream >> frameCount >> frameNames >> frameServiceTypes >> frameServiceNames
5536 >> frameURLs >> frameStateBuffers >> frameTypes;
5538 d->m_bComplete =
false;
5539 d->m_bLoadEventEmitted =
false;
5545 if (
d->m_cacheId == old_cacheId &&
signed(frameCount) ==
d->m_frames.count())
5548 d->m_redirectionTimer.stop();
5551 const FrameIt fEnd =
d->m_frames.end();
5553 for (; fIt != fEnd; ++fIt )
5554 (*fIt)->m_bCompleted =
false;
5556 fIt =
d->m_frames.begin();
5558 QStringList::ConstIterator fNameIt = frameNames.constBegin();
5559 QStringList::ConstIterator fServiceTypeIt = frameServiceTypes.constBegin();
5560 QStringList::ConstIterator fServiceNameIt = frameServiceNames.constBegin();
5561 KUrl::List::ConstIterator fURLIt = frameURLs.constBegin();
5565 for (; fIt != fEnd; ++fIt, ++fNameIt, ++fServiceTypeIt, ++fServiceNameIt, ++fURLIt, ++fBufferIt, ++fFrameTypeIt )
5574 child->
m_name = *fNameIt;
5577 processObjectRequest( child, *fURLIt, *fServiceTypeIt );
5582 if ( child->
m_extension && !(*fBufferIt).isEmpty() )
5584 QDataStream frameStream( *fBufferIt );
5585 child->
m_extension.data()->restoreState( frameStream );
5588 child->
m_part.data()->openUrl( *fURLIt );
5599 d->m_extension->setBrowserArguments(browserArgs);
5601 d->m_view->resizeContents( wContents, hContents );
5602 d->m_view->setContentsPos( xOffset, yOffset );
5612 d->m_bCleared =
false;
5615 d->m_sheetUsed = sheetUsed;
5617 QStringList::ConstIterator fNameIt = frameNames.constBegin();
5618 const QStringList::ConstIterator fNameEnd = frameNames.constEnd();
5620 QStringList::ConstIterator fServiceTypeIt = frameServiceTypes.constBegin();
5621 QStringList::ConstIterator fServiceNameIt = frameServiceNames.constBegin();
5622 KUrl::List::ConstIterator fURLIt = frameURLs.constBegin();
5626 for (; fNameIt != fNameEnd; ++fNameIt, ++fServiceTypeIt, ++fServiceNameIt, ++fURLIt, ++fBufferIt, ++fFrameTypeIt )
5630 newChild->
m_name = *fNameIt;
5636 const FrameIt childFrame =
d->m_frames.insert(
d->m_frames.end(), newChild );
5638 processObjectRequest( *childFrame, *fURLIt, *fServiceTypeIt );
5640 (*childFrame)->m_bPreloaded =
true;
5642 if ( (*childFrame)->m_part )
5644 if ( (*childFrame)->m_extension && !(*fBufferIt).isEmpty() )
5646 QDataStream frameStream( *fBufferIt );
5647 (*childFrame)->m_extension.data()->restoreState( frameStream );
5650 (*childFrame)->m_part.data()->openUrl( *fURLIt );
5661 d->m_extension->setBrowserArguments(browserArgs);
5665 d->m_restored =
true;
5667 d->m_restored =
false;
5691 return d->m_view->nodeUnderMouse();
5696 return d->m_view->nonSharedNodeUnderMouse();
5699 void KHTMLPart::emitSelectionChanged()
5703 if (!
d->m_activeFrame)
5705 emit
d->m_extension->enableAction(
"copy",
hasSelection() );
5713 return d->m_zoomFactor;
5717 static const int zoomSizes[] = { 20, 40, 60, 80, 90, 95, 100, 105, 110, 120, 140, 160, 180, 200, 250, 300 };
5723 extern const int KDE_NO_EXPORT
fastZoomSizes[] = { 20, 50, 75, 90, 100, 120, 150, 200, 300 };
5724 extern const int KDE_NO_EXPORT
fastZoomSizeCount =
sizeof fastZoomSizes /
sizeof fastZoomSizes[0];
5726 void KHTMLPart::slotIncZoom()
5731 void KHTMLPart::slotDecZoom()
5736 void KHTMLPart::slotIncZoomFast()
5738 zoomIn(fastZoomSizes, fastZoomSizeCount);
5741 void KHTMLPart::slotDecZoomFast()
5743 zoomOut(fastZoomSizes, fastZoomSizeCount);
5746 void KHTMLPart::zoomIn(
const int stepping[],
int count)
5750 if (zoomFactor < maxZoom) {
5752 for (
int i = 0; i < count; ++i)
5753 if (stepping[i] > zoomFactor) {
5754 zoomFactor = stepping[i];
5761 void KHTMLPart::zoomOut(
const int stepping[],
int count)
5764 if (zoomFactor > minZoom) {
5766 for (
int i = count-1; i >= 0; --i)
5767 if (stepping[i] < zoomFactor) {
5768 zoomFactor = stepping[i];
5779 if (percent < 100) percent = 100;
5782 if (percent > maxZoom) percent =
maxZoom;
5783 if (
d->m_zoomFactor == percent)
return;
5784 d->m_zoomFactor = percent;
5793 QApplication::setOverrideCursor( Qt::WaitCursor );
5794 d->m_view->setZoomLevel(
d->m_zoomFactor );
5795 QApplication::restoreOverrideCursor();
5800 for (; it !=
end; ++it ) {
5801 if (
KHTMLPart* p = qobject_cast<KHTMLPart*>((*it)->m_part.data()) )
5802 p->setZoomFactor(
d->m_zoomFactor);
5806 d->m_paDecZoomFactor->setEnabled(
d->m_zoomFactor > minZoom );
5807 d->m_paIncZoomFactor->setEnabled(
d->m_zoomFactor < maxZoom );
5811 void KHTMLPart::slotIncFontSize()
5816 void KHTMLPart::slotDecFontSize()
5821 void KHTMLPart::slotIncFontSizeFast()
5823 incFontSize(fastZoomSizes, fastZoomSizeCount);
5826 void KHTMLPart::slotDecFontSizeFast()
5828 decFontSize(fastZoomSizes, fastZoomSizeCount);
5831 void KHTMLPart::incFontSize(
const int stepping[],
int count)
5835 if (zoomFactor < maxZoom) {
5837 for (
int i = 0; i < count; ++i)
5838 if (stepping[i] > zoomFactor) {
5839 zoomFactor = stepping[i];
5846 void KHTMLPart::decFontSize(
const int stepping[],
int count)
5849 if (zoomFactor > minZoom) {
5851 for (
int i = count-1; i >= 0; --i)
5852 if (stepping[i] < zoomFactor) {
5853 zoomFactor = stepping[i];
5862 if (percent < minZoom) percent =
minZoom;
5863 if (percent > maxZoom) percent =
maxZoom;
5864 if (
d->m_fontScaleFactor == percent)
return;
5865 d->m_fontScaleFactor = percent;
5867 if (
d->m_view &&
d->m_doc) {
5868 QApplication::setOverrideCursor( Qt::WaitCursor );
5869 if (
d->m_doc->styleSelector())
5870 d->m_doc->styleSelector()->computeFontSizes(
d->m_doc->logicalDpiY(),
d->m_fontScaleFactor);
5871 d->m_doc->recalcStyle( NodeImpl::Force );
5872 QApplication::restoreOverrideCursor();
5877 for (; it !=
end; ++it ) {
5878 if (
KHTMLPart* p = qobject_cast<KHTMLPart*>((*it)->m_part.data()) )
5879 p->setFontScaleFactor(
d->m_fontScaleFactor);
5885 return d->m_fontScaleFactor;
5888 void KHTMLPart::slotZoomView(
int delta )
5896 void KHTMLPart::setStatusBarText(
const QString& text, StatusBarPriority p)
5898 if (!
d->m_statusMessagesEnabled)
5901 d->m_statusBarText[p] = text;
5904 QString tobe =
d->m_statusBarText[BarHoverText];
5906 tobe =
d->m_statusBarText[BarOverrideText];
5907 if (tobe.isEmpty()) {
5908 tobe =
d->m_statusBarText[BarDefaultText];
5909 if (!tobe.isEmpty() &&
d->m_jobspeed)
5916 emit ReadOnlyPart::setStatusBarText(tobe);
5922 setStatusBarText(text, BarOverrideText);
5927 setStatusBarText(text, BarDefaultText);
5932 return d->m_statusBarText[BarOverrideText];
5937 return d->m_statusBarText[BarDefaultText];
5942 return d->m_referrer;
5947 KUrl referrerURL =
KUrl(
d->m_pageReferrer );
5948 if (referrerURL.isValid())
5950 QString protocol = referrerURL.
protocol();
5952 if ((protocol ==
"http") ||
5953 ((protocol ==
"https") && (
url().protocol() ==
"https")))
5955 referrerURL.
setRef(QString());
5956 referrerURL.
setUser(QString());
5957 referrerURL.
setPass(QString());
5958 return referrerURL.
url();
5972 QDateTime lastModif = QFileInfo(
url().toLocalFile() ).lastModified();
5973 d->m_lastModified = lastModif.toString( Qt::LocalDate );
5976 return d->m_lastModified;
5979 void KHTMLPart::slotLoadImages()
5982 d->m_doc->docLoader()->setAutoloadImages( !
d->m_doc->docLoader()->autoloadImages() );
5986 for (; it !=
end; ++it ) {
5987 if (
KHTMLPart* p = qobject_cast<KHTMLPart*>((*it)->m_part.data()) )
5988 p->slotLoadImages();
5992 void KHTMLPart::reparseConfiguration()
5999 d->m_doc->docLoader()->setShowAnimations( settings->
showAnimations() );
6008 delete d->m_settings;
6011 QApplication::setOverrideCursor( Qt::WaitCursor );
6012 khtml::CSSStyleSelector::reparseConfiguration();
6013 if(
d->m_doc)
d->m_doc->updateStyleSelector();
6014 QApplication::restoreOverrideCursor();
6036 for (; it !=
end; ++it )
6037 if (!(*it)->m_bPreloaded && (*it)->m_part)
6038 res += (*it)->m_name;
6049 for (; it !=
end; ++it )
6050 if (!(*it)->m_bPreloaded && (*it)->m_part)
6052 res.append( (*it)->m_part.data() );
6062 if ( it ==
d->m_frames.end() )
6067 emit
d->m_extension->openUrlNotify();
6069 requestObject( *it, url, args, browserArgs );
6122 if (
d->editor_context.m_selection.state() == Selection::CARET)
6124 if (!xmlDocImpl()->renderer())
6127 khtml::RenderObject::NodeInfo nodeInfo(
true,
true);
6128 xmlDocImpl()->renderer()->layer()->nodeAtPoint(nodeInfo, x, y);
6129 NodeImpl *innerNode = nodeInfo.innerNode();
6130 if (!innerNode || !innerNode->renderer())
6133 return innerNode->isPointInsideSelection(x, y,
d->editor_context.m_selection);
6141 static bool firstRunAt(khtml::RenderObject *renderNode,
int y, NodeImpl *&startNode,
long &startOffset)
6143 for (khtml::RenderObject *n = renderNode; n; n = n->
nextSibling()) {
6145 khtml::RenderText*
const textRenderer =
static_cast<khtml::RenderText *
>(n);
6146 for (khtml::InlineTextBox* box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
6147 if (box->m_y == y && textRenderer->element()) {
6148 startNode = textRenderer->element();
6149 startOffset = box->m_start;
6168 static bool lastRunAt(khtml::RenderObject *renderNode,
int y, NodeImpl *&endNode,
long &endOffset)
6170 khtml::RenderObject *n = renderNode;
6174 khtml::RenderObject *
next;
6175 while ((next = n->nextSibling())) {
6180 if (
lastRunAt(n->firstChild(), y, endNode, endOffset)) {
6185 khtml::RenderText*
const textRenderer =
static_cast<khtml::RenderText *
>(n);
6186 for (khtml::InlineTextBox* box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
6187 if (box->m_y == y && textRenderer->element()) {
6188 endNode = textRenderer->element();
6189 endOffset = box->m_start + box->m_len;
6195 if (n == renderNode) {
6199 n = n->previousSibling();
6205 QMouseEvent *mouse =
event->qmouseEvent();
6206 DOM::Node innerNode =
event->innerNode();
6210 if (mouse->button() == Qt::LeftButton && !innerNode.
isNull() && innerNode.
handle()->renderer() &&
6211 innerNode.
handle()->renderer()->shouldSelect()) {
6212 Position pos(innerNode.
handle()->positionForCoordinates(event->
x(),
event->y()).position());
6213 if (pos.node() && (pos.node()->nodeType() == Node::TEXT_NODE || pos.node()->nodeType() == Node::CDATA_SECTION_NODE)) {
6214 selection.moveTo(pos);
6215 selection.expandUsingGranularity(Selection::WORD);
6219 if (selection.state() != Selection::CARET) {
6220 d->editor_context.beginSelectingText(Selection::WORD);
6223 setCaret(selection);
6229 QMouseEvent *mouse =
event->qmouseEvent();
6230 DOM::Node innerNode =
event->innerNode();
6234 if (mouse->button() == Qt::LeftButton && !innerNode.
isNull() && innerNode.
handle()->renderer() &&
6235 innerNode.
handle()->renderer()->shouldSelect()) {
6236 Position pos(innerNode.
handle()->positionForCoordinates(event->
x(),
event->y()).position());
6237 if (pos.node() && (pos.node()->nodeType() == Node::TEXT_NODE || pos.node()->nodeType() == Node::CDATA_SECTION_NODE)) {
6238 selection.moveTo(pos);
6239 selection.expandUsingGranularity(Selection::LINE);
6243 if (selection.state() != Selection::CARET) {
6244 d->editor_context.beginSelectingText(Selection::LINE);
6247 setCaret(selection);
6253 QMouseEvent *mouse =
event->qmouseEvent();
6254 DOM::Node innerNode =
event->innerNode();
6256 if (mouse->button() == Qt::LeftButton) {
6259 if (!innerNode.
isNull() && innerNode.
handle()->renderer() &&
6260 innerNode.
handle()->renderer()->shouldSelect()) {
6261 bool extendSelection = mouse->modifiers() & Qt::ShiftModifier;
6268 Position pos(innerNode.
handle()->positionForCoordinates(event->
x(),
event->y()).position());
6270 pos = Position(innerNode.
handle(), innerNode.
handle()->caretMinOffset());
6271 kDebug(6050) <<
event->x() <<
event->y() << pos << endl;
6274 if (extendSelection && sel.notEmpty()) {
6275 sel.clearModifyBias();
6277 if (
d->editor_context.m_selectionGranularity != Selection::CHARACTER) {
6278 sel.expandUsingGranularity(
d->editor_context.m_selectionGranularity);
6280 d->editor_context.m_beganSelectingText =
true;
6283 d->editor_context.m_selectionGranularity = Selection::CHARACTER;
6295 QMouseEvent *_mouse =
event->qmouseEvent();
6296 DOM::Node innerNode =
event->innerNode();
6297 d->m_mousePressNode = innerNode;
6299 d->m_dragStartPos = QPoint(event->
x(),
event->y());
6302 d->m_strSelectedURL =
event->url().string();
6303 d->m_strSelectedURLTarget =
event->target().string();
6306 d->m_strSelectedURL.clear();
6307 d->m_strSelectedURLTarget.clear();
6310 if ( _mouse->button() == Qt::LeftButton ||
6311 _mouse->button() == Qt::MidButton )
6313 d->m_bMousePressed =
true;
6315 #ifdef KHTML_NO_SELECTION 6316 d->m_dragLastPos = _mouse->globalPos();
6318 if ( _mouse->button() == Qt::LeftButton )
6320 if ( (!
d->m_strSelectedURL.isNull() && !
isEditable())
6321 || (!
d->m_mousePressNode.isNull() &&
d->m_mousePressNode.elementId() == ID_IMG) )
6324 d->editor_context.m_beganSelectingText =
false;
6326 handleMousePressEventSingleClick(event);
6331 if ( _mouse->button() == Qt::RightButton )
6340 QMouseEvent *_mouse =
event->qmouseEvent();
6341 if ( _mouse->button() == Qt::LeftButton )
6343 d->m_bMousePressed =
true;
6344 d->editor_context.m_beganSelectingText =
false;
6347 handleMousePressEventDoubleClick(event);
6352 handleMousePressEventTripleClick(event);
6358 #ifndef KHTML_NO_SELECTION 6359 bool KHTMLPart::isExtendingSelection()
const 6364 return d->editor_context.m_beganSelectingText;
6367 void KHTMLPart::extendSelectionTo(
int x,
int y,
const DOM::Node &innerNode)
6370 Position pos(innerNode.
handle()->positionForCoordinates(x, y).position());
6378 Selection sel = caret();
6379 sel.clearModifyBias();
6380 if (!
d->editor_context.m_beganSelectingText) {
6383 d->editor_context.beginSelectingText(Selection::CHARACTER);
6388 if (
d->editor_context.m_selectionGranularity != Selection::CHARACTER) {
6389 sel.expandUsingGranularity(
d->editor_context.m_selectionGranularity);
6394 #endif // KHTML_NO_SELECTION 6398 #ifdef QT_NO_DRAGANDDROP 6404 if( (
d->m_bMousePressed &&
6405 ( (!
d->m_strSelectedURL.isEmpty() && !
isEditable())
6406 || (!
d->m_mousePressNode.isNull() &&
d->m_mousePressNode.elementId() == ID_IMG) ) )
6410 DOM::NodeImpl* innerNodeImpl =
event->innerNode().handle();
6413 HTMLImageElementImpl *img = 0L;
6420 if (url.
isEmpty() && innerNodeImpl && innerNodeImpl->id() == ID_IMG)
6422 img =
static_cast<HTMLImageElementImpl *
>(innerNodeImpl);
6423 u =
completeURL(img->getAttribute(ATTR_SRC).string().trimmed());
6435 QDrag *drag =
new QDrag(
d->m_view->viewport() );
6437 if ( !
d->m_referrer.isEmpty() )
6438 metaDataMap.insert(
"referrer",
d->m_referrer );
6439 QMimeData* mimeData =
new QMimeData();
6441 drag->setMimeData( mimeData );
6443 if( img && img->complete() )
6444 drag->mimeData()->setImageData( img->currentImage() );
6446 if ( !pix.isNull() )
6447 drag->setPixmap( pix );
6453 d->m_bMousePressed =
false;
6454 d->m_strSelectedURL.clear();
6455 d->m_strSelectedURLTarget.clear();
6459 #endif // QT_NO_DRAGANDDROP 6465 if (
d->m_bMousePressed )
return false;
6473 QMouseEvent *_mouse =
event->qmouseEvent();
6474 DOM::Node innerNode =
event->innerNode();
6476 bool shiftPressed = ( _mouse->modifiers() & Qt::ShiftModifier );
6481 HTMLImageElementImpl *i =
static_cast<HTMLImageElementImpl *
>(innerNode.
handle());
6482 if ( i && i->isServerMap() )
6484 khtml::RenderObject *r = i->renderer();
6488 r->absolutePosition(absx, absy);
6489 int x(event->
x() - absx), y(event->
y() - absy);
6491 d->m_overURL = url.
string() + QString(
"?%1,%2").arg(x).arg(y);
6492 d->m_overURLTarget = target.
string();
6493 overURL(
d->m_overURL, target.
string(), shiftPressed );
6500 if (
d->m_overURL.isEmpty() ||
d->m_overURL != url ||
d->m_overURLTarget != target )
6503 d->m_overURLTarget = target.
string();
6504 overURL(
d->m_overURL, target.
string(), shiftPressed );
6509 if( !
d->m_overURL.isEmpty() )
6521 if (!
d->m_bMousePressed)
6524 #ifdef KHTML_NO_SELECTION 6525 if (
d->m_doc &&
d->m_view) {
6526 QPoint diff( mouse->globalPos() -
d->m_dragLastPos );
6528 if (abs(diff.x()) > 64 || abs(diff.y()) > 64) {
6529 d->m_view->scrollBy(-diff.x(), -diff.y());
6530 d->m_dragLastPos = mouse->globalPos();
6535 QMouseEvent *mouse =
event->qmouseEvent();
6536 DOM::Node innerNode =
event->innerNode();
6538 if ( (mouse->buttons() & Qt::LeftButton) == 0 || !innerNode.
handle() || !innerNode.
handle()->renderer() ||
6539 !innerNode.
handle()->renderer()->shouldSelect())
6543 extendSelectionTo(event->
x(),
event->y(), innerNode);
6544 #endif // KHTML_NO_SELECTION 6549 if (handleMouseMoveEventDrag(event))
6552 if (handleMouseMoveEventOver(event))
6555 handleMouseMoveEventSelection(event);
6560 DOM::Node innerNode =
event->innerNode();
6563 if (
d->m_bMousePressed ) {
6564 setStatusBarText(QString(), BarHoverText);
6570 d->m_bMousePressed =
false;
6572 #ifndef QT_NO_CLIPBOARD 6573 QMouseEvent *_mouse =
event->qmouseEvent();
6575 kDebug( 6050 ) <<
"MMB shouldOpen=" <<
d->m_bOpenMiddleClick;
6577 if (
d->m_bOpenMiddleClick) {
6585 #ifndef KHTML_NO_SELECTION 6591 if (!
d->editor_context.m_beganSelectingText
6592 &&
d->m_dragStartPos.x() ==
event->x()
6593 &&
d->m_dragStartPos.y() ==
event->y()
6594 &&
d->editor_context.m_selection.state() == Selection::RANGE) {
6596 #ifdef APPLE_CHANGES 6597 if (
d->editor_context.m_selection.base().node()->isContentEditable())
6599 selection.moveTo(
d->editor_context.m_selection.base().node()->positionForCoordinates(event->
x(),
event->y()).position());
6600 setCaret(selection);
6603 #ifndef QT_NO_CLIPBOARD 6605 text.replace(QChar(0xa0),
' ');
6606 if (!text.isEmpty()) {
6607 disconnect( qApp->clipboard(), SIGNAL(
selectionChanged()),
this, SLOT(slotClearSelection()));
6608 qApp->clipboard()->setText(text,QClipboard::Selection);
6609 connect( qApp->clipboard(), SIGNAL(
selectionChanged()), SLOT(slotClearSelection()));
6613 emitSelectionChanged();
6627 emitSelectionChanged();
6628 emit
d->m_extension->enableAction(
"print",
d->m_doc != 0 );
6630 if ( !
d->m_settings->autoLoadImages() &&
d->m_paLoadImages )
6633 lst.append(
d->m_paLoadImages );
6639 void KHTMLPart::slotPrintFrame()
6641 if (
d->m_frames.count() == 0 )
6654 const QMetaObject *mo = ext->metaObject();
6657 if (mo->indexOfSlot(
"print()") != -1)
6658 QMetaObject::invokeMethod(ext,
"print()", Qt::DirectConnection);
6661 void KHTMLPart::slotSelectAll()
6664 if (part && part->inherits(
"KHTMLPart"))
6665 static_cast<KHTMLPart *>(part)->selectAll();
6668 void KHTMLPart::startAutoScroll()
6670 connect(&
d->m_scrollTimer, SIGNAL(
timeout()),
this, SLOT(slotAutoScroll()));
6671 d->m_scrollTimer.setSingleShot(
false);
6672 d->m_scrollTimer.start(100);
6675 void KHTMLPart::stopAutoScroll()
6677 disconnect(&
d->m_scrollTimer, SIGNAL(
timeout()),
this, SLOT(slotAutoScroll()));
6678 if (
d->m_scrollTimer.isActive())
6679 d->m_scrollTimer.stop();
6683 void KHTMLPart::slotAutoScroll()
6686 d->m_view->doAutoScroll();
6691 void KHTMLPart::runAdFilter()
6699 QSetIterator<khtml::CachedObject*> it(
d->m_doc->docLoader()->m_docObjects );
6700 while (it.hasNext())
6702 khtml::CachedObject* obj = it.next();
6703 if ( obj->type() == khtml::CachedObject::Image ) {
6704 khtml::CachedImage *image =
static_cast<khtml::CachedImage *
>(obj);
6705 bool wasBlocked = image->m_wasBlocked;
6707 if ( image->m_wasBlocked != wasBlocked )
6708 image->do_notify(QRect(QPoint(0,0), image->pixmap_size()));
6713 for ( NodeImpl *nextNode, *node =
d->m_doc; node; node = nextNode ) {
6716 nextNode = node->traverseNextNode();
6718 if ( node->id() == ID_IMG ||
6719 node->id() == ID_IFRAME ||
6720 (node->id() == ID_INPUT &&
static_cast<HTMLInputElementImpl *
>(node)->inputType() == HTMLInputElementImpl::IMAGE ))
6726 while (nextNode && nextNode->isAncestor(node))
6727 nextNode = nextNode->traverseNextNode();
6730 NodeImpl *parent = node->parent();
6734 parent->removeChild(node, exception);
6745 if (!
d->m_doc)
return;
6748 if (
d->m_doc->isHTMLDocument())
6749 first = static_cast<HTMLDocumentImpl*>(
d->m_doc)->body();
6756 while ( first && !(first->renderer()
6757 && ((first->nodeType() == Node::TEXT_NODE || first->nodeType() == Node::CDATA_SECTION_NODE)
6758 || (first->renderer()->isReplaced() && !first->renderer()->firstChild()))))
6760 next = first->firstChild();
6761 if ( !next ) next = first->nextSibling();
6762 while( first && !next )
6764 first = first->parentNode();
6766 next = first->nextSibling();
6772 if (
d->m_doc->isHTMLDocument())
6773 last = static_cast<HTMLDocumentImpl*>(
d->m_doc)->body();
6780 while ( last && !(last->renderer()
6781 && ((last->nodeType() == Node::TEXT_NODE || last->nodeType() == Node::CDATA_SECTION_NODE)
6782 || (last->renderer()->isReplaced() && !last->renderer()->lastChild()))))
6784 next = last->lastChild();
6785 if ( !next ) next = last->previousSibling();
6786 while ( last && !next )
6788 last = last->parentNode();
6790 next = last->previousSibling();
6795 if ( !first || !last )
6797 Q_ASSERT(first->renderer());
6798 Q_ASSERT(last->renderer());
6799 d->editor_context.m_selection.moveTo(Position(first, 0), Position(last, last->nodeValue().length()));
6800 d->m_doc->updateSelection();
6802 emitSelectionChanged();
6807 bool linkAllowed =
true;
6812 if ( !linkAllowed ) {
6813 khtml::Tokenizer *tokenizer =
d->m_doc->tokenizer();
6815 tokenizer->setOnHold(
true);
6823 i18n(
"Security Warning" ),
6832 i18n(
"<qt>Access by untrusted page to<br /><b>%1</b><br /> denied.</qt>", Qt::escape(linkURL.
prettyUrl())),
6833 i18n(
"Security Alert" ));
6837 tokenizer->setOnHold(
false);
6846 if ( part ==
d->m_activeFrame )
6848 d->m_activeFrame = 0L;
6849 if ( !part->inherits(
"KHTMLPart" ) )
6861 void KHTMLPart::slotActiveFrameChanged(
KParts::Part *part )
6866 kError(6050) <<
"strange error! we activated ourselves";
6871 if (
d->m_activeFrame &&
d->m_activeFrame->widget() &&
d->m_activeFrame->widget()->inherits(
"QFrame" ) )
6873 QFrame *frame =
static_cast<QFrame *
>(
d->m_activeFrame->widget() );
6874 if (frame->frameStyle() != QFrame::NoFrame)
6876 frame->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken);
6881 if(
d->m_activeFrame && !
d->m_activeFrame->inherits(
"KHTMLPart" ) )
6888 if( part && !part->inherits(
"KHTMLPart" ) )
6897 d->m_activeFrame = part;
6899 if (
d->m_activeFrame &&
d->m_activeFrame->widget()->inherits(
"QFrame" ) )
6901 QFrame *frame =
static_cast<QFrame *
>(
d->m_activeFrame->widget() );
6902 if (frame->frameStyle() != QFrame::NoFrame)
6904 frame->setFrameStyle( QFrame::StyledPanel | QFrame::Plain);
6907 kDebug(6050) <<
"new active frame " <<
d->m_activeFrame;
6918 if (!
d->m_doc || !
d->m_view)
6922 d->m_doc->setFocusNode(node.
handle());
6925 QRect rect = node.
handle()->getRect();
6926 d->m_view->ensureVisible(rect.right(), rect.bottom());
6927 d->m_view->ensureVisible(rect.left(), rect.top());
6932 return DOM::Node(
d->m_doc?
d->m_doc->focusNode():0);
6935 DOM::EventListener *KHTMLPart::createHTMLEventListener( QString code, QString
name, NodeImpl* node,
bool svg )
6942 return proxy->createHTMLEventHandler(
url().
url(), name, code, node, svg );
6950 void KHTMLPart::setOpener(
KHTMLPart *_opener)
6952 d->m_opener = _opener;
6955 bool KHTMLPart::openedByJS()
6957 return d->m_openedByJS;
6960 void KHTMLPart::setOpenedByJS(
bool _openedByJS)
6962 d->m_openedByJS = _openedByJS;
6967 khtml::Cache::preloadStyleSheet(url, stylesheet);
6972 khtml::Cache::preloadScript(url, script);
6975 long KHTMLPart::cacheId()
const 6977 return d->m_cacheId;
6982 return d->m_restored;
6992 return d->m_pluginPageQuestionAsked.contains(mimetype);
7000 d->m_pluginPageQuestionAsked.append(mimetype);
7006 if( !
d->m_encoding.isNull() )
7007 dec->
setEncoding(
d->m_encoding.toLatin1().constData(),
7017 d->m_doc->setDecoder(dec);
7022 void KHTMLPart::emitCaretPositionChanged(
const DOM::Position &pos) {
7024 Position rng_pos = pos.equivalentRangeCompliantPosition();
7025 Node node = rng_pos.node();
7029 void KHTMLPart::restoreScrollPosition()
7033 if (
url().hasRef() && !
d->m_restoreScrollPosition && !args.
reload()) {
7034 if ( !
d->m_doc || !
d->m_doc->parsing() )
7035 disconnect(
d->m_view, SIGNAL(finishedLayout()),
this, SLOT(restoreScrollPosition()));
7045 if (
d->m_view->contentsHeight() -
d->m_view->visibleHeight() >= args.
yOffset()
7046 ||
d->m_bComplete) {
7048 disconnect(
d->m_view, SIGNAL(finishedLayout()),
this, SLOT(restoreScrollPosition()));
7053 void KHTMLPart::openWallet(DOM::HTMLFormElementImpl *form)
7055 #ifndef KHTML_NO_WALLET 7062 p->openWallet(form);
7071 if (
d->m_bWalletOpened) {
7072 if (
d->m_wallet->isOpen()) {
7073 form->walletOpened(
d->m_wallet);
7076 d->m_wallet->deleteLater();
7078 d->m_bWalletOpened =
false;
7085 d->m_wq->wallet = wallet;
7086 connect(wallet, SIGNAL(walletOpened(
bool)),
d->m_wq, SLOT(walletOpened(
bool)));
7091 #endif // KHTML_NO_WALLET 7097 #ifndef KHTML_NO_WALLET 7104 p->saveToWallet(key, data);
7109 if (
d->m_bWalletOpened) {
7110 if (
d->m_wallet->isOpen()) {
7115 d->m_wallet->writeMap(key, data);
7118 d->m_wallet->deleteLater();
7120 d->m_bWalletOpened =
false;
7127 d->m_wq->wallet = wallet;
7128 connect(wallet, SIGNAL(walletOpened(
bool)),
d->m_wq, SLOT(walletOpened(
bool)));
7131 d->m_wq->savers.append(qMakePair(key, data));
7132 #endif // KHTML_NO_WALLET 7136 void KHTMLPart::dequeueWallet(DOM::HTMLFormElementImpl *form) {
7137 #ifndef KHTML_NO_WALLET 7144 p->dequeueWallet(form);
7151 #endif // KHTML_NO_WALLET 7156 #ifndef KHTML_NO_WALLET 7160 d->m_wq->deleteLater();
7164 d->m_bWalletOpened =
false;
7168 d->m_wallet = wallet;
7169 d->m_bWalletOpened =
true;
7170 connect(
d->m_wallet, SIGNAL(walletClosed()), SLOT(slotWalletClosed()));
7171 d->m_walletForms.clear();
7172 if (!
d->m_statusBarWalletLabel) {
7173 d->m_statusBarWalletLabel =
new KUrlLabel(
d->m_statusBarExtension->statusBar());
7174 d->m_statusBarWalletLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum));
7175 d->m_statusBarWalletLabel->setUseCursor(
false);
7176 d->m_statusBarExtension->addStatusBarItem(
d->m_statusBarWalletLabel, 0,
false);
7177 d->m_statusBarWalletLabel->setPixmap(
SmallIcon(
"wallet-open"));
7178 connect(
d->m_statusBarWalletLabel, SIGNAL(leftClickedUrl()), SLOT(launchWalletManager()));
7179 connect(
d->m_statusBarWalletLabel, SIGNAL(rightClickedUrl()), SLOT(walletMenu()));
7182 #endif // KHTML_NO_WALLET 7188 #ifndef KHTML_NO_WALLET 7200 #endif // !KHTML_NO_WALLET 7204 void KHTMLPart::slotWalletClosed()
7206 #ifndef KHTML_NO_WALLET 7208 d->m_wallet->deleteLater();
7211 d->m_bWalletOpened =
false;
7212 if (
d->m_statusBarWalletLabel) {
7213 d->m_statusBarExtension->removeStatusBarItem(
d->m_statusBarWalletLabel);
7214 delete d->m_statusBarWalletLabel;
7215 d->m_statusBarWalletLabel = 0L;
7217 #endif // KHTML_NO_WALLET 7220 void KHTMLPart::launchWalletManager()
7222 #ifndef KHTML_NO_WALLET 7223 QDBusInterface r(
"org.kde.kwalletmanager",
"/kwalletmanager/MainWindow_1",
7224 "org.kde.KMainWindow");
7228 r.call(QDBus::NoBlock,
"show");
7229 r.call(QDBus::NoBlock,
"raise");
7231 #endif // KHTML_NO_WALLET 7234 void KHTMLPart::walletMenu()
7236 #ifndef KHTML_NO_WALLET 7238 QActionGroup *menuActionGroup =
new QActionGroup(menu);
7239 connect( menuActionGroup, SIGNAL(triggered(
QAction*)),
this, SLOT(removeStoredPasswordForm(
QAction*)) );
7241 menu->addAction(
i18n(
"&Close Wallet"),
this, SLOT(slotWalletClosed()));
7243 if (
d->m_view &&
d->m_view->nonPasswordStorableSite(
toplevelURL().host())) {
7244 menu->addAction(
i18n(
"&Allow storing passwords for this site"),
this, SLOT(delNonPasswordStorableSite()));
7248 for ( QStringList::ConstIterator it =
d->m_walletForms.constBegin(); it !=
d->m_walletForms.constEnd(); ++it ) {
7250 action->setActionGroup(menuActionGroup);
7252 action->setData(var);
7256 menu->popup(QCursor::pos());
7257 #endif // KHTML_NO_WALLET 7262 #ifndef KHTML_NO_WALLET 7265 QVariant var(action->data());
7270 QString key = var.toString();
7281 if (
d->m_wallet->removeEntry(key))
7284 d->m_walletForms.removeAll(key);
7285 #endif // KHTML_NO_WALLET 7288 void KHTMLPart::addWalletFormKey(
const QString& walletFormKey)
7290 #ifndef KHTML_NO_WALLET 7293 parentPart()->addWalletFormKey(walletFormKey);
7297 if(!
d->m_walletForms.contains(walletFormKey))
7298 d->m_walletForms.append(walletFormKey);
7299 #endif // KHTML_NO_WALLET 7302 void KHTMLPart::delNonPasswordStorableSite()
7304 #ifndef KHTML_NO_WALLET 7306 d->m_view->delNonPasswordStorableSite(
toplevelURL().host());
7307 #endif // KHTML_NO_WALLET 7309 void KHTMLPart::saveLoginInformation(
const QString& host,
const QString& key,
const QMap<QString, QString>& walletMap)
7311 #ifndef KHTML_NO_WALLET 7312 d->m_storePass.saveLoginInformation(host, key, walletMap);
7313 #endif // KHTML_NO_WALLET 7316 void KHTMLPart::slotToggleCaretMode()
7322 d->m_formNotification = fn;
7326 return d->m_formNotification;
7346 return d->m_doc->unsubmittedFormChanges();
7349 void KHTMLPart::setDebugScript(
bool enable )
7353 if (!
d->m_paDebugScript) {
7354 d->m_paDebugScript =
new KAction(
i18n(
"JavaScript &Debugger" ),
this );
7356 connect(
d->m_paDebugScript, SIGNAL(triggered(
bool)),
this, SLOT(slotDebugScript()) );
7358 d->m_paDebugScript->setEnabled(
d->m_frame ?
d->m_frame->m_jscript : 0L );
7360 lst.append(
d->m_paDebugScript );
7363 d->m_bJScriptDebugEnabled = enable;
7373 if ( enable && originPart ) {
7374 d->m_openableSuppressedPopups++;
7375 if (
d->m_suppressedPopupOriginParts.indexOf( originPart ) == -1 )
7376 d->m_suppressedPopupOriginParts.append( originPart );
7379 if ( enable && !
d->m_statusBarPopupLabel ) {
7380 d->m_statusBarPopupLabel =
new KUrlLabel(
d->m_statusBarExtension->statusBar() );
7381 d->m_statusBarPopupLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ));
7382 d->m_statusBarPopupLabel->setUseCursor(
false );
7383 d->m_statusBarExtension->addStatusBarItem(
d->m_statusBarPopupLabel, 0,
false );
7384 d->m_statusBarPopupLabel->setPixmap(
SmallIcon(
"window-suppressed") );
7386 d->m_statusBarPopupLabel->setToolTip(
i18n(
"This page was prevented from opening a new window via JavaScript." ) );
7388 connect(
d->m_statusBarPopupLabel, SIGNAL(leftClickedUrl()), SLOT(suppressedPopupMenu()));
7389 if (
d->m_settings->jsPopupBlockerPassivePopup()) {
7392 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);
7394 }
else if ( !enable &&
d->m_statusBarPopupLabel ) {
7395 d->m_statusBarPopupLabel->setToolTip(
"" );
7396 d->m_statusBarExtension->removeStatusBarItem(
d->m_statusBarPopupLabel );
7397 delete d->m_statusBarPopupLabel;
7398 d->m_statusBarPopupLabel = 0L;
7402 void KHTMLPart::suppressedPopupMenu() {
7404 if (
d->m_openableSuppressedPopups )
7405 m->addAction(
i18np(
"&Show Blocked Popup Window",
"&Show %1 Blocked Popup Windows",
d->m_openableSuppressedPopups),
this, SLOT(showSuppressedPopups()));
7406 QAction *a = m->addAction(
i18n(
"Show Blocked Window Passive Popup &Notification"),
this, SLOT(togglePopupPassivePopup()));
7407 a->setChecked(
d->m_settings->jsPopupBlockerPassivePopup());
7408 m->addAction(
i18n(
"&Configure JavaScript New Window Policies..."),
this, SLOT(launchJSConfigDialog()));
7409 m->popup(QCursor::pos());
7412 void KHTMLPart::togglePopupPassivePopup() {
7414 d->m_settings->setJSPopupBlockerPassivePopup( !
d->m_settings->jsPopupBlockerPassivePopup() );
7418 void KHTMLPart::showSuppressedPopups() {
7419 foreach (
KHTMLPart* part,
d->m_suppressedPopupOriginParts ) {
7421 KJS::Window *w = KJS::Window::retrieveWindow( part );
7423 w->showSuppressedWindows();
7424 w->forgetSuppressedWindows();
7429 d->m_openableSuppressedPopups = 0;
7430 d->m_suppressedPopupOriginParts.clear();
7435 QString KHTMLPart::defaultExtension()
const 7439 if ( !
d->m_doc->isHTMLDocument() )
7441 return d->m_doc->htmlMode() == DOM::DocumentImpl::XHtml ?
".xhtml" :
".html";
7446 if (!
d->m_bComplete ||
d->m_runningScripts || (
d->m_doc &&
d->m_doc->parsing()))
7452 for (; it !=
end; ++it ) {
7453 if ((*it)->m_run || !(*it)->m_bCompleted)
7457 return d->m_submitForm || !
d->m_redirectURL.isEmpty() ||
d->m_redirectionTimer.isActive() ||
d->m_job;
7461 #include "khtml_part.moc" 7462 #include "khtmlpart_p.moc" 7463 #ifndef KHTML_NO_WALLET 7464 #include "khtml_wallet_p.moc" void findTextBegin()
Initiates a text search.
static const int sDNSTTLSeconds
KParts::ReadOnlyPart * findFramePart(const QString &f)
Finds a frame by name.
virtual void setWindow(QWidget *window)
QString m_ssl_cert_errors
Settings for the HTML view.
bool jsErrorsEnabled() const
virtual void khtmlDrawContentsEvent(khtml::DrawContentsEvent *)
Eventhandler for the khtml::DrawContentsEvent.
void hide()
Convenience method to hide the document's view.
QTimer m_redirectionTimer
KHTMLFrameList::ConstIterator ConstFrameIt
void message(KMessage::MessageType messageType, const QString &text, const QString &caption=QString())
void executeAnchorJump(const KUrl &url, bool lockHistory)
QString i18n(const char *text)
bool kill(KillVerbosity verbosity=Quietly)
Contextual information about the caret and the built-in editor.
DOM::Node nodeUnderMouse() const
Returns the Node currently under the mouse.
KSelectAction * m_paUseStylesheet
void setSelection(const DOM::Range &)
Sets the current selection.
static ScriptableExtension * childObject(QObject *obj)
void setLockHistory(bool lock)
MimeType classifyMimeType(const QString &mime)
DOM::DocumentImpl * m_doc
unsigned int m_jobPercent
bool nextAnchor()
Go to the next anchor.
bool isJavaScriptEnabled(const QString &hostname=QString()) const
QString getCacheControlString(KIO::CacheControl cacheControl)
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) const
DNSPrefetch dnsPrefetch() const
Returns currently set DNS prefetching mode.
static const int sDNSPrefetchTimerDelay
void fetchData(long id, QObject *recvObj, const char *recvSlot)
Fetch data for cache entry id and send it to slot recvSlot in the object recvObj. ...
QPixmap MainBarIcon(const QString &name, int force_size, int state, const QStringList &overlays)
void setFlagRecursively(bool KHTMLPartPrivate::*flag, bool value)
KAction * m_paViewDocument
void setShortcuts(const QList< QKeySequence > &shortcuts, ShortcutTypes type=ShortcutTypes(ActiveShortcut|DefaultShortcut))
CaretDisplayPolicy caretDisplayPolicyNonFocused() const
Returns the current caret policy when the view is not focused.
KUrl completeURL(const QString &url)
returns a KUrl object for the given url.
static List split(const QString &_url)
int zoomFactor() const
Returns the current zoom factor.
void addMetaData(const QString &key, const QString &value)
The Node interface is the primary datatype for the entire Document Object Model.
QAction * action(const char *name) const
KAction * m_paStopAnimations
int fontScaleFactor() const
Returns the current font scale factor.
KToggleAction * m_paToggleCaretMode
KParts::BrowserExtension * browserExtension() const
Returns a pointer to the KParts::BrowserExtension.
This class resembles the editing API when the associated khtml document is editable (in design mode)...
virtual bool doOpenStream(const QString &mimeType)
Implements the streaming API of KParts::ReadOnlyPart.
static QList< QList< KSslError::Error > > errorsFromString(const QString &s)
KEncodingDetector::AutoDetectScript m_autoDetectLanguage
virtual Part * activePart() const
QStringList m_walletForms
DOM::Editor * editor() const
Returns the instance of the attached html editor interface.
void setUserStyleSheet(const KUrl &url)
Sets a user defined style sheet to be used on top of the HTML 4 default style sheet.
int m_openableSuppressedPopups
virtual void slotFinished(KJob *)
Called when the job downloading the page is finished.
QString rsqueeze(const QString &str, int maxlen=40)
static void removeTempFile(const QString &name)
An HTMLDocument is the root of the HTML hierarchy and holds the entire content.
T * create(QObject *parent=0, const QVariantList &args=QVariantList())
static KHTMLPageCache * self()
static "constructor".
Node endContainer() const
Node within which the range ends.
bool isHideAdsEnabled() const
KParts::ReadOnlyPart * currentFrame() const
Return the current frame (the one that has focus) Not necessarily a direct child of ours...
khtml::EditorContext editor_context
KParts::PartManager * m_manager
QString decodeWithBuffering(const char *data, int len)
void setJSErrorsEnabled(bool enabled)
virtual void restoreState(QDataStream &stream)
Restores the KHTMLPart's previously saved state (including child frame objects) from the provided QDa...
static KIconLoader * global()
QMap< QString, QString > & metaData()
static QString codeForJavaScriptURL(const QString &url)
unsigned long m_totalObjectCount
static const KComponentData & componentData()
QStringList serviceTypes() const
KParts::OpenUrlArguments m_args
void removeClient(KXMLGUIClient *client)
DOM::HTMLDocument htmlDocument() const
Returns a reference to the DOM HTML document (for non-HTML documents, returns null) ...
QString lastModified() const
Last-modified date (in raw string format), if received in the [HTTP] headers.
static bool test(const QEvent *event)
KUrlLabel * m_statusBarUALabel
QString userStyleSheet() const
static QString userAgentForHost(const QString &hostname)
void populateMimeData(QMimeData *mimeData, const MetaDataMap &metaData=MetaDataMap(), MimeDataFlags flags=DefaultMimeDataFlags) const
void removeChildClient(KXMLGUIClient *child)
DOM::DOMString url() const
KLocalizedString ki18n(const char *msg)
void setJSStatusBarText(const QString &text)
Called by KJS.
QWeakPointer< KHTMLRun > m_run
QString i18np(const char *sing, const char *plur, const A1 &a1)
KParts::BrowserArguments m_browserArgs
KHTMLView * view() const
Returns a pointer to the HTML document's view.
static const int zoomSizeCount
bool isPointInsideSelection(int x, int y)
Returns whether the given point is inside the current selection.
bool pluginPageQuestionAsked(const QString &mimetype) const
MimetypeJob * mimetype(const KUrl &url, JobFlags flags=DefaultFlags)
bool visuallyOrdered() const
KHTMLFrameList::Iterator FrameIt
static void information(QWidget *parent, const QString &text, const QString &caption=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
static QString locate(const char *type, const QString &filename, const KComponentData &cData=KGlobal::mainComponent())
void addClient(KXMLGUIClient *client)
bool equals(const KUrl &u, const EqualsOptions &options=0) const
KEncodingDetector * m_decoder
KParts::BrowserHostExtension * browserHostExtension() const
bool dndEnabled() const
Returns whether Dragn'n'Drop support is enabled or not.
QList< QPointer< KHTMLPart > > m_suppressedPopupOriginParts
static Ptr findByPath(const QString &path, mode_t mode=0, bool fast_mode=false, int *accuracy=0)
QQueue< QString > m_DNSPrefetchQueue
void setAutoDetectLanguage(AutoDetectScript)
KAction * zoomOut(const QObject *recvr, const char *slot, QObject *parent)
void setSuggestedFileName(const QString &suggestedFileName)
void removeCatalog(const QString &catalog)
const QByteArray encoding() const
KHTMLPart::GUIProfile m_guiProfile
bool frameExists(const QString &frameName)
Returns whether a frame with the specified name is exists or not.
virtual void removePart(Part *part)
KService::List query(const QString &mimeType, const QString &genericServiceType=QString::fromLatin1("Application"), const QString &constraint=QString()) const
TransferJob * get(const KUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
int stat(const QString &path, KDE_struct_stat *buf)
This class is khtml's main class.
const char * name(StandardAction id)
void setRef(const QString &fragment)
void setPluginsEnabled(bool enable)
Enables or disables plugins, default is enabled.
Node startContainer() const
Node within which the range begins.
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
StatJob * stat(const KUrl &url, JobFlags flags=DefaultFlags)
static bool test(const QEvent *event)
KUrlLabel * m_statusBarJSErrorLabel
virtual void saveState(QDataStream &stream)
Saves the KHTMLPart's complete state (including child frame objects) to the provided QDataStream...
KSelectAction * m_paIncZoomFactor
QAction * addAction(const QString &name, QAction *action)
Renders and displays HTML in a QScrollArea.
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
virtual QWidget * widget()
virtual void setXMLFile(const QString &file, bool merge=false, bool setXMLDoc=true)
friend class KHTMLPartBrowserHostExtension
KHTMLPart * part() const
Returns a pointer to the KHTMLPart that is rendering the page.
void setUrl(const KUrl &url)
bool isFullyLoaded(bool *pendingRedirections) const
KAction * m_paSaveBackground
bool m_bPendingRedirection
QPixmap pixmapForUrl(const KUrl &_url, mode_t _mode=0, KIconLoader::Group _group=KIconLoader::Desktop, int _force_size=0, int _state=0, QString *_path=0)
CompareWithoutTrailingSlash
SubmitForm * m_submitForm
static KHTMLSettings * defaultHTMLSettings()
bool isDetached() const
not part of the DOM true if the range is detached
virtual bool urlSelected(const QString &url, int button, int state, const QString &_target, const KParts::OpenUrlArguments &args=KParts::OpenUrlArguments(), const KParts::BrowserArguments &browserArgs=KParts::BrowserArguments())
void setSuffix(const QString &suffix)
KHTMLPartBrowserExtension * m_extension
static bool isAncestorOrSamePart(KHTMLPart *p1, KHTMLPart *p2)
friend class KHTMLPartIface
void addError(const QString &error)
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QString queryMetaData(const QString &key)
void setDoPost(bool enable)
KHTMLPartBrowserHostExtension * m_hostExtension
KHTMLPart * findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame, bool checkForNavigation)
QString indent(QString text, int spaces)
void associateWidget(QWidget *widget) const
void setCaretMode(bool enable)
Enables/disables caret mode.
bool strcmp(const DOMString &a, const DOMString &b)
static bool s_dnsInitialised
void selectionChanged()
This signal is emitted when the selection changes.
bool setEncoding(const QString &name, bool override=false)
Sets the encoding the page uses.
QString prettyUrl(AdjustPathOption trailing=LeaveTrailingSlash) const
virtual void khtmlMouseReleaseEvent(khtml::MouseReleaseEvent *event)
Eventhandler for the khtml::MouseMouseReleaseEvent.
bool run(const KUrl &_url, bool _is_local)
bool canNavigate(KParts::ReadOnlyPart *b)
static Wallet * openWallet(const QString &name, WId w, OpenType ot=Synchronous)
void setQuery(const QString &query)
void setOptions(long options)
Set the options which are checked.
QString i18nc(const char *ctxt, const char *text)
virtual void customEvent(QEvent *event)
KSharedConfigPtr config()
QPointer< KHTMLViewBar > m_topViewBar
KLocalizedString subs(int a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const
QString formatNumber(double num, int precision=-1) const
void setOnlyLocalReferences(bool enable)
Security option.
void setPath(const QString &path)
KCodecAction * m_paSetEncoding
KSelectAction * m_paDecZoomFactor
bool javaEnabled() const
Return true if Java applet support is enabled, false if disabled.
QString comment(const KUrl &url=KUrl()) const
friend class KHTMLPartBrowserExtension
QString errorString() const
static void deregisterPart(KHTMLPart *part)
bool isCaretMode() const
Returns whether caret mode is on/off.
bool isJavaEnabled(const QString &hostname=QString()) const
void setUser(const QString &user)
KParts::StatusBarExtension * m_statusBarExtension
static bool firstRunAt(khtml::RenderObject *renderNode, int y, NodeImpl *&startNode, long &startOffset)
returns the position of the first inline text box of the line at coordinate y in renderNode ...
QPixmap loadIcon(const QString &name, KIconLoader::Group group, int size=0, int state=KIconLoader::DefaultState, const QStringList &overlays=QStringList(), QString *path_store=0L, bool canReturnNull=false) const
void formSubmitNotification(const char *action, const QString &url, const QByteArray &formData, const QString &target, const QString &contentType, const QString &boundary)
If form notification is on, this will be emitted either for a form submit or before the form submit a...
void onURL(const QString &url)
Emitted if the cursor is moved over an URL.
void deleteEntry(const QString &pKey, WriteConfigFlags pFlags=Normal)
virtual void customEvent(QEvent *event)
KSmoothScrollingMode smoothScrolling() const
bool isAutoDelayedActionsEnabled() const
QPointer< KHTMLView > m_view
KHTMLFindBar * findBar() const
bool isModified() const
Checks whether the page contains unsubmitted form changes.
void plugActionList(const QString &name, const QList< QAction * > &actionList)
static bool lastRunAt(khtml::RenderObject *renderNode, int y, NodeImpl *&endNode, long &endOffset)
returns the position of the last inline text box of the line at coordinate y in renderNode ...
void setPageSecurity(PageSecurity sec)
QList< KXMLGUIClient *> childClients()
const int KDE_NO_EXPORT fastZoomSizes[]
KAction * m_paDebugRenderTree
void setCaretVisible(bool show)
Sets the visibility of the caret.
void setMetaRefreshEnabled(bool enable)
Enable/disable automatic forwarding by <meta http-equiv="refresh" ....
static ScriptableExtension * adapterFromLiveConnect(QObject *parentObj, LiveConnectExtension *oldApi)
KAnimationAdvice showAnimations() const
void enableAction(const char *name, bool enabled)
void paint(QPainter *, const QRect &, int=0, bool *=0)
Paints the HTML page to a QPainter.
KJSProxy * framejScript(KParts::ReadOnlyPart *framePart)
Returns child frame framePart its script interpreter.
bool m_metaRefreshEnabled
static void registerPart(KHTMLPart *part)
KIO::CacheControl m_cachePolicy
void removeStatusBarItem(QWidget *widget)
static void dumpFrameTree(KHTMLPart *part)
virtual void startingJob(KIO::Job *)
Hook for adding code before a job is started.
KHTMLPart::DNSPrefetch m_bDNSPrefetch
KAction * m_paFindAheadText
virtual void khtmlMousePressEvent(khtml::MousePressEvent *event)
Eventhandler of the khtml::MousePressEvent.
void canceled(const QString &errMsg)
QString selectedTextAsHTML() const
Return the text the user has marked.
long long numberValue(uint field, long long defaultValue=0) const
void setURLCursor(const QCursor &c)
Sets the cursor to use when the cursor is on a link.
bool metaRefreshEnabled() const
Returns true if automatic forwarding is enabled.
QStringList frameNames() const
Returns a list of names of all frame (including iframe) objects of the current document.
bool authorizeUrlAction(const QString &action, const KUrl &baseUrl, const KUrl &destUrl)
friend class KHTMLPopupGUIClient
void setCaretPosition(DOM::Node node, long offset, bool extendSelection=false)
Sets the caret to the given position.
void setWarnOnUnencrypted(bool x)
static BrowserExtension * childObject(QObject *obj)
bool pluginsEnabled() const
Returns true if plugins are enabled, false if disabled.
void setItems(const QStringList &lst)
static int s_DOMTreeIndentLevel
virtual ~KHTMLPart()
Destructor.
bool is(const QString &mimeTypeName) const
QString formatDateTime(const QDateTime &dateTime, DateFormat format=ShortDate, bool includeSecs=false) const
void preloadScript(const QString &url, const QString &script)
Loads a script into the script cache.
RangeImpl * handle() const
bool isOpenMiddleClickEnabled()
QString m_ssl_cipher_used_bits
KAction * m_paFindAheadLinks
bool m_bJScriptDebugEnabled
void setPass(const QString &pass)
KAction * clear(const QObject *recvr, const char *slot, QObject *parent)
void cancelFetch(QObject *recvObj)
Cancel sending data to recvObj.
KHTMLPart(QWidget *parentWidget=0, QObject *parent=0, GUIProfile prof=DefaultGUI)
Constructs a new KHTMLPart.
static KMimeTypeTrader * self()
QString m_statusBarText[3]
Node parentNode() const
The parent of this node.
This class implements the basic string we use in the DOM.
bool gotoAnchor(const QString &name)
Finds the anchor named name.
void setJavaEnabled(bool enable)
Enables/disables Java applet support.
KParts::PartManager * partManager()
Returns a reference to the partmanager instance which manages html frame objects. ...
The Document interface represents the entire HTML or XML document.
void setURL(const QString &url)
virtual bool doWriteStream(const QByteArray &data)
Implements the streaming API of KParts::ReadOnlyPart.
virtual void begin(const KUrl &url=KUrl(), int xOffset=0, int yOffset=0)
Clears the widget and prepares it for new content.
KHTMLPart * findFrame(const QString &f)
Finds a frame by name.
void setFixedFont(const QString &name)
Sets the fixed font style.
QString csqueeze(const QString &str, int maxlen=40)
void openUrlRequest(const KUrl &url, const KParts::OpenUrlArguments &arguments=KParts::OpenUrlArguments(), const KParts::BrowserArguments &browserArguments=KParts::BrowserArguments())
QList< KParts::ReadOnlyPart * > frames() const
DOMString nodeName() const
The name of this node, depending on its type; see the table above.
virtual void khtmlMouseMoveEvent(khtml::MouseMoveEvent *event)
Eventhandler for the khtml::MouseMouseMoveEvent.
QString referrer() const
Referrer used for links in this page.
const int KDE_NO_EXPORT fastZoomSizeCount
static const QString FormDataFolder()
void setFontScaleFactor(int percent)
Sets the scale factor to be applied to fonts.
virtual bool openFile()
Internal empty reimplementation of KParts::ReadOnlyPart::openFile .
NamedNodeMap attributes() const
A NamedNodeMap containing the attributes of this node (if it is an Element ) or null otherwise...
virtual void write(const char *str, int len=-1)
Writes another part of the HTML code to the widget.
const char * encoding() const
QString m_ssl_cipher_bits
void scheduleRedirection(int delay, const QString &url, bool lockHistory=true)
Schedules a redirection after delay seconds.
void cancelEntry(long id)
Cancel the entry.
const KShortcut & reload()
Node getNamedItem(const DOMString &name) const
Retrieves a node specified by name.
void setActiveNode(const DOM::Node &node)
Sets the focused node of the document to the specified node.
bool findTextNext(bool reverse=false)
Finds the next occurrence of a string set by findText()
QString jsDefaultStatusBarText() const
Called by KJS.
void infoMessage(const QString &)
virtual void guiActivateEvent(KParts::GUIActivateEvent *event)
Internal reimplementation of KParts::Part::guiActivateEvent .
bool prevAnchor()
Go to previous anchor.
void loadingProgress(int percent)
KAction * next(const QObject *recvr, const char *slot, QObject *parent)
virtual QString selectedText() const
Returns the text the user has marked.
DOM::Node activeNode() const
Returns the node that has the keyboard focus.
KJobUiDelegate * uiDelegate() const
virtual void timerEvent(QTimerEvent *)
virtual KParts::ReadOnlyPart * createPart(QWidget *parentWidget, QObject *parent, const QString &mimetype, QString &serviceName, QStringList &serviceTypes, const QStringList ¶ms)
This method is called when a new embedded object (include html frames) is to be created.
void setPluginPageQuestionAsked(const QString &mimetype)
void setFormNotification(FormNotification fn)
Determine if signal should be emitted before, instead or never when a submitForm() happens...
void setShortcut(const KShortcut &shortcut, ShortcutTypes type=ShortcutTypes(ActiveShortcut|DefaultShortcut))
static bool showIconsOnPushButtons()
QString documentSource() const
Returns the content of the source document.
void setStatusMessagesEnabled(bool enable)
Enable/disable statusbar messages.
void setStandardFont(const QString &name)
Sets the standard font style.
KXMLGUIFactory * factory() const
void setSuppressedPopupIndicator(bool enable, KHTMLPart *originPart=0)
Shows or hides the suppressed popup indicator.
void setForcesNewWindow(bool forcesNewWindow)
QString encoding() const
Returns the encoding the page currently uses.
static bool test(const QEvent *event)
static bool isJavaScriptURL(const QString &url)
BrowserArguments browserArguments() const
KHTMLPart * findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame=0)
Recursively finds the part containing the frame with name f and checks if it is accessible by calling...
void caretPositionChanged(const DOM::Node &node, long offset)
This signal is emitted whenever the caret position has been changed.
SimpleJob * http_update_cache(const KUrl &url, bool no_cache, time_t expireDate)
bool autoloadImages() const
Returns whether images contained in the document are loaded automatically or not. ...
virtual void setWidget(QWidget *widget)
FormNotification formNotification() const
Determine if signal should be emitted before, instead or never when a submitForm() happens...
KUrl backgroundURL() const
Returns the URL for the background Image (used by save background)
int lstat(const QString &path, KDE_struct_stat *buf)
virtual void addPart(Part *part, bool setActive=true)
void addStatusBarItem(QWidget *widget, int stretch, bool permanent)
QWeakPointer< KParts::BrowserExtension > m_extension
bool isPluginsEnabled(const QString &hostname=QString()) const
bool hasSelection() const
Has the user selected anything?
QPointer< KParts::ReadOnlyPart > m_part
virtual bool openUrl(const KUrl &url)
Opens the specified URL url.
QWeakPointer< KParts::ScriptableExtension > m_scriptable
bool m_bDNSPrefetchIsDefault
virtual void insert(const QString &item)
void preloadStyleSheet(const QString &url, const QString &stylesheet)
Loads a style sheet into the stylesheet cache.
KPluginFactory * factory()
Introduced in DOM Level 2.
bool m_redirectLockHistory
KUrl toplevelURL()
Returns the toplevel (origin) URL of this document, even if this part is a frame or an iframe...
bool setEncoding(const char *encoding, EncodingChoiceSource type)
This library provides a full-featured HTML parser and widget.
DOM::Node nonSharedNodeUnderMouse() const
Returns the Node currently under the mouse that is not shared.
void submitFormProxy(const char *action, const QString &url, const QByteArray &formData, const QString &target, const QString &contentType=QString(), const QString &boundary=QString())
long endOffset() const
Offset within the ending node of the range.
Result askEmbedOrSave(int flags=0)
friend class KHTMLPartPrivate
void setArguments(const OpenUrlArguments &arguments)
void setFileName(const QString &_txt)
void setJScriptEnabled(bool enable)
Enable/disable Javascript support.
void configurationChanged()
Emitted whenever the configuration has changed.
bool isJavaScriptDebugEnabled(const QString &hostname=QString()) const
static bool runUrl(const KUrl &url, const QString &mimetype, QWidget *window, bool tempFile=false, bool runExecutables=true, const QString &suggestedFileName=QString(), const QByteArray &asn=QByteArray())
void setDNDEnabled(bool b)
Enables or disables Drag'n'Drop support.
DOM::Document document() const
Returns a reference to the DOM document.
int m_numDNSPrefetchedNames
TransferJob * http_post(const KUrl &url, const QByteArray &postData, JobFlags flags=DefaultFlags)
static void setCaretInvisibleIfNeeded(KHTMLPart *part)
KDNSPrefetch dnsPrefetch() const
void setDNSPrefetch(DNSPrefetch pmode)
Sets whether DNS Names found in loaded documents'anchors should be pre-fetched (pre-resolved).
bool setCurrentAutoDetectScript(KEncodingDetector::AutoDetectScript)
QPointer< khtml::ChildFrame > m_frame
KStatusBar * statusBar() const
void setAlwaysHonourDoctype(bool b=true)
Sets whether the document's Doctype should always be used to determine the parsing mode for the docum...
virtual void khtmlMouseDoubleClickEvent(khtml::MouseDoubleClickEvent *)
Eventhandler for the khtml::MouseDoubleClickEvent.
virtual void showErrorMessage()
void setCaretDisplayPolicyNonFocused(CaretDisplayPolicy policy)
Sets the caret display policy when the view is not focused.
T readEntry(const QString &key, const T &aDefault) const
void findText()
Starts a new search by popping up a dialog asking the user what he wants to search for...
KAction * m_paSaveDocument
QCursor urlCursor() const
Returns the cursor which is used when the cursor is on a link.
void setMimeType(const QString &mime)
static QString defaultMimeType()
long options() const
Returns the state of the options.
virtual QString errorString() const
static Ptr findByUrl(const KUrl &url, mode_t mode=0, bool is_local_file=false, bool fast_mode=false, int *accuracy=0)
void setHost(ScriptableExtension *host)
KJS::KHTMLPartScriptable * m_scriptableExtension
bool isLocalAnchorJump(const KUrl &url)
KUrlLabel * m_statusBarPopupLabel
long createCacheEntry()
Create a new cache entry.
static const int sDNSCacheSize
void setHelpText(const QString &text)
virtual void end()
Call this after your last call to write().
long startOffset() const
Offset within the starting node of the range.
KAction * zoomIn(const QObject *recvr, const char *slot, QObject *parent)
const KHTMLSettings * settings() const
QVariant executeScript(const DOM::Node &n, const QString &script)
Same as executeScript( const QString & ) except with the Node parameter specifying the 'this' value...
QString m_ssl_parent_cert
bool statusMessagesEnabled() const
Returns true if status messages are enabled.
QString queryItem(const QString &item) const
virtual bool closeUrl()
Stops loading the document and kills all data requests (for images, etc.)
KAction * m_paDebugDOMTree
void setUseCursor(bool on, QCursor *cursor=0L)
bool m_statusMessagesEnabled
QPixmap SmallIcon(const QString &name, int force_size, int state, const QStringList &overlays)
NodeImpl * handle() const
Node nextSibling() const
The node immediately following this node.
bool jScriptEnabled() const
Returns true if Javascript support is enabled or false otherwise.
QString jsStatusBarText() const
Called by KJS.
KHTMLSettings * m_settings
static bool keyDoesNotExist(const QString &wallet, const QString &folder, const QString &key)
static StatusBarExtension * childObject(QObject *obj)
static const QString NetworkWallet()
Node firstChild() const
The first child of this node.
QWeakPointer< DOM::HTMLPartContainerElementImpl > m_partContainerElement
bool isNull() const
tests if this Node is 0.
bool onlyLocalReferences() const
Returns whether only file:/ or data:/ references are allowed to be loaded ( default false )...
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
void setEditable(bool enable)
Makes the document editable.
bool isAdFiltered(const QString &url) const
tests whether url is filtered.
void setForcePermitLocalImages(bool enable)
Security option.
bool isEditable() const
Returns true if the document is editable, false otherwise.
bool mayPrefetchHostname(const QString &name)
Will pre-resolve name according to dnsPrefetch current settings Returns true if the name will be pre-...
virtual KActionCollection * actionCollection() const
bool warnOnUnencrypted() const
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
void executeJavascriptURL(const QString &u)
void setZoomFactor(int percent)
Sets the Zoom factor.
void setAutoloadImages(bool enable)
Specifies whether images contained in the document should be loaded automatically or not...
void show()
Convenience method to show the document's view.
static Ptr mimeType(const QString &name, FindByNameOption options=ResolveAliases)
void saveData(long id, QDataStream *str)
Save the data of cache entry id to the datastream str.
void init()
Called by constructor and reparseConfiguration.
virtual void showError(KJob *job)
Called when a certain error situation (i.e.
KJS::Interpreter * jScriptInterpreter()
Returns the JavaScript interpreter the part is using.
virtual void setComponentData(const KComponentData &componentData)
QPointer< KHTMLViewBar > m_bottomViewBar
void setContentType(const QString &contentType)
static const int sMaxDNSPrefetchPerPage
QString pageReferrer() const
Referrer used to obtain this page.
void popupMenu(const QString &url, const QPoint &point)
Emitted when the user clicks the right mouse button on the document.
QByteArray rawErrorDetail(int errorCode, const QString &errorText, const KUrl *reqUrl=0L, int method=-1)
void stopAnimations()
Stops all animated images on the current and child pages.
void insertChildClient(KXMLGUIClient *child)
const QString & encoding() const
void setLowerWindow(bool lower)
void prefetchHost(const QString &hostName)
void selectAll()
Marks all text in the document as selected.
QString errorText() const
void nodeActivated(const DOM::Node &)
This signal is emitted when an element retrieves the keyboard focus.
void propagateInitialDomainAndBaseTo(KHTMLPart *kid)
QSet< QString > m_lookedupHosts
CaretDisplayPolicy
Enumeration for displaying the caret.
virtual bool doCloseStream()
Implements the streaming API of KParts::ReadOnlyPart.
static bool test(const QEvent *event)
void setLocationBarUrl(const QString &url)
static KIO::CacheControl cacheControl()
bool m_restoreScrollPosition
void clearTypingStyle()
Clears the typing style for the document.
QTimer m_progressUpdateTimer
QString convertSize(KIO::filesize_t size)
void setPageSecurity(int)
JobUiDelegate * ui() const
static bool download(const KUrl &src, QString &target, QWidget *window)
DOM::Node m_mousePressNode
void htmlError(int errorCode, const QString &text, const KUrl &reqUrl)
presents a detailed error message to the user.
static KParts::HistoryProvider * vLinks()
void addData(long id, const QByteArray &data)
Add data to the cache entry with id id.
bool forcePermitLocalImages() const
If true, local image files will be loaded even when forbidden by the Kiosk/KAuthorized policies ( def...
static bool test(const QEvent *event)
static LiveConnectExtension * childObject(QObject *obj)
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
void setSslInfo(const QList< QSslCertificate > &certificateChain, const QString &ip, const QString &host, const QString &sslProtocol, const QString &cipher, int usedBits, int bits, const QList< QList< KSslError::Error > > &validationErrors)
static int dndEventDelay()
QString encodedHtmlRef() const
void setJSDefaultStatusBarText(const QString &text)
Called by KJS.
DOM::Range selection() const
Returns the selected part of the HTML.
KAction * m_paDebugScript
static int warningContinueCancel(QWidget *parent, const QString &text, const QString &caption=QString(), const KGuiItem &buttonContinue=KStandardGuiItem::cont(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
static QDebug kFatal(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
static void manage(QWidget *widget, bool programmers_mode=false)
void unplugActionList(const QString &name)
static KUrl join(const List &_list)
void renameFrameForContainer(DOM::HTMLPartContainerElementImpl *cont, const QString &newName)
QString path(AdjustPathOption trailing=LeaveTrailingSlash) const
static const int zoomSizes[]
unsigned long m_loadedObjects
quint32 elementId() const
static void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
void setStatusBar(KStatusBar *status)
void endData(long id)
Signal end of data for the cache entry with id id.
KHTMLPart * parentPart()
Returns a pointer to the parent KHTMLPart if the part is a frame in an HTML frameset.
bool m_bRightMousePressed
QString m_ssl_protocol_version
OpenUrlArguments arguments() const
unsigned short nodeType() const
A code representing the type of the underlying object, as defined above.
DNSPrefetch
DNS Prefetching Mode enumeration.
DOMString nodeValue() const
The value of this node, depending on its type; see the table above.
bool autoLoadImages() const