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"))
633 DOM::HashChangeEventImpl *hashChangeEvImpl = 0;
634 const QString &oldRef = q->url().ref();
635 const QString &newRef = url.
ref();
636 const bool hashChanged = (oldRef != newRef) || (oldRef.isNull() && newRef.isEmpty());
642 emit m_extension->openUrlNotify();
645 hashChangeEvImpl =
new DOM::HashChangeEventImpl();
646 hashChangeEvImpl->initHashChangeEvent(
"hashchange",
654 if (!q->gotoAnchor(newRef))
658 emit m_extension->setLocationBarUrl( url.
prettyUrl() );
660 if (hashChangeEvImpl) {
661 m_doc->dispatchWindowEvent(hashChangeEvImpl);
667 kDebug( 6050 ) <<
this <<
"opening" <<
url;
668 #ifndef KHTML_NO_WALLET 695 if ( !urls.isEmpty() ) {
696 const KUrl mainURL = urls.first();
697 int error = mainURL.
queryItem(
"error" ).toInt();
700 const QString errorText = mainURL.
queryItem(
"errText" );
711 QString host = url.
isLocalFile() ?
"localhost" : url.host();
716 d->
m_statusBarUALabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum));
740 bool isFrameSet =
false;
741 if ( d->
m_doc && d->
m_doc->isHTMLDocument() ) {
742 HTMLDocumentImpl* htmlDoc =
static_cast<HTMLDocumentImpl*
>(d->
m_doc);
743 isFrameSet = htmlDoc->body() && (htmlDoc->body()->id() == ID_FRAMESET);
750 for (; it !=
end; ++it) {
765 if ( url.
hasRef() && !isFrameSet )
767 bool noReloadForced = !args.reload() && !browserArgs.redirectedRequest() && !browserArgs.doPost();
770 kDebug( 6050 ) <<
"jumping to anchor. m_url = " <<
url;
779 d->
m_doc->setParsing(
false);
781 kDebug( 6050 ) <<
"completed...";
790 args.setXOffset( d->
m_view->contentsX() );
791 args.setYOffset( d->
m_view->contentsY() );
799 disconnect(d->
m_view, SIGNAL(finishedLayout()),
this, SLOT(restoreScrollPosition()));
800 connect(d->
m_view, SIGNAL(finishedLayout()),
this, SLOT(restoreScrollPosition()));
811 begin(url, args.xOffset(), args.yOffset());
812 write(QString::fromLatin1(
"<html><head></head><body>"));
814 write(QString::fromLatin1(
"<img "));
816 write(QString::fromLatin1(
"<embed "));
817 write(QString::fromLatin1(
"src=\""));
822 write(QString::fromLatin1(
"\">"));
831 if(url.
protocol().startsWith(
"http" ) && !url.host().isEmpty() &&
832 url.
path().isEmpty()) {
839 metaData.insert(
"main_frame_request",
parentPart() == 0 ?
"TRUE" :
"FALSE" );
842 metaData.insert(
"PropagateHttpHeader",
"true");
843 metaData.insert(
"ssl_was_in_use", d->
m_ssl_in_use ?
"TRUE" :
"FALSE" );
844 metaData.insert(
"ssl_activate_warnings",
"TRUE" );
852 else if (args.reload() && !browserArgs.softReload)
857 if ( browserArgs.doPost() && (url.
protocol().startsWith(
"http")) )
872 connect( d->
m_job, SIGNAL(result(
KJob*)),
875 SLOT(slotData(
KIO::Job*,QByteArray)) );
876 connect ( d->
m_job, SIGNAL(infoMessage(
KJob*,QString,QString)),
877 SLOT(slotInfoMessage(
KJob*,QString)) );
897 connect( d->
m_job, SIGNAL(speed(
KJob*,ulong)),
898 this, SLOT(slotJobSpeed(
KJob*,ulong)) );
900 connect( d->
m_job, SIGNAL(percent(
KJob*,ulong)),
901 this, SLOT(slotJobPercent(
KJob*,ulong)) );
903 connect( d->
m_job, SIGNAL(result(
KJob*)),
904 this, SLOT(slotJobDone(
KJob*)) );
913 connect( job, SIGNAL(result(
KJob*)),
914 this, SLOT(slotUserSheetStatDone(
KJob*)) );
931 if ( d->
m_doc && d->
m_doc->isHTMLDocument() ) {
932 HTMLDocumentImpl* hdoc =
static_cast<HTMLDocumentImpl*
>( d->
m_doc );
935 hdoc->body()->dispatchWindowEvent( EventImpl::UNLOAD_EVENT,
false,
false );
937 d->
m_doc->updateRendering();
946 disconnect(d->
m_view, SIGNAL(finishedLayout()),
this, SLOT(restoreScrollPosition()));
951 kDebug( 6050 ) <<
" was still parsing... calling end ";
952 slotFinishedParsing();
953 d->
m_doc->setParsing(
false);
959 kDebug( 6050 ) <<
"Aborted before starting to render, reverting location bar to " <<
url().
prettyUrl();
966 khtml::Cache::loader()->cancelRequests( d->
m_doc->docLoader() );
972 for (; it !=
end; ++it )
975 (*it)->m_run.data()->abort();
976 if ( !( *it )->m_part.isNull() )
977 ( *it )->m_part.data()->closeUrl();
984 for (; it !=
end; ++it)
986 if ( !( *it )->m_part.isNull() )
987 ( *it )->m_part.data()->closeUrl();
999 d->
m_view->closeChildDialogs();
1007 return static_cast<HTMLDocumentImpl*>(d->
m_doc);
1009 return static_cast<HTMLDocumentImpl*
>(0);
1022 QByteArray sourceArray;
1023 QDataStream dataStream( &sourceArray, QIODevice::WriteOnly );
1025 QTextStream stream( sourceArray, QIODevice::ReadOnly );
1026 stream.setCodec( QTextCodec::codecForName(
encoding().toLatin1().constData() ) );
1027 sourceStr = stream.readAll();
1034 if ( f.open( QIODevice::ReadOnly ) )
1036 QTextStream stream( &f );
1037 stream.setCodec( QTextCodec::codecForName(
encoding().toLatin1().constData() ) );
1038 sourceStr = stream.readAll();
1066 if (const_cast<KHTMLPart*>(
this)->
parentPart())
1073 if (const_cast<KHTMLPart*>(
this)->
parentPart())
1086 if (!proxy || proxy->paused())
1089 return proxy->interpreter();
1100 d->
m_frame->m_jscript->clear();
1150 for (; it !=
end; ++it)
1151 if ((*it)->m_part.data() ==
this) {
1166 QVariant KHTMLPart::crossFrameExecuteScript(
const QString& target,
const QString& script)
1170 QString trg = target.toLower();
1172 if (target ==
"_top") {
1176 else if (target ==
"_parent") {
1180 else if (target ==
"_self" || target ==
"_blank") {
1190 if (destpart ==
this)
1194 if (destpart->checkFrameAccess(
this))
1227 d->
m_jsedlg->_clear->setIcon(
KIcon(
"edit-clear-locationbar-ltr"));
1234 void KHTMLPart::removeJSErrorExtension() {
1248 void KHTMLPart::disableJSErrorExtension() {
1249 removeJSErrorExtension();
1258 void KHTMLPart::jsErrorDialogContextMenu() {
1260 m->addAction(
i18n(
"&Hide Errors"),
this, SLOT(removeJSErrorExtension()));
1261 m->addAction(
i18n(
"&Disable Error Reporting"),
this, SLOT(disableJSErrorExtension()));
1262 m->popup(QCursor::pos());
1265 void KHTMLPart::launchJSErrorDialog() {
1273 void KHTMLPart::launchJSConfigDialog() {
1275 args <<
"khtml_java_js";
1283 kDebug(6070) <<
"executeScript: caller='" << objectName() <<
"' filename=" << filename <<
" baseLine=" << baseLine ;
1287 if (!proxy || proxy->paused())
1290 KJS::Completion comp;
1291 QVariant ret = proxy->evaluate(filename, baseLine, script, n, &comp);
1296 if (comp.complType() == KJS::Throw && comp.value()) {
1299 QString msg = KJSDebugger::DebugWindow::exceptionToString(
1300 proxy->interpreter()->globalExec(), comp.value());
1302 Qt::escape(filename), Qt::escape(msg)));
1309 kDebug(6070) <<
"executeScript done, handling immediate redirection NOW";
1311 khtml::Tokenizer* t = d->
m_doc->tokenizer();
1333 if (!proxy || proxy->paused())
1337 KJS::Completion comp;
1338 const QVariant ret = proxy->evaluate( QString(), 1, script, n, &comp );
1344 if (comp.complType() == KJS::Throw && comp.value()) {
1347 QString msg = KJSDebugger::DebugWindow::exceptionToString(
1348 proxy->interpreter()->globalExec(), comp.value());
1349 dlg->
addError(
i18n(
"<qt><b>Error</b>: node %1: %2</qt>",
1399 void KHTMLPart::slotDebugDOMTree()
1402 qDebug(
"%s", d->
m_doc->toString().string().toLatin1().constData());
1410 for (; it !=
end; ++it )
1411 if ( !( *it )->m_part.isNull() && (*it)->m_part.data()->inherits(
"KHTMLPart" ) ) {
1414 static_cast<KHTMLPart*
>( p )->slotDebugDOMTree();
1419 void KHTMLPart::slotDebugScript()
1422 jScript()->showDebugWindow();
1425 void KHTMLPart::slotDebugRenderTree()
1429 d->
m_doc->renderer()->printTree();
1440 void KHTMLPart::slotDebugFrameTree()
1445 void KHTMLPart::slotStopAnimations()
1452 if ( d->
m_doc && d->
m_doc->docLoader()->autoloadImages() == enable )
1456 d->
m_doc->docLoader()->setAutoloadImages( enable );
1468 connect( d->
m_paLoadImages, SIGNAL(triggered(
bool)),
this, SLOT(slotLoadImages()) );
1481 return d->
m_doc->docLoader()->autoloadImages();
1486 void KHTMLPart::clear()
1498 for(; it !=
end; ++it )
1502 (*it)->m_run.data()->abort();
1509 for(; it !=
end; ++it )
1513 (*it)->m_run.data()->abort();
1524 if (d->
m_doc->attached())
1530 d->
m_frame->m_jscript->clear();
1533 if (d->
m_doc && d->
m_doc->renderer() && d->
m_doc->renderer()->layer())
1534 d->
m_doc->renderer()->layer()->suspendMarquees();
1561 for(; it !=
end; ++it )
1563 if ( (*it)->m_part )
1566 delete (*it)->m_part.data();
1580 for (; oi != oiEnd; ++oi )
1582 delete (*oi)->m_part.data();
1604 #ifndef QT_NO_CLIPBOARD 1605 connect( qApp->clipboard(), SIGNAL(
selectionChanged()), SLOT(slotClearSelection()));
1633 DOM::HTMLDocumentImpl *KHTMLPart::docImpl()
const 1635 if ( d && d->
m_doc && d->
m_doc->isHTMLDocument() )
1636 return static_cast<HTMLDocumentImpl*>(d->
m_doc);
1640 DOM::DocumentImpl *KHTMLPart::xmlDocImpl()
const 1647 void KHTMLPart::slotInfoMessage(
KJob* kio_job,
const QString& msg)
1654 setStatusBarText(msg, BarDefaultText);
1662 void KHTMLPart::slotData(
KIO::Job* kio_job,
const QByteArray &data )
1698 d->
m_doc->docLoader()->setCacheCreationDate(cacheCreationDate);
1734 if( !qData.isEmpty())
1735 d->
m_doc->processHttpEquiv(
"refresh", qData);
1747 if (!language.isEmpty())
1748 d->
m_doc->setContentLanguage(language);
1750 if ( !
url().isLocalFile() )
1760 write( data.data(), data.size() );
1763 void KHTMLPart::slotRestoreData(
const QByteArray &data )
1779 write( data.data(), data.size() );
1781 if (data.size() == 0)
1809 kDebug(6050) <<
"errorCode" << errorCode <<
"text" << text;
1817 QString errorName, techName, description;
1818 QStringList causes, solutions;
1821 QDataStream stream(raw);
1823 stream >> errorName >> techName >> description >> causes >> solutions;
1825 QString
url, protocol, datetime;
1829 url = Qt::escape( Qt::escape( reqUrl.
prettyUrl() ) );
1835 QFile file( filename );
1836 bool isOpened = file.open( QIODevice::ReadOnly );
1838 kWarning(6050) <<
"Could not open error html template:" << filename;
1840 QString html = QString( QLatin1String( file.readAll() ) );
1842 html.replace( QLatin1String(
"TITLE" ),
i18n(
"Error: %1 - %2", errorName, url ) );
1843 html.replace( QLatin1String(
"DIRECTION" ), QApplication::isRightToLeft() ?
"rtl" :
"ltr" );
1846 QString doc = QLatin1String(
"<h1>" );
1847 doc +=
i18n(
"The requested operation could not be completed" );
1848 doc += QLatin1String(
"</h1><h2>" );
1850 doc += QLatin1String(
"</h2>" );
1851 if ( !techName.isNull() ) {
1852 doc += QLatin1String(
"<h2>" );
1853 doc +=
i18n(
"Technical Reason: " );
1855 doc += QLatin1String(
"</h2>" );
1857 doc += QLatin1String(
"<br clear=\"all\">" );
1858 doc += QLatin1String(
"<h3>" );
1859 doc +=
i18n(
"Details of the Request:" );
1860 doc += QLatin1String(
"</h3><ul><li>" );
1861 doc +=
i18n(
"URL: %1" , url );
1862 doc += QLatin1String(
"</li><li>" );
1863 if ( !protocol.isNull() ) {
1864 doc +=
i18n(
"Protocol: %1", protocol );
1865 doc += QLatin1String(
"</li><li>" );
1867 doc +=
i18n(
"Date and Time: %1" , datetime );
1868 doc += QLatin1String(
"</li><li>" );
1869 doc +=
i18n(
"Additional Information: %1" , text );
1870 doc += QLatin1String(
"</li></ul><h3>" );
1871 doc +=
i18n(
"Description:" );
1872 doc += QLatin1String(
"</h3><p>" );
1874 doc += QLatin1String(
"</p>" );
1875 if ( causes.count() ) {
1876 doc += QLatin1String(
"<h3>" );
1877 doc +=
i18n(
"Possible Causes:" );
1878 doc += QLatin1String(
"</h3><ul><li>" );
1879 doc += causes.join(
"</li><li>" );
1880 doc += QLatin1String(
"</li></ul>" );
1882 if ( solutions.count() ) {
1883 doc += QLatin1String(
"<h3>" );
1884 doc +=
i18n(
"Possible Solutions:" );
1885 doc += QLatin1String(
"</h3><ul><li>" );
1886 doc += solutions.join(
"</li><li>" );
1887 doc += QLatin1String(
"</li></ul>" );
1890 html.replace( QLatin1String(
"TEXT"), doc );
1938 HTMLPartContainerElementImpl *elt = d->
m_frame ?
1939 d->
m_frame->m_partContainerElement.data() : 0;
1944 elt->partLoadingErrorNotify();
1965 if (mimeStr ==
"application/xhtml+xml")
1967 if (mimeStr ==
"image/svg+xml")
1969 if (mimeStr ==
"text/html" || mimeStr.isEmpty())
1973 if ((mime && mime->
is(
"text/xml")) || mimeStr.endsWith(
"+xml"))
1976 if (mime && mime->
is(
"text/plain"))
1979 if (khtmlImLoad::ImageManager::loaderDatabase()->supportedMimeTypes().contains(mimeStr))
1995 if ( d->
m_view->underMouse() )
1996 QToolTip::hideText();
2000 removeJSErrorExtension();
2005 KJS::Window *w = KJS::Window::retrieveWindow( part );
2007 w->forgetSuppressedWindows();
2020 QString urlString = url.
url();
2023 if ( urlString != urlString2 ) {
2047 d->
m_doc = DOMImplementationImpl::createSVGDocument( d->
m_view );
2051 d->
m_doc = DOMImplementationImpl::createXMLDocument( d->
m_view );
2059 d->
m_doc = DOMImplementationImpl::createHTMLDocument( d->
m_view );
2061 static_cast<HTMLDocumentImpl *
>(d->
m_doc)->setHTMLRequested( type !=
MimeXHTML );
2067 if (!d->
m_doc->attached())
2068 d->
m_doc->attach( );
2078 if ( !userStyleSheet.isEmpty() )
2082 connect(d->
m_doc,SIGNAL(finishedParsing()),
this,SLOT(slotFinishedParsing()));
2086 d->
m_doc->setParsing(
true);
2095 len = strlen( data );
2102 if(decoded.isEmpty())
2108 khtml::Tokenizer* t = d->
m_doc->tokenizer();
2110 t->write( decoded,
true );
2127 d->
m_doc->setParseMode( DocumentImpl::Strict );
2133 khtml::Tokenizer* t = d->
m_doc->tokenizer();
2135 t->write( str,
true );
2146 if (!decoded.isEmpty())
2149 d->
m_doc->finishParsing();
2153 void KHTMLPart::onFirstData()
2158 d->
m_doc->determineParseMode();
2164 d->
m_doc->setVisuallyOrdered();
2167 d->
m_doc->recalcStyle( NodeImpl::Force );
2173 if ( mime && ( mime->
is(
"text/html" ) || mime->
is(
"text/xml" ) ) )
2183 write( data.data(), data.size() );
2197 d->
m_view->paint(p, rc, yOff, more);
2207 for (; it !=
end; ++it ) {
2208 if (
KHTMLPart* p = qobject_cast<KHTMLPart*>((*it)->m_part.data()) )
2209 p->stopAnimations();
2213 void KHTMLPart::resetFromScript()
2218 disconnect(d->
m_doc,SIGNAL(finishedParsing()),
this,SLOT(slotFinishedParsing()));
2219 connect(d->
m_doc,SIGNAL(finishedParsing()),
this,SLOT(slotFinishedParsing()));
2220 d->
m_doc->setParsing(
true);
2225 void KHTMLPart::slotFinishedParsing()
2227 d->
m_doc->setParsing(
false);
2228 d->
m_doc->dispatchHTMLEvent(EventImpl::KHTML_CONTENTLOADED_EVENT,
true,
false);
2229 checkEmitLoadEvent();
2230 disconnect(d->
m_doc,SIGNAL(finishedParsing()),
this,SLOT(slotFinishedParsing()));
2238 void KHTMLPart::slotLoaderRequestStarted( khtml::DocLoader* dl, khtml::CachedObject *obj )
2240 if ( obj && obj->type() == khtml::CachedObject::Image && d->
m_doc && d->
m_doc->docLoader() == dl ) {
2265 void KHTMLPart::slotLoaderRequestDone( khtml::DocLoader* dl, khtml::CachedObject *obj )
2267 if ( obj && obj->type() == khtml::CachedObject::Image && d->
m_doc && d->
m_doc->docLoader() == dl ) {
2287 void KHTMLPart::slotProgressUpdate()
2308 void KHTMLPart::slotJobSpeed(
KJob* ,
unsigned long speed )
2315 void KHTMLPart::slotJobPercent(
KJob* ,
unsigned long percent )
2325 void KHTMLPart::slotJobDone(
KJob* )
2335 void KHTMLPart::slotUserSheetStatDone(
KJob *_job )
2337 using namespace KIO;
2339 if ( _job->
error() ) {
2349 if ( lastModified != static_cast<time_t>(-1) ) {
2350 if (
d->m_userStyleSheetLastModified >= lastModified ) {
2361 *pendingRedirections =
false;
2366 for (; it !=
end; ++it ) {
2367 if ( !(*it)->m_bCompleted || (*it)->m_run )
2373 if ( (*it)->m_bPendingRedirection )
2374 *pendingRedirections =
true;
2382 for (; oi != oiEnd; ++oi )
2383 if ( !(*oi)->m_bCompleted )
2388 if ( m_doc && m_doc->parsing() )
2393 if ( m_doc && m_doc->docLoader() )
2394 requests = khtml::Cache::loader()->numRequests( m_doc->docLoader() );
2405 void KHTMLPart::checkCompleted()
2412 if (
d->m_doc && !
d->m_doc->parsing() && !
d->m_focusNodeRestored)
2414 if (
d->m_focusNodeNumber >= 0)
2415 d->m_doc->setFocusNode(
d->m_doc->nodeWithAbsIndex(
d->m_focusNodeNumber));
2417 d->m_focusNodeRestored =
true;
2420 bool fullyLoaded, pendingChildRedirections;
2421 fullyLoaded =
d->isFullyLoaded(&pendingChildRedirections);
2424 if (!fullyLoaded ||
d->m_bComplete)
2429 d->m_bComplete =
true;
2431 d->m_totalObjectCount = 0;
2432 d->m_loadedObjects = 0;
2444 checkEmitLoadEvent();
2446 bool pendingAction =
false;
2448 if ( !
d->m_redirectURL.isEmpty() )
2454 d->m_redirectionTimer.setSingleShot(
true );
2455 d->m_redirectionTimer.start( qMax(0, 1000 *
d->m_delayRedirect) );
2460 pendingAction =
true;
2462 else if ( pendingChildRedirections )
2464 pendingAction =
true;
2471 d->m_view->complete( pendingAction );
2476 sheets =
d->m_doc->availableStyleSheets();
2477 sheets.prepend(
i18n(
"Automatic Detection" ) );
2478 d->m_paUseStylesheet->setItems( sheets );
2480 d->m_paUseStylesheet->setEnabled( sheets.count() > 2);
2481 if (sheets.count() > 2)
2483 d->m_paUseStylesheet->setCurrentItem(qMax(sheets.indexOf(
d->m_sheetUsed), 0));
2484 slotUseStylesheet();
2491 kDebug(6080) <<
"DONE:" <<
d->m_parsetime.elapsed();
2495 void KHTMLPart::checkEmitLoadEvent()
2497 bool fullyLoaded, pendingChildRedirections;
2498 fullyLoaded =
d->isFullyLoaded(&pendingChildRedirections);
2501 if (
d->m_bLoadEventEmitted || !
d->m_doc || !fullyLoaded )
return;
2503 d->m_bLoadEventEmitted =
true;
2510 return d->m_settings;
2513 #ifndef KDE_NO_COMPAT // KDE5: remove this ifndef, keep the method (renamed to baseUrl) 2516 if ( !
d->m_doc )
return KUrl();
2518 return d->m_doc->baseURL();
2524 if ( !
d->m_doc )
return KUrl( url );
2528 return KUrl(
d->m_doc->completeURL(url),
d->m_decoder->codec()->mibEnum());
2531 return KUrl(
d->m_doc->completeURL( url ) );
2536 return KUrl::fromPercentEncoding( u.right( u.length() - 11 ).toUtf8() );
2541 QString script = codeForJavaScriptURL(u);
2542 kDebug( 6050 ) <<
"script=" << script;
2543 QVariant res = q->executeScript(
DOM::Node(), script );
2545 q->begin( q->url() );
2546 q->setAlwaysHonourDoctype();
2547 q->write( res.toString() );
2550 emit q->completed();
2555 return url.indexOf( QLatin1String(
"javascript:" ), 0, Qt::CaseInsensitive ) == 0;
2562 kDebug(6050) <<
"delay=" << delay <<
" url=" << url <<
" from=" << this->
url() <<
"parent=" <<
parentPart();
2563 kDebug(6050) <<
"current redirectURL=" <<
d->m_redirectURL <<
" with delay " <<
d->m_delayRedirect;
2568 if ( delay == -1 &&
d->isInPageURL(url) ) {
2569 d->executeInPageURL(url, doLockHistory);
2573 if( delay < 24*60*60 &&
2574 (
d->m_redirectURL.isEmpty() || delay <=
d->m_delayRedirect) ) {
2575 d->m_delayRedirect = delay;
2576 d->m_redirectURL =
url;
2577 d->m_redirectLockHistory = doLockHistory;
2578 kDebug(6050) <<
" d->m_bComplete=" <<
d->m_bComplete;
2580 if (
d->m_bComplete ) {
2581 d->m_redirectionTimer.stop();
2582 d->m_redirectionTimer.setSingleShot(
true );
2583 d->m_redirectionTimer.start( qMax(0, 1000 *
d->m_delayRedirect) );
2590 m_delayRedirect = 0;
2591 m_redirectURL.clear();
2592 m_redirectionTimer.stop();
2595 void KHTMLPart::slotRedirect()
2598 QString u =
d->m_redirectURL;
2600 d->clearRedirection();
2602 if (
d->isInPageURL(u) )
2604 d->executeInPageURL(u,
d->m_redirectLockHistory);
2612 if ( openedByJS() &&
d->m_opener )
2613 cUrl =
d->m_opener->url();
2617 kWarning(6050) <<
"KHTMLPart::scheduleRedirection: Redirection from " << cUrl <<
" to " << url <<
" REJECTED!";
2622 if ( url.
equals(this->url(),
2625 args.
metaData().insert(
"referrer",
d->m_pageReferrer);
2640 if ( !
urlSelected( u, 0, 0,
"_self", args, browserArgs ) ) {
2646 void KHTMLPart::slotRedirection(
KIO::Job*,
const KUrl& url)
2650 emit
d->m_extension->setLocationBarUrl( url.
prettyUrl() );
2651 d->m_workingURL =
url;
2656 d->m_encoding = name;
2657 d->m_haveEncoding =
override;
2659 if( !
url().isEmpty() ) {
2664 d->m_restored =
true;
2666 d->m_restored =
false;
2674 if(
d->m_haveEncoding && !
d->m_encoding.isEmpty())
2675 return d->m_encoding;
2677 if(
d->m_decoder &&
d->m_decoder->encoding())
2678 return QString(
d->m_decoder->encoding());
2680 return defaultEncoding();
2683 QString KHTMLPart::defaultEncoding()
const 2686 if ( !encoding.isEmpty() )
2691 return "iso-8859-1";
2698 if (
d->m_doc &&
d->m_doc->docLoader() )
2699 (
void)
new khtml::PartStyleSheetLoader(
this, url.
url(),
d->m_doc->docLoader());
2705 d->m_doc->setUserStyleSheet( styleSheet );
2713 HTMLCollectionImpl *anchors =
new HTMLCollectionImpl(
d->m_doc, HTMLCollectionImpl::DOC_ANCHORS);
2715 NodeImpl *n = anchors->namedItem(name);
2719 n =
d->m_doc->getElementById( name );
2722 d->m_doc->setCSSTarget(n);
2725 bool top = !n && (name.isEmpty() || name.toLower() ==
"top");
2728 d->m_view->setContentsPos(
d->m_view->contentsX(), 0);
2731 kDebug(6050) << name <<
"not found";
2737 HTMLElementImpl *a =
static_cast<HTMLElementImpl *
>(n);
2739 a->getUpperLeftCorner(x, y);
2740 if (x <= d->m_view->contentsX())
2743 gox =
d->m_view->contentsX();
2744 if ( x + 10 >
d->m_view->contentsX()+
d->m_view->visibleWidth()) {
2745 a->getLowerRightCorner(x, dummy);
2746 gox = x -
d->m_view->visibleWidth() + 10;
2750 d->m_view->setContentsPos(gox, y);
2759 d->m_view->focusNextPrevNode (
true );
2768 d->m_view->focusNextPrevNode (
false );
2775 d->m_settings->setStdFontName(name);
2780 d->m_settings->setFixedFontName(name);
2785 d->m_linkCursor = c;
2790 return d->m_linkCursor;
2795 return d->m_onlyLocalReferences;
2800 d->m_onlyLocalReferences = enable;
2805 return d->m_forcePermitLocalImages;
2810 d->m_forcePermitLocalImages = enable;
2817 this->*flag = value;
2823 for (; it != itEnd; ++it) {
2833 for (; it != itEnd; ++it) {
2841 void KHTMLPart::initCaret()
2844 if (
d->editor_context.m_selection.state() == Selection::NONE) {
2847 if (
d->m_doc->isHTMLDocument()) {
2848 HTMLDocumentImpl* htmlDoc =
static_cast<HTMLDocumentImpl*
>(
d->m_doc);
2849 node = htmlDoc->body();
2853 d->editor_context.m_selection.moveTo(Position(node, 0));
2854 d->editor_context.m_selection.setNeedsLayout();
2855 d->editor_context.m_selection.needsCaretRepaint();
2863 if (!khtml::KHTMLPartAccessor::caret(part).caretPos().node()->isContentEditable())
2886 return d->m_caretMode;
2906 return d->m_designMode;
2910 return &
d->editor_context;
2917 Q_UNUSED(extendSelection);
2918 #ifndef KHTML_NO_CARET 2920 kDebug(6200) <<
"node: " << node.
handle() <<
" nodeName: " 2922 <<
" extendSelection " << extendSelection;
2923 if (
view()->moveCaretTo(node.
handle(), offset, !extendSelection))
2924 emitSelectionChanged();
2925 view()->ensureCaretVisible();
2927 #endif // KHTML_NO_CARET 2933 #ifndef KHTML_NO_CARET 2935 #else // KHTML_NO_CARET 2937 #endif // KHTML_NO_CARET 2946 #ifndef KHTML_NO_CARET 2947 view()->setCaretDisplayPolicyNonFocused(policy);
2948 #endif // KHTML_NO_CARET 2955 NodeImpl *caretNode =
d->editor_context.m_selection.caretPos().node();
2956 if (
isCaretMode() || (caretNode && caretNode->isContentEditable())) {
2957 invalidateSelection();
2958 enableFindAheadActions(
false);
2962 if (
d->editor_context.m_caretBlinkTimer >= 0)
2963 killTimer(
d->editor_context.m_caretBlinkTimer);
2964 clearCaretRectIfNeeded();
2971 d->m_find.findTextBegin();
2974 bool KHTMLPart::initFindNode(
bool selection,
bool reverse,
bool fromCursor )
2976 return d->m_find.initFindNode(
selection, reverse, fromCursor);
2979 void KHTMLPart::slotFind()
2984 if (!part->inherits(
"KHTMLPart") )
2986 kError(6000) <<
"part is a" << part->metaObject()->className() <<
", can't do a search into it";
2992 void KHTMLPart::slotFindNext()
2997 if (!part->inherits(
"KHTMLPart") )
2999 kError(6000) <<
"part is a" << part->metaObject()->className() <<
", can't do a search into it";
3005 void KHTMLPart::slotFindPrev()
3010 if (!part->inherits(
"KHTMLPart") )
3012 kError(6000) <<
"part is a" << part->metaObject()->className() <<
", can't do a search into it";
3018 void KHTMLPart::slotFindDone()
3023 void KHTMLPart::slotFindAheadText()
3033 void KHTMLPart::slotFindAheadLink()
3043 void KHTMLPart::enableFindAheadActions(
bool )
3048 void KHTMLPart::slotFindDialogDestroyed()
3057 d->m_find.activate();
3064 d->m_find.createNewKFind(str, options, parent, findDialog );
3072 return d->m_find.findTextNext( reverse );
3075 bool KHTMLPart::pFindTextNextInThisFrame(
bool reverse )
3077 return d->m_find.findTextNext( reverse );
3082 const Selection &sel =
d->editor_context.m_selection;
3084 kDebug() <<
"Selection is not valid. Returning empty selection";
3087 if(sel.start().offset() < 0 || sel.end().offset() < 0) {
3088 kDebug() <<
"invalid values for end/startOffset " << sel.start().offset() <<
" " << sel.end().offset();
3094 int exceptioncode = 0;
3095 return r.
handle()->toHTML(exceptioncode).string();
3100 bool hasNewLine =
true;
3101 bool seenTDTag =
false;
3103 const Selection &sel =
d->editor_context.m_selection;
3107 DOM::DOMStringImpl *dstr =
static_cast<DOM::TextImpl*
>(n.
handle())->renderString();
3108 QString str(dstr->s, dstr->l);
3109 if(!str.isEmpty()) {
3115 if(n == sel.start().node() && n == sel.end().node()) {
3116 int s = khtml::RenderPosition::fromDOMPosition(sel.start()).renderedOffset();
3117 int e = khtml::RenderPosition::fromDOMPosition(sel.end()).renderedOffset();
3118 text = str.mid(s, e-s);
3119 }
else if(n == sel.start().node()) {
3120 text = str.mid(khtml::RenderPosition::fromDOMPosition(sel.start()).renderedOffset());
3121 }
else if(n == sel.end().node()) {
3122 text += str.left(khtml::RenderPosition::fromDOMPosition(sel.end()).renderedOffset());
3132 text +=
static_cast<HTMLTextAreaElementImpl*
>(n.
handle())->value().string();
3135 if (static_cast<HTMLInputElementImpl*>(n.
handle())->inputType() != HTMLInputElementImpl::PASSWORD)
3136 text += static_cast<HTMLInputElementImpl*>(n.
handle())->value().string();
3139 text +=
static_cast<HTMLSelectElementImpl*
>(n.
handle())->value().string();
3146 text +=
static_cast<HTMLImageElementImpl*
>(n.
handle())->altText().string();
3180 if(n == sel.end().node())
break;
3231 int end = text.length();
3234 while ((start < end) && (text[start] ==
'\n'))
3238 while ((start < (end-1)) && (text[end-1] ==
'\n') && (text[end-2] ==
'\n'))
3241 return text.mid(start, end-start);
3244 QString KHTMLPart::simplifiedSelectedText()
const 3247 text.replace(QChar(0xa0),
' ');
3249 while (!text.isEmpty() && text[0].isSpace())
3251 while (!text.isEmpty() && text[text.length()-1].isSpace())
3252 text.truncate(text.length()-1);
3258 return !
d->editor_context.m_selection.isEmpty() && !
d->editor_context.m_selection.isCollapsed();
3263 return d->editor_context.m_selection.toRange();
3268 DOM::Range r =
d->editor_context.m_selection.toRange();
3280 const Selection &KHTMLPart::caret()
const 3282 return d->editor_context.m_selection;
3285 const Selection &KHTMLPart::dragCaret()
const 3287 return d->editor_context.m_dragCaret;
3290 void KHTMLPart::setCaret(
const Selection &s,
bool closeTyping)
3292 if (
d->editor_context.m_selection != s) {
3293 clearCaretRectIfNeeded();
3294 setFocusNodeIfNeeded(s);
3295 d->editor_context.m_selection = s;
3296 notifySelectionChanged(closeTyping);
3300 void KHTMLPart::setDragCaret(
const DOM::Selection &dragCaret)
3302 if (
d->editor_context.m_dragCaret != dragCaret) {
3303 d->editor_context.m_dragCaret.needsCaretRepaint();
3304 d->editor_context.m_dragCaret = dragCaret;
3305 d->editor_context.m_dragCaret.needsCaretRepaint();
3309 void KHTMLPart::clearSelection()
3311 clearCaretRectIfNeeded();
3312 setFocusNodeIfNeeded(
d->editor_context.m_selection);
3313 #ifdef APPLE_CHANGES 3314 d->editor_context.m_selection.clear();
3316 d->editor_context.m_selection.collapse();
3318 notifySelectionChanged();
3321 void KHTMLPart::invalidateSelection()
3323 clearCaretRectIfNeeded();
3324 d->editor_context.m_selection.setNeedsLayout();
3325 selectionLayoutChanged();
3328 void KHTMLPart::setSelectionVisible(
bool flag)
3330 if (
d->editor_context.m_caretVisible == flag)
3333 clearCaretRectIfNeeded();
3334 setFocusNodeIfNeeded(
d->editor_context.m_selection);
3335 d->editor_context.m_caretVisible = flag;
3340 void KHTMLPart::slotClearSelection()
3343 &&
d->editor_context.m_selection.state() != Selection::NONE
3344 && !
d->editor_context.m_selection.caretPos().node()->isContentEditable())
3345 clearCaretRectIfNeeded();
3347 #ifdef APPLE_CHANGES 3348 d->editor_context.m_selection.clear();
3350 d->editor_context.m_selection.collapse();
3353 notifySelectionChanged();
3357 void KHTMLPart::clearCaretRectIfNeeded()
3359 if (
d->editor_context.m_caretPaint) {
3360 d->editor_context.m_caretPaint =
false;
3361 d->editor_context.m_selection.needsCaretRepaint();
3365 void KHTMLPart::setFocusNodeIfNeeded(
const Selection &s)
3367 if (!xmlDocImpl() || s.state() == Selection::NONE)
3370 NodeImpl *n = s.start().node();
3371 NodeImpl *target = (n && n->isContentEditable()) ? n : 0;
3373 while (n && n != s.end().node()) {
3374 if (n->isContentEditable()) {
3378 n = n->traverseNextNode();
3381 assert(target == 0 || target->isContentEditable());
3384 for ( ; target && !target->isFocusable(); target = target->parentNode())
3386 if (target && target->isMouseFocusable())
3387 xmlDocImpl()->setFocusNode(target);
3388 else if (!target || !target->focused())
3389 xmlDocImpl()->setFocusNode(0);
3393 void KHTMLPart::selectionLayoutChanged()
3396 if (
d->editor_context.m_caretBlinkTimer >= 0) {
3397 killTimer(
d->editor_context.m_caretBlinkTimer);
3398 d->editor_context.m_caretBlinkTimer = -1;
3402 if (
d->editor_context.m_caretVisible
3403 &&
d->editor_context.m_selection.state() != Selection::NONE) {
3405 ||
d->editor_context.m_selection.caretPos().node()->isContentEditable();
3406 if (
d->editor_context.m_caretBlinks &&
d->editor_context.m_caretPaint)
3407 d->editor_context.m_caretBlinkTimer = startTimer(qApp->cursorFlashTime() / 2);
3408 d->editor_context.m_selection.needsCaretRepaint();
3410 QRect r(
d->editor_context.m_selection.getRepaintRect());
3411 if (
d->editor_context.m_caretPaint)
3412 d->m_view->ensureVisible(r.x(), r.y());
3416 d->m_doc->updateSelection();
3420 d->editor_context.m_xPosForVerticalArrowNavigation =
d->editor_context.NoXPosForVerticalArrowNavigation;
3423 void KHTMLPart::notifySelectionChanged(
bool closeTyping)
3425 Editor *ed =
d->editor_context.m_editor;
3426 selectionLayoutChanged();
3434 emitSelectionChanged();
3439 if (e->timerId() ==
d->editor_context.m_caretBlinkTimer) {
3440 if (
d->editor_context.m_caretBlinks &&
3441 d->editor_context.m_selection.state() != Selection::NONE) {
3442 d->editor_context.m_caretPaint = !
d->editor_context.m_caretPaint;
3443 d->editor_context.m_selection.needsCaretRepaint();
3445 }
else if (e->timerId() ==
d->m_DNSPrefetchTimer) {
3448 if (
d->m_DNSPrefetchQueue.isEmpty()) {
3449 killTimer(
d->m_DNSPrefetchTimer );
3450 d->m_DNSPrefetchTimer = -1;
3452 }
else if (e->timerId() ==
d->m_DNSTTLTimer) {
3453 foreach (
const QString &
name,
d->m_lookedupHosts)
3454 d->m_DNSPrefetchQueue.enqueue(name);
3455 if (
d->m_DNSPrefetchTimer <= 0)
3469 int dots = name.count(
'.');
3470 if (dots > 2 || (dots == 2 && !name.startsWith(
"www.")))
3474 if (
d->m_lookedupHosts.contains( name ) )
3477 d->m_DNSPrefetchQueue.enqueue( name );
3478 d->m_lookedupHosts.insert( name );
3479 d->m_numDNSPrefetchedNames++;
3481 if (
d->m_DNSPrefetchTimer < 1)
3483 if (
d->m_DNSTTLTimer < 1)
3489 void KHTMLPart::paintCaret(QPainter *p,
const QRect &rect)
const 3491 if (
d->editor_context.m_caretPaint)
3492 d->editor_context.m_selection.paintCaret(p, rect);
3495 void KHTMLPart::paintDragCaret(QPainter *p,
const QRect &rect)
const 3497 d->editor_context.m_dragCaret.paintCaret(p, rect);
3501 if (!
d->editor_context.m_editor)
3502 const_cast<KHTMLPart *
>(
this)->
d->editor_context.m_editor =
new DOM::Editor(const_cast<KHTMLPart *>(
this));
3503 return d->editor_context.m_editor;
3506 void KHTMLPart::resetHoverText()
3508 if( !
d->m_overURL.isEmpty() )
3510 d->m_overURL.clear();
3511 d->m_overURLTarget.clear();
3512 emit
onURL( QString() );
3514 setStatusBarText(QString(), BarHoverText);
3515 emit
d->m_extension->mouseOverInfo(
KFileItem());
3519 void KHTMLPart::overURL(
const QString &url,
const QString &target,
bool )
3524 if ( url.isEmpty() )
3529 if ( url.isEmpty() ) {
3530 setStatusBarText(Qt::escape(u.
prettyUrl()), BarHoverText);
3534 if (
d->isJavaScriptURL(url) ) {
3535 QString jscode =
d->codeForJavaScriptURL( url );
3537 if (url.startsWith(
"javascript:window.open"))
3538 jscode +=
i18n(
" (In new window)");
3539 setStatusBarText( Qt::escape( jscode ), BarHoverText );
3544 emit
d->m_extension->mouseOverInfo(item);
3553 if ( !u.isValid() ) {
3554 setStatusBarText(Qt::escape(u.
prettyUrl()), BarHoverText);
3562 const QString path = QFile::encodeName( u.
toLocalFile() );
3564 KDE_struct_stat buff;
3567 KDE_struct_stat lbuff;
3570 QString text = Qt::escape(u.
prettyUrl());
3571 QString text2 = text;
3573 if (ok && S_ISLNK( lbuff.st_mode ) )
3577 tmp =
i18n(
"Symbolic Link");
3579 tmp =
i18n(
"%1 (Link)", com);
3580 char buff_two[1024];
3582 int n = readlink ( path.toLocal8Bit().data(), buff_two, 1022);
3587 setStatusBarText(text2, BarHoverText);
3596 else if ( ok && S_ISREG( buff.st_mode ) )
3598 if (buff.st_size < 1024)
3599 text =
i18np(
"%2 (%1 byte)",
"%2 (%1 bytes)", (
long) buff.st_size, text2);
3602 float d = (float) buff.st_size/1024.0;
3608 else if ( ok && S_ISDIR( buff.st_mode ) )
3618 setStatusBarText(text, BarHoverText);
3623 if (target.toLower() ==
"_blank")
3625 extra =
i18n(
" (In new window)");
3627 else if (!target.isEmpty() &&
3628 (target.toLower() !=
"_top") &&
3629 (target.toLower() !=
"_self") &&
3630 (target.toLower() !=
"_parent"))
3636 extra =
i18n(
" (In new window)");
3638 extra =
i18n(
" (In other frame)");
3641 if (u.
protocol() == QLatin1String(
"mailto")) {
3643 mailtoMsg +=
i18n(
"Email to: ") + KUrl::fromPercentEncoding(u.
path().toLatin1());
3644 const QStringList queries = u.
query().mid(1).split(
'&');
3645 QStringList::ConstIterator it = queries.begin();
3646 const QStringList::ConstIterator itEnd = queries.end();
3647 for (; it != itEnd; ++it)
3648 if ((*it).startsWith(QLatin1String(
"subject=")))
3649 mailtoMsg +=
i18n(
" - Subject: ") + KUrl::fromPercentEncoding((*it).mid(8).toLatin1());
3650 else if ((*it).startsWith(QLatin1String(
"cc=")))
3651 mailtoMsg +=
i18n(
" - CC: ") + KUrl::fromPercentEncoding((*it).mid(3).toLatin1());
3652 else if ((*it).startsWith(QLatin1String(
"bcc=")))
3653 mailtoMsg +=
i18n(
" - BCC: ") + KUrl::fromPercentEncoding((*it).mid(4).toLatin1());
3654 mailtoMsg = Qt::escape(mailtoMsg);
3655 mailtoMsg.replace(QRegExp(
"([\n\r\t]|[ ]{10})"), QString());
3656 setStatusBarText(
"<qt>"+mailtoMsg, BarHoverText);
3661 else if (u.
protocol() == QLatin1String(
"http")) {
3666 if (!hrefNode.
isNull()) {
3668 if (!hreflangNode.
isNull()) {
3671 if (countryCode == QLatin1String(
"en"))
3672 countryCode = QLatin1String(
"gb");
3673 QString flagImg = QLatin1String(
"<img src=%1>").arg(
3674 locate(
"locale", QLatin1String(
"l10n/")
3676 + QLatin1String(
"/flag.png")));
3677 emit setStatusBarText(flagImg + u.
prettyUrl() + extra);
3682 setStatusBarText(Qt::escape(u.
prettyUrl()) + extra, BarHoverText);
3694 bool hasTarget =
false;
3696 QString target = _target;
3697 if ( target.isEmpty() &&
d->m_doc )
3698 target =
d->m_doc->baseTarget();
3699 if ( !target.isEmpty() )
3702 if (
d->isJavaScriptURL(url) )
3704 crossFrameExecuteScript( target,
d->codeForJavaScriptURL(url) );
3710 if ( url.isEmpty() )
3713 if ( !cURL.isValid() )
3717 kDebug(6050) <<
this <<
"complete URL:" << cURL.
url() <<
"target=" << target;
3719 if ( state & Qt::ControlModifier )
3721 emit
d->m_extension->createNewWindow( cURL, args, browserArgs );
3725 if ( button == Qt::LeftButton && ( state & Qt::ShiftModifier ) )
3728 metaData.insert(
"referrer",
d->m_referrer );
3733 if (!checkLinkSecurity(cURL,
3734 ki18n(
"<qt>This untrusted page links to<br /><b>%1</b>.<br />Do you want to follow the link?</qt>" ),
3740 args.
metaData().insert(
"main_frame_request",
3742 args.
metaData().insert(
"ssl_parent_ip",
d->m_ssl_parent_ip);
3743 args.
metaData().insert(
"ssl_parent_cert",
d->m_ssl_parent_cert);
3744 args.
metaData().insert(
"PropagateHttpHeader",
"true");
3745 args.
metaData().insert(
"ssl_was_in_use",
d->m_ssl_in_use ?
"TRUE":
"FALSE");
3746 args.
metaData().insert(
"ssl_activate_warnings",
"TRUE");
3748 if ( hasTarget && target !=
"_self" && target !=
"_top" && target !=
"_blank" && target !=
"_parent" )
3751 khtml::ChildFrame *frame = recursiveFrameRequest(
this, cURL, args, browserArgs,
false );
3754 args.
metaData()[
"referrer"] =
d->m_referrer;
3755 requestObject( frame, cURL, args, browserArgs );
3760 if (!
d->m_referrer.isEmpty() && !args.
metaData().contains(
"referrer"))
3761 args.
metaData()[
"referrer"] =
d->m_referrer;
3763 if ( button == Qt::NoButton && (state & Qt::ShiftModifier) && (state & Qt::ControlModifier) )
3765 emit
d->m_extension->createNewWindow( cURL, args, browserArgs );
3769 if ( state & Qt::ShiftModifier)
3773 emit
d->m_extension->createNewWindow( cURL, args, browserArgs, winArgs );
3780 if (cURL.
hasRef() && (!hasTarget || target ==
"_self"))
3782 if (
d->isLocalAnchorJump(cURL))
3784 d->executeAnchorJump(cURL, browserArgs.
lockHistory() );
3789 if ( !
d->m_bComplete && !hasTarget )
3792 view()->viewport()->unsetCursor();
3793 emit
d->m_extension->openUrlRequest( cURL, args, browserArgs );
3797 void KHTMLPart::slotViewDocumentSource()
3800 bool isTempFile =
false;
3804 sourceFile.
setSuffix(defaultExtension());
3805 sourceFile.setAutoRemove(
false);
3806 if (sourceFile.open())
3808 QDataStream stream ( &sourceFile );
3810 currentUrl =
KUrl();
3811 currentUrl.
setPath(sourceFile.fileName());
3816 (void)
KRun::runUrl( currentUrl, QLatin1String(
"text/plain"),
view(), isTempFile );
3819 void KHTMLPart::slotViewPageInfo()
3824 dlg->setAttribute(Qt::WA_DeleteOnClose);
3825 dlg->setObjectName(
"KHTML Page Info Dialog");
3829 connect(ui._close, SIGNAL(clicked()), dlg, SLOT(accept()));
3832 ui._title->setText(
d->m_doc->title().string().trimmed());
3835 if (
parentPart() &&
d->m_doc &&
d->m_doc->isHTMLDocument() ) {
3836 dlg->setWindowTitle(
i18n(
"Frame Information"));
3841 if (!
d->m_pageServices.isEmpty())
3842 editStr =
i18n(
" <a href=\"%1\">[Properties]</a>",
d->m_pageServices);
3845 ui._url->setText(
"<a href=\"" +
url().
url() +
"\">" + squeezedURL +
"</a>" + editStr);
3848 ui._lastModified->hide();
3849 ui._lmLabel->hide();
3855 if (enc.isEmpty()) {
3857 ui._encoding->hide();
3859 ui._encoding->setText(enc);
3862 if (!xmlDocImpl() || xmlDocImpl()->parseMode() == DOM::DocumentImpl::Unknown) {
3864 ui._modeLabel->hide();
3866 switch (xmlDocImpl()->parseMode()) {
3867 case DOM::DocumentImpl::Compat:
3868 ui._mode->setText(
i18nc(
"HTML rendering mode (see http://en.wikipedia.org/wiki/Quirks_mode)",
"Quirks"));
3870 case DOM::DocumentImpl::Transitional:
3871 ui._mode->setText(
i18nc(
"HTML rendering mode (see http://en.wikipedia.org/wiki/Quirks_mode)",
"Almost standards"));
3873 case DOM::DocumentImpl::Strict:
3875 ui._mode->setText(
i18nc(
"HTML rendering mode (see http://en.wikipedia.org/wiki/Quirks_mode)",
"Strict"));
3881 const QStringList headers =
d->m_httpHeaders.split(
"\n");
3883 QStringList::ConstIterator it = headers.begin();
3884 const QStringList::ConstIterator itEnd = headers.end();
3886 for (; it != itEnd; ++it) {
3887 const QStringList
header = (*it).split(QRegExp(
":[ ]+"));
3888 if (header.count() != 2)
3890 QTreeWidgetItem *item =
new QTreeWidgetItem(ui._headers);
3891 item->setText(0, header[0]);
3892 item->setText(1, header[1]);
3900 void KHTMLPart::slotViewFrameSource()
3907 bool isTempFile =
false;
3908 if (!(url.
isLocalFile()) && frame->inherits(
"KHTMLPart"))
3910 long cacheId =
static_cast<KHTMLPart *
>(frame)->
d->m_cacheId;
3915 sourceFile.
setSuffix(defaultExtension());
3916 sourceFile.setAutoRemove(
false);
3917 if (sourceFile.open())
3919 QDataStream stream ( &sourceFile );
3922 url.
setPath(sourceFile.fileName());
3928 (void)
KRun::runUrl( url, QLatin1String(
"text/plain"),
view(), isTempFile );
3934 if (!
d->m_doc || !
d->m_doc->isHTMLDocument())
3937 QString relURL =
static_cast<HTMLDocumentImpl*
>(
d->m_doc)->body()->getAttribute( ATTR_BACKGROUND ).string();
3942 void KHTMLPart::slotSaveBackground()
3945 metaData[
"referrer"] =
d->m_referrer;
3949 void KHTMLPart::slotSaveDocument()
3954 srcURL.
setFileName(
"index" + defaultExtension() );
3961 void KHTMLPart::slotSecurity()
3985 const QStringList sl =
d->m_ssl_peer_chain.split(
'\n', QString::SkipEmptyParts);
3987 bool certChainOk =
d->m_ssl_in_use;
3989 foreach (
const QString &s, sl) {
3990 certChain.append(QSslCertificate(s.toLatin1()));
3991 if (certChain.last().isNull()) {
3992 certChainOk =
false;
3998 kid->setup(certChain,
4002 d->m_ssl_cipher_desc,
4003 d->m_ssl_cipher_version,
4004 d->m_ssl_cipher_used_bits.toInt(),
4005 d->m_ssl_cipher_bits.toInt(),
4014 QStringList sl =
d->m_ssl_peer_chain.split(
'\x01', QString::SkipEmptyParts);
4016 bool decodedOk =
true;
4017 foreach (
const QString &s, sl) {
4018 certChain.append(QSslCertificate(s.toLatin1()));
4019 if (certChain.last().isNull()) {
4025 if (decodedOk ||
true ) {
4029 d->m_ssl_protocol_version,
4031 d->m_ssl_cipher_used_bits.toInt(),
4032 d->m_ssl_cipher_bits.toInt(),
4034 kDebug(7024) <<
"Showing SSL Info dialog";
4036 kDebug(7024) <<
"SSL Info dialog closed";
4039 "appears to be corrupt."),
4044 void KHTMLPart::slotSaveFrame()
4053 srcURL.
setFileName(
"index" + defaultExtension() );
4060 void KHTMLPart::slotSetEncoding(
const QString &enc)
4068 d->m_autoDetectLanguage=scri;
4072 void KHTMLPart::slotUseStylesheet()
4076 bool autoselect = (
d->m_paUseStylesheet->currentItem() == 0);
4077 d->m_sheetUsed = autoselect ? QString() :
d->m_paUseStylesheet->currentText();
4078 d->m_doc->updateStyleSelector();
4082 void KHTMLPart::updateActions()
4088 for (; it !=
end; ++it )
4095 if (
d->m_paViewFrame)
4096 d->m_paViewFrame->setEnabled( frames );
4097 if (
d->m_paSaveFrame)
4098 d->m_paSaveFrame->setEnabled( frames );
4101 d->m_paFind->setText(
i18n(
"&Find in Frame..." ) );
4103 d->m_paFind->setText(
i18n(
"&Find..." ) );
4110 bool enableFindAndSelectAll =
true;
4113 enableFindAndSelectAll = frame->inherits(
"KHTMLPart" );
4115 d->m_paFind->setEnabled( enableFindAndSelectAll );
4116 d->m_paSelectAll->setEnabled( enableFindAndSelectAll );
4118 bool enablePrintFrame =
false;
4124 enablePrintFrame = ext->metaObject()->indexOfSlot(
"print()" ) != -1;
4127 d->m_paPrintFrame->setEnabled( enablePrintFrame );
4132 if (
d->m_doc &&
d->m_doc->isHTMLDocument() &&
static_cast<HTMLDocumentImpl*
>(
d->m_doc)->body() && !
d->m_bClearing )
4133 bgURL = static_cast<HTMLDocumentImpl*>(
d->m_doc)->body()->getAttribute( ATTR_BACKGROUND ).string();
4135 if (
d->m_paSaveBackground)
4136 d->m_paSaveBackground->setEnabled( !bgURL.isEmpty() );
4138 if (
d->m_paDebugScript )
4139 d->m_paDebugScript->setEnabled(
d->m_frame ?
d->m_frame->m_jscript : 0L );
4145 if ((*it)->m_partContainerElement.data() == frame)
4146 return (*it)->m_scriptable.data();
4150 void KHTMLPart::loadFrameElement( DOM::HTMLPartContainerElementImpl *frame,
const QString &url,
4151 const QString &frameName,
const QStringList ¶ms,
bool isIFrame )
4156 FrameIt it =
d->m_frames.find( frameName );
4157 if ( it ==
d->m_frames.end() ) {
4160 child->
m_name = frameName;
4161 d->m_frames.insert(
d->m_frames.end(), child );
4173 QString
khtml = QString::fromLatin1(
"khtml");
4175 QString::fromLatin1(
"text/html"),
4176 khtml, dummy, QStringList());
4182 navigateLocalProtocol(child, part,
KUrl(
"about:blank"));
4183 connectToChildPart(child, part,
"text/html" );
4193 if (!requestObject( child, u ) && !child->
m_run) {
4198 QString KHTMLPart::requestFrameName()
4200 return QString::fromLatin1(
"<!--frame %1-->").arg(
d->m_frameNameId++);
4203 bool KHTMLPart::loadObjectElement( DOM::HTMLPartContainerElementImpl *frame,
const QString &url,
4204 const QString &serviceType,
const QStringList ¶ms )
4208 FrameIt it =
d->m_objects.insert(
d->m_objects.end(), child );
4209 (*it)->m_partContainerElement = frame;
4211 (*it)->m_params = params;
4215 if (!requestObject( *it,
completeURL( url ), args ) && !(*it)->m_run) {
4216 (*it)->m_bCompleted =
true;
4227 if (!
d->isJavaScriptURL(url.
url()) && !checkLinkSecurity(url))
4229 kDebug(6031) <<
this <<
"checkLinkSecurity refused";
4251 if ( child->
m_run ) {
4252 kDebug(6031) <<
"navigating ChildFrame while mimetype resolution was in progress...";
4253 child->
m_run.data()->abort();
4269 if (!
d->m_referrer.isEmpty() && !child->
m_args.
metaData().contains(
"referrer" ))
4274 child->
m_args.
metaData().insert(
"ssl_parent_cert",
d->m_ssl_parent_cert);
4278 d->m_ssl_in_use ?
"TRUE":
"FALSE");
4279 child->
m_args.
metaData().insert(
"ssl_activate_warnings",
"TRUE");
4285 if ((url.isEmpty() || url.
url() ==
"about:blank" || url.
protocol() ==
"javascript") && args.
mimeType().isEmpty())
4289 kDebug(6031) <<
"Running new KHTMLRun for" <<
this <<
"and child=" << child;
4291 d->m_bComplete =
false;
4294 return processObjectRequest( child, url, args.
mimeType() );
4309 kDebug( 6031 ) <<
"trying to create part for" << mimetype << _url;
4319 if (
d->m_onlyLocalReferences || ( url.isEmpty() && mimetype.isEmpty() ) ) {
4320 childLoadFailure(child);
4332 emit
d->m_extension->openUrlNotify();
4346 (child->
m_run && child->
m_run.data()->serverSuggestsSave())) {
4364 QString suggestedFileName;
4365 int disposition = 0;
4367 suggestedFileName =
run->suggestedFileName();
4368 disposition =
run->serverSuggestsSave() ?
4399 if (mime->
is(
"text/html")
4400 || mime->
is(
"application/xml")) {
4404 childLoadFailure(child);
4414 childLoadFailure(child);
4418 connectToChildPart( child, part, mimetype );
4422 checkEmitLoadEvent();
4455 return navigateChild( child, url );
4461 if (!qobject_cast<KHTMLPart*>(inPart))
4469 d->propagateInitialDomainAndBaseTo(p);
4472 if (
d->isJavaScriptURL(url.
url())) {
4475 d->codeForJavaScriptURL(url.
url()));
4480 d->propagateInitialDomainAndBaseTo(p);
4481 p->
write( res.toString() );
4487 p->
write(
"<HTML><TITLE></TITLE><BODY></BODY></HTML>");
4497 if (url.
protocol() ==
"javascript" || url.
url() ==
"about:blank") {
4498 return navigateLocalProtocol(child, child->
m_part.data(),
url);
4499 }
else if ( !url.isEmpty() ) {
4500 kDebug( 6031 ) <<
"opening" << url <<
"in frame" << child->
m_part;
4501 bool b = child->
m_part.data()->openUrl( url );
4516 kDebug(6031) <<
"we:" <<
this <<
"kid:" << child << part << mimetype;
4518 part->setObjectName( child->
m_name );
4522 if (!qobject_cast<KHTMLPart*>(p) && child->
m_jscript)
4540 if (qobject_cast<KHTMLPart*>(part)) {
4541 static_cast<KHTMLPart*
>(part)->
d->m_frame = child;
4553 scriptExt->
setHost(
d->m_scriptableExtension);
4561 this, SLOT(slotChildStarted(
KIO::Job*)) );
4563 this, SLOT(slotChildCompleted()) );
4565 this, SLOT(slotChildCompleted(
bool)) );
4566 connect( part, SIGNAL(setStatusBarText(QString)),
4567 this, SIGNAL(setStatusBarText(QString)) );
4568 if ( part->inherits(
"KHTMLPart" ) )
4571 part, SLOT(slotParentCompleted()) );
4573 part, SLOT(slotParentCompleted()) );
4577 this, SLOT(slotChildDocCreated()) );
4584 connect( kidBrowserExt, SIGNAL(openUrlNotify()),
4585 d->m_extension, SIGNAL(openUrlNotify()) );
4598 connect( kidBrowserExt, SIGNAL(infoMessage(QString)),
4599 d->m_extension, SIGNAL(infoMessage(QString)) );
4604 kidBrowserExt->setBrowserInterface(
d->m_extension->browserInterface() );
4609 QObject *parent,
const QString &mimetype,
4610 QString &serviceName, QStringList &serviceTypes,
4611 const QStringList ¶ms )
4614 if ( !serviceName.isEmpty() )
4615 constr.append( QString::fromLatin1(
"DesktopEntryName == '%1'" ).arg( serviceName ) );
4619 if ( offers.isEmpty() ) {
4620 int pos = mimetype.indexOf(
"-plugin" );
4623 QString stripped_mime = mimetype.left( pos );
4625 if ( offers.isEmpty() )
4629 KService::List::ConstIterator it = offers.constBegin();
4630 const KService::List::ConstIterator itEnd = offers.constEnd();
4631 for ( ; it != itEnd; ++it )
4639 QVariantList variantlist;
4640 Q_FOREACH(
const QString& str, params)
4641 variantlist << QVariant(str);
4643 if ( service->
serviceTypes().contains(
"Browser/View" ) )
4644 variantlist << QString(
"Browser/View");
4649 serviceName = service->
name();
4654 kWarning() << QString(
"There was an error loading the module %1.\nThe diagnostics is:\n%2")
4663 if ( !
d->m_manager &&
d->m_view )
4666 d->m_manager->setObjectName(
"khtml part manager" );
4667 d->m_manager->setAllowNestedParts(
true );
4668 connect(
d->m_manager, SIGNAL(activePartChanged(
KParts::Part*)),
4674 return d->m_manager;
4677 void KHTMLPart::submitFormAgain()
4679 disconnect(
this, SIGNAL(
completed()),
this, SLOT(submitFormAgain()));
4680 if(
d->m_doc && !
d->m_doc->parsing() &&
d->m_submitForm)
4681 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 );
4683 delete d->m_submitForm;
4684 d->m_submitForm = 0;
4687 void KHTMLPart::submitFormProxy(
const char *
action,
const QString &url,
const QByteArray &formData,
const QString &_target,
const QString& contentType,
const QString& boundary )
4689 submitForm(action, url, formData, _target, contentType, boundary);
4692 void KHTMLPart::submitForm(
const char *
action,
const QString &url,
const QByteArray &formData,
const QString &_target,
const QString& contentType,
const QString& boundary )
4694 kDebug(6000) <<
this <<
"target=" << _target <<
"url=" <<
url;
4722 if (!
d->m_submitForm) {
4724 if (
d->m_ssl_in_use) {
4726 "\nA third party may be able to intercept and view this information." 4727 "\nAre you sure you wish to continue?"),
4735 i18n(
"Warning: Your data is about to be transmitted across the network unencrypted." 4736 "\nAre you sure you wish to continue?"),
4737 i18n(
"Network Transmission"),
4740 "WarnOnUnencryptedForm");
4742 QString grpNotifMsgs = QLatin1String(
"Notification Messages");
4745 if (!cg.
readEntry(
"WarnOnUnencryptedForm",
true)) {
4759 i18n(
"This site is attempting to submit form data via email.\n" 4760 "Do you want to continue?"),
4761 i18n(
"Network Transmission"),
4764 "WarnTriedEmailSubmit");
4775 QString urlstring = u.
url();
4777 if (
d->isJavaScriptURL(urlstring) ) {
4778 crossFrameExecuteScript( _target,
d->codeForJavaScriptURL(urlstring) );
4782 if (!checkLinkSecurity(u,
4783 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>" ),
4789 d->clearRedirection();
4793 if (!
d->m_referrer.isEmpty())
4794 args.
metaData()[
"referrer"] =
d->m_referrer;
4796 args.
metaData().insert(
"PropagateHttpHeader",
"true");
4797 args.
metaData().insert(
"ssl_parent_ip",
d->m_ssl_parent_ip);
4798 args.
metaData().insert(
"ssl_parent_cert",
d->m_ssl_parent_cert);
4799 args.
metaData().insert(
"main_frame_request",
4801 args.
metaData().insert(
"ssl_was_in_use",
d->m_ssl_in_use ?
"TRUE":
"FALSE");
4802 args.
metaData().insert(
"ssl_activate_warnings",
"TRUE");
4807 browserArgs.
frameName = _target.isEmpty() ?
d->m_doc->baseTarget() : _target ;
4812 QString q = u.
query().mid(1);
4813 QStringList nvps = q.split(
"&");
4814 bool triedToAttach =
false;
4816 QStringList::Iterator nvp = nvps.begin();
4817 const QStringList::Iterator nvpEnd = nvps.end();
4822 while (nvp != nvpEnd) {
4823 const QStringList pair = (*nvp).split(
"=");
4824 if (pair.count() >= 2) {
4825 if (pair.first().toLower() ==
"attach") {
4826 nvp = nvps.erase(nvp);
4827 triedToAttach =
true;
4837 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");
4841 if (contentType.toLower() ==
"multipart/form-data") {
4843 bodyEnc = QLatin1String( KUrl::toPercentEncoding(QString::fromLatin1(formData.data(),
4845 }
else if (contentType.toLower() ==
"text/plain") {
4847 QString tmpbody = QString::fromLatin1(formData.data(),
4849 tmpbody.replace(QRegExp(
"[&]"),
"\n");
4850 tmpbody.replace(QRegExp(
"[+]"),
" ");
4851 tmpbody = KUrl::fromPercentEncoding(tmpbody.toLatin1());
4852 bodyEnc = QLatin1String( KUrl::toPercentEncoding(tmpbody) );
4854 bodyEnc = QLatin1String( KUrl::toPercentEncoding(QString::fromLatin1(formData.data(),
4855 formData.size())) );
4858 nvps.append(QString(
"body=%1").arg(bodyEnc));
4865 u.
setQuery( QString::fromLatin1( formData.data(), formData.size() ) );
4873 if (contentType.isNull() || contentType ==
"application/x-www-form-urlencoded")
4874 browserArgs.
setContentType(
"Content-Type: application/x-www-form-urlencoded" );
4876 browserArgs.
setContentType(
"Content-Type: " + contentType +
"; boundary=" + boundary );
4879 if (
d->m_doc->parsing() ||
d->m_runningScripts > 0 ) {
4880 if(
d->m_submitForm ) {
4881 kDebug(6000) <<
"ABORTING!";
4885 d->m_submitForm->submitAction =
action;
4886 d->m_submitForm->submitUrl =
url;
4887 d->m_submitForm->submitFormData = formData;
4888 d->m_submitForm->target = _target;
4889 d->m_submitForm->submitContentType = contentType;
4890 d->m_submitForm->submitBoundary = boundary;
4891 connect(
this, SIGNAL(
completed()),
this, SLOT(submitFormAgain()));
4895 emit
d->m_extension->openUrlRequest( u, args, browserArgs );
4908 if ( linkUrl.isEmpty() ) {
4914 popupURL = khtmlPart->
url();
4922 linkKUrl = popupURL;
4926 if (!(
d->m_strSelectedURLTarget).isEmpty() &&
4927 (
d->m_strSelectedURLTarget.toLower() !=
"_top") &&
4928 (
d->m_strSelectedURLTarget.toLower() !=
"_self") &&
4929 (
d->m_strSelectedURLTarget.toLower() !=
"_parent")) {
4930 if (
d->m_strSelectedURLTarget.toLower() ==
"_blank")
4945 QPointer<QObject> guard( client );
4947 QString
mimetype = QLatin1String(
"text/html" );
4950 if (!linkUrl.isEmpty())
4959 if (!fname.isEmpty() && !popupURL.
hasRef() && popupURL.
query().isEmpty())
4968 !pmt->
is(
"application/x-perl") &&
4969 !pmt->
is(
"application/x-perl-module") &&
4970 !pmt->
is(
"application/x-php") &&
4971 !pmt->
is(
"application/x-python-bytecode") &&
4972 !pmt->
is(
"application/x-python") &&
4973 !pmt->
is(
"application/x-shellscript"))
4974 mimetype = pmt->
name();
4981 emit
d->m_extension->popupMenu( QCursor::pos(), popupURL, S_IFREG ,
4982 args, browserArgs, itemflags,
4985 if ( !guard.isNull() ) {
4987 emit
popupMenu(linkUrl, QCursor::pos());
4988 d->m_strSelectedURL.clear();
4989 d->m_strSelectedURLTarget.clear();
4993 void KHTMLPart::slotParentCompleted()
4996 if ( !
d->m_redirectURL.isEmpty() && !
d->m_redirectionTimer.isActive() )
4999 d->m_redirectionTimer.setSingleShot(
true );
5000 d->m_redirectionTimer.start( qMax(0, 1000 *
d->m_delayRedirect) );
5004 void KHTMLPart::slotChildStarted(
KIO::Job *job )
5012 if (
d->m_bComplete )
5018 emit
d->m_extension->openURLNotify();
5021 d->m_bComplete =
false;
5026 void KHTMLPart::slotChildCompleted()
5028 slotChildCompleted(
false );
5031 void KHTMLPart::slotChildCompleted(
bool pendingAction )
5043 if (!qobject_cast<KHTMLPart*>(child->
m_part))
5049 void KHTMLPart::slotChildDocCreated()
5054 if (
KHTMLPart* htmlFrame = qobject_cast<KHTMLPart*>(sender()))
5055 d->propagateInitialDomainAndBaseTo(htmlFrame);
5058 disconnect( sender(), SIGNAL(
docCreated()),
this, SLOT(slotChildDocCreated()) );
5065 if ( m_doc && kid->d->
m_doc ) {
5066 DocumentImpl* kidDoc = kid->d->
m_doc;
5067 if ( kidDoc->origin()->isEmpty() ) {
5068 kidDoc->setOrigin ( m_doc->origin() );
5069 kidDoc->setBaseURL( m_doc->baseURL() );
5080 QString urlStr = url.
url();
5081 if (
d->isJavaScriptURL(urlStr) ) {
5086 QString frameName = browserArgs.
frameName.toLower();
5087 if ( !frameName.isEmpty() ) {
5088 if ( frameName == QLatin1String(
"_top" ) )
5090 emit
d->m_extension->openUrlRequest( url, args, browserArgs );
5093 else if ( frameName == QLatin1String(
"_blank" ) )
5095 emit
d->m_extension->createNewWindow( url, args, browserArgs );
5098 else if ( frameName == QLatin1String(
"_parent" ) )
5102 emit
d->m_extension->openUrlRequest( url, args, newBrowserArgs );
5105 else if ( frameName != QLatin1String(
"_self" ) )
5107 khtml::ChildFrame *_frame = recursiveFrameRequest( callingHtmlPart, url, args, browserArgs );
5111 emit
d->m_extension->openUrlRequest( url, args, browserArgs );
5122 requestObject( child, url, args, browserArgs );
5123 }
else if ( frameName==
"_self" )
5127 emit
d->m_extension->openUrlRequest( url, args, newBrowserArgs );
5133 emit
d->m_extension->requestFocus(
this);
5138 assert( obj->inherits(
"KParts::ReadOnlyPart" ) );
5143 for (; it !=
end; ++it ) {
5144 if ((*it)->m_part.data() == part )
5149 const FrameIt oiEnd =
d->m_objects.end();
5150 for (; oi != oiEnd; ++oi ) {
5151 if ((*oi)->m_part.data() == part)
5160 bool KHTMLPart::checkFrameAccess(
KHTMLPart *callingHtmlPart)
5162 if (callingHtmlPart ==
this)
5165 if (!xmlDocImpl()) {
5166 #ifdef DEBUG_FINDFRAME 5167 kDebug(6050) <<
"Empty part" <<
this <<
"URL = " <<
url();
5173 if (callingHtmlPart && callingHtmlPart->xmlDocImpl() && xmlDocImpl()) {
5174 khtml::SecurityOrigin* actDomain = callingHtmlPart->xmlDocImpl()->origin();
5175 khtml::SecurityOrigin* destDomain = xmlDocImpl()->origin();
5177 if (actDomain->canAccess(destDomain))
5180 #ifdef DEBUG_FINDFRAME 5183 kDebug(6050) <<
"Unknown part/domain" << callingHtmlPart <<
"tries to access part" <<
this;
5192 return d->findFrameParent(callingPart, f, childFrame,
false);
5198 #ifdef DEBUG_FINDFRAME 5199 kDebug(6050) << q <<
"URL =" << q->url() <<
"name =" << q->objectName() <<
"findFrameParent(" << f <<
")";
5204 if (!callingHtmlPart)
5207 if (!checkForNavigation && !q->checkFrameAccess(callingHtmlPart))
5210 if (!childFrame && !q->parentPart() && (q->objectName() == f)) {
5211 if (!checkForNavigation || callingHtmlPart->d->
canNavigate(q))
5215 FrameIt it = m_frames.find( f );
5219 #ifdef DEBUG_FINDFRAME 5220 kDebug(6050) <<
"FOUND!";
5222 if (!checkForNavigation || callingHtmlPart->d->
canNavigate((*it)->m_part.data())) {
5229 it = m_frames.begin();
5230 for (; it !=
end; ++it )
5232 if (
KHTMLPart* p = qobject_cast<KHTMLPart*>((*it)->m_part.data()) )
5262 if (q->checkFrameAccess(b))
5266 if (q->parentPart() && top() == b)
5271 if (b->opener() && canNavigate(b->opener()))
5276 if (anc->checkFrameAccess(q))
5305 while ( part && part->inherits(
"KHTMLPart") &&
5306 static_cast<KHTMLPart *
>(part)->
d->m_frames.count() > 0 ) {
5309 if ( !part )
return frameset;
5316 FrameIt it =
d->m_frames.find( frameName );
5317 if ( it ==
d->m_frames.end() )
5323 return (!(*it)->m_partContainerElement.isNull());
5327 const QString& newName)
5329 for (
int i = 0; i < m_frames.size(); ++i) {
5340 return kp->jScript();
5343 const FrameIt itEnd =
d->m_frames.end();
5345 for (; it != itEnd; ++it) {
5347 if (framePart == frame->
m_part.data()) {
5358 return qobject_cast<
KHTMLPart*>( parent() );
5365 #ifdef DEBUG_FINDFRAME 5372 if (childPart ==
this)
5375 childPart->requestObject( childFrame, url, args, browserArgs );
5384 parentPart()->requestObject( res, url, args, browserArgs );
5390 #ifdef DEBUG_SAVESTATE 5391 static int s_saveStateIndentLevel = 0;
5396 #ifdef DEBUG_SAVESTATE 5397 QString
indent= QString().leftJustified( s_saveStateIndentLevel * 4,
' ' );
5398 const int indentLevel = s_saveStateIndentLevel++;
5399 kDebug( 6050 ) << indent <<
"saveState this=" <<
this <<
" '" << objectName() <<
"' saving URL " <<
url().
url();
5402 stream <<
url() << (qint32)
d->m_view->contentsX() << (qint32)
d->m_view->contentsY()
5403 << (qint32)
d->m_view->contentsWidth() << (qint32)
d->m_view->contentsHeight() << (qint32)
d->m_view->marginWidth() << (qint32)
d->m_view->marginHeight();
5406 int focusNodeNumber;
5407 if (!
d->m_focusNodeRestored)
5408 focusNodeNumber =
d->m_focusNodeNumber;
5409 else if (
d->m_doc &&
d->m_doc->focusNode())
5410 focusNodeNumber =
d->m_doc->nodeAbsIndex(
d->m_doc->focusNode());
5412 focusNodeNumber = -1;
5413 stream << focusNodeNumber;
5416 stream <<
d->m_cacheId;
5419 QStringList docState;
5422 docState =
d->m_doc->docState();
5424 stream <<
d->m_encoding <<
d->m_sheetUsed << docState;
5426 stream <<
d->m_zoomFactor;
5427 stream <<
d->m_fontScaleFactor;
5429 stream <<
d->m_httpHeaders;
5430 stream <<
d->m_pageServices;
5431 stream <<
d->m_pageReferrer;
5434 stream <<
d->m_ssl_in_use
5435 <<
d->m_ssl_peer_chain
5438 <<
d->m_ssl_protocol_version
5439 <<
d->m_ssl_cipher_used_bits
5440 <<
d->m_ssl_cipher_bits
5441 <<
d->m_ssl_cert_errors
5442 <<
d->m_ssl_parent_ip
5443 <<
d->m_ssl_parent_cert;
5446 QStringList frameNameLst, frameServiceTypeLst, frameServiceNameLst;
5453 for (; it !=
end; ++it )
5455 if ( !(*it)->m_part )
5458 frameNameLst << (*it)->m_name;
5459 frameServiceTypeLst << (*it)->m_serviceType;
5460 frameServiceNameLst << (*it)->m_serviceName;
5461 frameURLLst << (*it)->m_part.data()->url();
5464 QDataStream frameStream( &state, QIODevice::WriteOnly );
5466 if ( (*it)->m_extension )
5467 (*it)->m_extension.data()->saveState( frameStream );
5469 frameStateBufferLst << state;
5471 frameTypeLst << int( (*it)->m_type );
5475 stream << (quint32) frameNameLst.count();
5476 stream << frameNameLst << frameServiceTypeLst << frameServiceNameLst << frameURLLst << frameStateBufferLst << frameTypeLst;
5477 #ifdef DEBUG_SAVESTATE 5478 s_saveStateIndentLevel = indentLevel;
5485 qint32 xOffset, yOffset, wContents, hContents, mWidth, mHeight;
5487 QStringList
frameNames, frameServiceTypes, docState, frameServiceNames;
5493 long old_cacheId =
d->m_cacheId;
5495 stream >> u >> xOffset >> yOffset >> wContents >> hContents >> mWidth >> mHeight;
5497 d->m_view->setMarginWidth( mWidth );
5498 d->m_view->setMarginHeight( mHeight );
5502 stream >>
d->m_focusNodeNumber;
5503 d->m_focusNodeRestored =
false;
5505 stream >>
d->m_cacheId;
5507 stream >> encoding >> sheetUsed >> docState;
5510 d->m_sheetUsed = sheetUsed;
5520 stream >>
d->m_httpHeaders;
5521 stream >>
d->m_pageServices;
5522 stream >>
d->m_pageReferrer;
5525 stream >>
d->m_ssl_in_use
5526 >>
d->m_ssl_peer_chain
5529 >>
d->m_ssl_protocol_version
5530 >>
d->m_ssl_cipher_used_bits
5531 >>
d->m_ssl_cipher_bits
5532 >>
d->m_ssl_cert_errors
5533 >>
d->m_ssl_parent_ip
5534 >>
d->m_ssl_parent_cert;
5538 stream >> frameCount >> frameNames >> frameServiceTypes >> frameServiceNames
5539 >> frameURLs >> frameStateBuffers >> frameTypes;
5541 d->m_bComplete =
false;
5542 d->m_bLoadEventEmitted =
false;
5548 if (
d->m_cacheId == old_cacheId &&
signed(frameCount) ==
d->m_frames.count())
5551 d->m_redirectionTimer.stop();
5554 const FrameIt fEnd =
d->m_frames.end();
5556 for (; fIt != fEnd; ++fIt )
5557 (*fIt)->m_bCompleted =
false;
5559 fIt =
d->m_frames.begin();
5561 QStringList::ConstIterator fNameIt = frameNames.constBegin();
5562 QStringList::ConstIterator fServiceTypeIt = frameServiceTypes.constBegin();
5563 QStringList::ConstIterator fServiceNameIt = frameServiceNames.constBegin();
5564 KUrl::List::ConstIterator fURLIt = frameURLs.constBegin();
5568 for (; fIt != fEnd; ++fIt, ++fNameIt, ++fServiceTypeIt, ++fServiceNameIt, ++fURLIt, ++fBufferIt, ++fFrameTypeIt )
5577 child->
m_name = *fNameIt;
5580 processObjectRequest( child, *fURLIt, *fServiceTypeIt );
5585 if ( child->
m_extension && !(*fBufferIt).isEmpty() )
5587 QDataStream frameStream( *fBufferIt );
5588 child->
m_extension.data()->restoreState( frameStream );
5591 child->
m_part.data()->openUrl( *fURLIt );
5602 d->m_extension->setBrowserArguments(browserArgs);
5604 d->m_view->resizeContents( wContents, hContents );
5605 d->m_view->setContentsPos( xOffset, yOffset );
5615 d->m_bCleared =
false;
5618 d->m_sheetUsed = sheetUsed;
5620 QStringList::ConstIterator fNameIt = frameNames.constBegin();
5621 const QStringList::ConstIterator fNameEnd = frameNames.constEnd();
5623 QStringList::ConstIterator fServiceTypeIt = frameServiceTypes.constBegin();
5624 QStringList::ConstIterator fServiceNameIt = frameServiceNames.constBegin();
5625 KUrl::List::ConstIterator fURLIt = frameURLs.constBegin();
5629 for (; fNameIt != fNameEnd; ++fNameIt, ++fServiceTypeIt, ++fServiceNameIt, ++fURLIt, ++fBufferIt, ++fFrameTypeIt )
5633 newChild->
m_name = *fNameIt;
5639 const FrameIt childFrame =
d->m_frames.insert(
d->m_frames.end(), newChild );
5641 processObjectRequest( *childFrame, *fURLIt, *fServiceTypeIt );
5643 (*childFrame)->m_bPreloaded =
true;
5645 if ( (*childFrame)->m_part )
5647 if ( (*childFrame)->m_extension && !(*fBufferIt).isEmpty() )
5649 QDataStream frameStream( *fBufferIt );
5650 (*childFrame)->m_extension.data()->restoreState( frameStream );
5653 (*childFrame)->m_part.data()->openUrl( *fURLIt );
5664 d->m_extension->setBrowserArguments(browserArgs);
5668 d->m_restored =
true;
5670 d->m_restored =
false;
5694 return d->m_view->nodeUnderMouse();
5699 return d->m_view->nonSharedNodeUnderMouse();
5702 void KHTMLPart::emitSelectionChanged()
5706 if (!
d->m_activeFrame)
5708 emit
d->m_extension->enableAction(
"copy",
hasSelection() );
5716 return d->m_zoomFactor;
5720 static const int zoomSizes[] = { 20, 40, 60, 80, 90, 95, 100, 105, 110, 120, 140, 160, 180, 200, 250, 300 };
5726 extern const int KDE_NO_EXPORT
fastZoomSizes[] = { 20, 50, 75, 90, 100, 120, 150, 200, 300 };
5727 extern const int KDE_NO_EXPORT
fastZoomSizeCount =
sizeof fastZoomSizes /
sizeof fastZoomSizes[0];
5729 void KHTMLPart::slotIncZoom()
5734 void KHTMLPart::slotDecZoom()
5739 void KHTMLPart::slotIncZoomFast()
5741 zoomIn(fastZoomSizes, fastZoomSizeCount);
5744 void KHTMLPart::slotDecZoomFast()
5746 zoomOut(fastZoomSizes, fastZoomSizeCount);
5749 void KHTMLPart::zoomIn(
const int stepping[],
int count)
5753 if (zoomFactor < maxZoom) {
5755 for (
int i = 0; i < count; ++i)
5756 if (stepping[i] > zoomFactor) {
5757 zoomFactor = stepping[i];
5764 void KHTMLPart::zoomOut(
const int stepping[],
int count)
5767 if (zoomFactor > minZoom) {
5769 for (
int i = count-1; i >= 0; --i)
5770 if (stepping[i] < zoomFactor) {
5771 zoomFactor = stepping[i];
5782 if (percent < 100) percent = 100;
5785 if (percent > maxZoom) percent =
maxZoom;
5786 if (
d->m_zoomFactor == percent)
return;
5787 d->m_zoomFactor = percent;
5796 QApplication::setOverrideCursor( Qt::WaitCursor );
5797 d->m_view->setZoomLevel(
d->m_zoomFactor );
5798 QApplication::restoreOverrideCursor();
5803 for (; it !=
end; ++it ) {
5804 if (
KHTMLPart* p = qobject_cast<KHTMLPart*>((*it)->m_part.data()) )
5805 p->setZoomFactor(
d->m_zoomFactor);
5809 d->m_paDecZoomFactor->setEnabled(
d->m_zoomFactor > minZoom );
5810 d->m_paIncZoomFactor->setEnabled(
d->m_zoomFactor < maxZoom );
5814 void KHTMLPart::slotIncFontSize()
5819 void KHTMLPart::slotDecFontSize()
5824 void KHTMLPart::slotIncFontSizeFast()
5826 incFontSize(fastZoomSizes, fastZoomSizeCount);
5829 void KHTMLPart::slotDecFontSizeFast()
5831 decFontSize(fastZoomSizes, fastZoomSizeCount);
5834 void KHTMLPart::incFontSize(
const int stepping[],
int count)
5838 if (zoomFactor < maxZoom) {
5840 for (
int i = 0; i < count; ++i)
5841 if (stepping[i] > zoomFactor) {
5842 zoomFactor = stepping[i];
5849 void KHTMLPart::decFontSize(
const int stepping[],
int count)
5852 if (zoomFactor > minZoom) {
5854 for (
int i = count-1; i >= 0; --i)
5855 if (stepping[i] < zoomFactor) {
5856 zoomFactor = stepping[i];
5865 if (percent < minZoom) percent =
minZoom;
5866 if (percent > maxZoom) percent =
maxZoom;
5867 if (
d->m_fontScaleFactor == percent)
return;
5868 d->m_fontScaleFactor = percent;
5870 if (
d->m_view &&
d->m_doc) {
5871 QApplication::setOverrideCursor( Qt::WaitCursor );
5872 if (
d->m_doc->styleSelector())
5873 d->m_doc->styleSelector()->computeFontSizes(
d->m_doc->logicalDpiY(),
d->m_fontScaleFactor);
5874 d->m_doc->recalcStyle( NodeImpl::Force );
5875 QApplication::restoreOverrideCursor();
5880 for (; it !=
end; ++it ) {
5881 if (
KHTMLPart* p = qobject_cast<KHTMLPart*>((*it)->m_part.data()) )
5882 p->setFontScaleFactor(
d->m_fontScaleFactor);
5888 return d->m_fontScaleFactor;
5891 void KHTMLPart::slotZoomView(
int delta )
5899 void KHTMLPart::setStatusBarText(
const QString& text, StatusBarPriority p)
5901 if (!
d->m_statusMessagesEnabled)
5904 d->m_statusBarText[p] = text;
5907 QString tobe =
d->m_statusBarText[BarHoverText];
5909 tobe =
d->m_statusBarText[BarOverrideText];
5910 if (tobe.isEmpty()) {
5911 tobe =
d->m_statusBarText[BarDefaultText];
5912 if (!tobe.isEmpty() &&
d->m_jobspeed)
5919 emit ReadOnlyPart::setStatusBarText(tobe);
5925 setStatusBarText(text, BarOverrideText);
5930 setStatusBarText(text, BarDefaultText);
5935 return d->m_statusBarText[BarOverrideText];
5940 return d->m_statusBarText[BarDefaultText];
5945 return d->m_referrer;
5950 KUrl referrerURL =
KUrl(
d->m_pageReferrer );
5951 if (referrerURL.isValid())
5953 QString protocol = referrerURL.
protocol();
5955 if ((protocol ==
"http") ||
5956 ((protocol ==
"https") && (
url().protocol() ==
"https")))
5958 referrerURL.
setRef(QString());
5959 referrerURL.
setUser(QString());
5960 referrerURL.
setPass(QString());
5961 return referrerURL.
url();
5975 QDateTime lastModif = QFileInfo(
url().toLocalFile() ).lastModified();
5976 d->m_lastModified = lastModif.toString( Qt::LocalDate );
5979 return d->m_lastModified;
5982 void KHTMLPart::slotLoadImages()
5985 d->m_doc->docLoader()->setAutoloadImages( !
d->m_doc->docLoader()->autoloadImages() );
5989 for (; it !=
end; ++it ) {
5990 if (
KHTMLPart* p = qobject_cast<KHTMLPart*>((*it)->m_part.data()) )
5991 p->slotLoadImages();
5995 void KHTMLPart::reparseConfiguration()
6002 d->m_doc->docLoader()->setShowAnimations( settings->
showAnimations() );
6011 delete d->m_settings;
6014 QApplication::setOverrideCursor( Qt::WaitCursor );
6015 khtml::CSSStyleSelector::reparseConfiguration();
6016 if(
d->m_doc)
d->m_doc->updateStyleSelector();
6017 QApplication::restoreOverrideCursor();
6039 for (; it !=
end; ++it )
6040 if (!(*it)->m_bPreloaded && (*it)->m_part)
6041 res += (*it)->m_name;
6052 for (; it !=
end; ++it )
6053 if (!(*it)->m_bPreloaded && (*it)->m_part)
6055 res.append( (*it)->m_part.data() );
6065 if ( it ==
d->m_frames.end() )
6070 emit
d->m_extension->openUrlNotify();
6072 requestObject( *it, url, args, browserArgs );
6125 if (
d->editor_context.m_selection.state() == Selection::CARET)
6127 if (!xmlDocImpl()->renderer())
6130 khtml::RenderObject::NodeInfo nodeInfo(
true,
true);
6131 xmlDocImpl()->renderer()->layer()->nodeAtPoint(nodeInfo, x, y);
6132 NodeImpl *innerNode = nodeInfo.innerNode();
6133 if (!innerNode || !innerNode->renderer())
6136 return innerNode->isPointInsideSelection(x, y,
d->editor_context.m_selection);
6144 static bool firstRunAt(khtml::RenderObject *renderNode,
int y, NodeImpl *&startNode,
long &startOffset)
6146 for (khtml::RenderObject *n = renderNode; n; n = n->
nextSibling()) {
6148 khtml::RenderText*
const textRenderer =
static_cast<khtml::RenderText *
>(n);
6149 for (khtml::InlineTextBox* box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
6150 if (box->m_y == y && textRenderer->element()) {
6151 startNode = textRenderer->element();
6152 startOffset = box->m_start;
6171 static bool lastRunAt(khtml::RenderObject *renderNode,
int y, NodeImpl *&endNode,
long &endOffset)
6173 khtml::RenderObject *n = renderNode;
6177 khtml::RenderObject *
next;
6178 while ((next = n->nextSibling())) {
6183 if (
lastRunAt(n->firstChild(), y, endNode, endOffset)) {
6188 khtml::RenderText*
const textRenderer =
static_cast<khtml::RenderText *
>(n);
6189 for (khtml::InlineTextBox* box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
6190 if (box->m_y == y && textRenderer->element()) {
6191 endNode = textRenderer->element();
6192 endOffset = box->m_start + box->m_len;
6198 if (n == renderNode) {
6202 n = n->previousSibling();
6208 QMouseEvent *mouse =
event->qmouseEvent();
6209 DOM::Node innerNode =
event->innerNode();
6213 if (mouse->button() == Qt::LeftButton && !innerNode.
isNull() && innerNode.
handle()->renderer() &&
6214 innerNode.
handle()->renderer()->shouldSelect()) {
6215 Position pos(innerNode.
handle()->positionForCoordinates(event->
x(),
event->y()).position());
6216 if (pos.node() && (pos.node()->nodeType() == Node::TEXT_NODE || pos.node()->nodeType() == Node::CDATA_SECTION_NODE)) {
6217 selection.moveTo(pos);
6218 selection.expandUsingGranularity(Selection::WORD);
6222 if (selection.state() != Selection::CARET) {
6223 d->editor_context.beginSelectingText(Selection::WORD);
6226 setCaret(selection);
6232 QMouseEvent *mouse =
event->qmouseEvent();
6233 DOM::Node innerNode =
event->innerNode();
6237 if (mouse->button() == Qt::LeftButton && !innerNode.
isNull() && innerNode.
handle()->renderer() &&
6238 innerNode.
handle()->renderer()->shouldSelect()) {
6239 Position pos(innerNode.
handle()->positionForCoordinates(event->
x(),
event->y()).position());
6240 if (pos.node() && (pos.node()->nodeType() == Node::TEXT_NODE || pos.node()->nodeType() == Node::CDATA_SECTION_NODE)) {
6241 selection.moveTo(pos);
6242 selection.expandUsingGranularity(Selection::LINE);
6246 if (selection.state() != Selection::CARET) {
6247 d->editor_context.beginSelectingText(Selection::LINE);
6250 setCaret(selection);
6256 QMouseEvent *mouse =
event->qmouseEvent();
6257 DOM::Node innerNode =
event->innerNode();
6259 if (mouse->button() == Qt::LeftButton) {
6262 if (!innerNode.
isNull() && innerNode.
handle()->renderer() &&
6263 innerNode.
handle()->renderer()->shouldSelect()) {
6264 bool extendSelection = mouse->modifiers() & Qt::ShiftModifier;
6271 Position pos(innerNode.
handle()->positionForCoordinates(event->
x(),
event->y()).position());
6273 pos = Position(innerNode.
handle(), innerNode.
handle()->caretMinOffset());
6274 kDebug(6050) <<
event->x() <<
event->y() << pos << endl;
6277 if (extendSelection && sel.notEmpty()) {
6278 sel.clearModifyBias();
6280 if (
d->editor_context.m_selectionGranularity != Selection::CHARACTER) {
6281 sel.expandUsingGranularity(
d->editor_context.m_selectionGranularity);
6283 d->editor_context.m_beganSelectingText =
true;
6286 d->editor_context.m_selectionGranularity = Selection::CHARACTER;
6298 QMouseEvent *_mouse =
event->qmouseEvent();
6299 DOM::Node innerNode =
event->innerNode();
6300 d->m_mousePressNode = innerNode;
6302 d->m_dragStartPos = QPoint(event->
x(),
event->y());
6305 d->m_strSelectedURL =
event->url().string();
6306 d->m_strSelectedURLTarget =
event->target().string();
6309 d->m_strSelectedURL.clear();
6310 d->m_strSelectedURLTarget.clear();
6313 if ( _mouse->button() == Qt::LeftButton ||
6314 _mouse->button() == Qt::MidButton )
6316 d->m_bMousePressed =
true;
6318 #ifdef KHTML_NO_SELECTION 6319 d->m_dragLastPos = _mouse->globalPos();
6321 if ( _mouse->button() == Qt::LeftButton )
6323 if ( (!
d->m_strSelectedURL.isNull() && !
isEditable())
6324 || (!
d->m_mousePressNode.isNull() &&
d->m_mousePressNode.elementId() == ID_IMG) )
6327 d->editor_context.m_beganSelectingText =
false;
6329 handleMousePressEventSingleClick(event);
6334 if ( _mouse->button() == Qt::RightButton )
6343 QMouseEvent *_mouse =
event->qmouseEvent();
6344 if ( _mouse->button() == Qt::LeftButton )
6346 d->m_bMousePressed =
true;
6347 d->editor_context.m_beganSelectingText =
false;
6350 handleMousePressEventDoubleClick(event);
6355 handleMousePressEventTripleClick(event);
6361 #ifndef KHTML_NO_SELECTION 6362 bool KHTMLPart::isExtendingSelection()
const 6367 return d->editor_context.m_beganSelectingText;
6370 void KHTMLPart::extendSelectionTo(
int x,
int y,
const DOM::Node &innerNode)
6373 Position pos(innerNode.
handle()->positionForCoordinates(x, y).position());
6381 Selection sel = caret();
6382 sel.clearModifyBias();
6383 if (!
d->editor_context.m_beganSelectingText) {
6386 d->editor_context.beginSelectingText(Selection::CHARACTER);
6391 if (
d->editor_context.m_selectionGranularity != Selection::CHARACTER) {
6392 sel.expandUsingGranularity(
d->editor_context.m_selectionGranularity);
6397 #endif // KHTML_NO_SELECTION 6401 #ifdef QT_NO_DRAGANDDROP 6407 if( (
d->m_bMousePressed &&
6408 ( (!
d->m_strSelectedURL.isEmpty() && !
isEditable())
6409 || (!
d->m_mousePressNode.isNull() &&
d->m_mousePressNode.elementId() == ID_IMG) ) )
6413 DOM::NodeImpl* innerNodeImpl =
event->innerNode().handle();
6416 HTMLImageElementImpl *img = 0L;
6423 if (url.
isEmpty() && innerNodeImpl && innerNodeImpl->id() == ID_IMG)
6425 img =
static_cast<HTMLImageElementImpl *
>(innerNodeImpl);
6426 u =
completeURL(img->getAttribute(ATTR_SRC).parsedUrl().string());
6438 QDrag *drag =
new QDrag(
d->m_view->viewport() );
6440 if ( !
d->m_referrer.isEmpty() )
6441 metaDataMap.insert(
"referrer",
d->m_referrer );
6442 QMimeData* mimeData =
new QMimeData();
6444 drag->setMimeData( mimeData );
6446 if( img && img->complete() )
6447 drag->mimeData()->setImageData( img->currentImage() );
6449 if ( !pix.isNull() )
6450 drag->setPixmap( pix );
6456 d->m_bMousePressed =
false;
6457 d->m_strSelectedURL.clear();
6458 d->m_strSelectedURLTarget.clear();
6462 #endif // QT_NO_DRAGANDDROP 6468 if (
d->m_bMousePressed )
return false;
6476 QMouseEvent *_mouse =
event->qmouseEvent();
6477 DOM::Node innerNode =
event->innerNode();
6479 bool shiftPressed = ( _mouse->modifiers() & Qt::ShiftModifier );
6484 HTMLImageElementImpl *i =
static_cast<HTMLImageElementImpl *
>(innerNode.
handle());
6485 if ( i && i->isServerMap() )
6487 khtml::RenderObject *r = i->renderer();
6491 r->absolutePosition(absx, absy);
6492 int x(event->
x() - absx), y(event->
y() - absy);
6494 d->m_overURL = url.
string() + QString(
"?%1,%2").arg(x).arg(y);
6495 d->m_overURLTarget = target.
string();
6496 overURL(
d->m_overURL, target.
string(), shiftPressed );
6503 if (
d->m_overURL.isEmpty() ||
d->m_overURL != url ||
d->m_overURLTarget != target )
6506 d->m_overURLTarget = target.
string();
6507 overURL(
d->m_overURL, target.
string(), shiftPressed );
6512 if( !
d->m_overURL.isEmpty() )
6524 if (!
d->m_bMousePressed)
6527 #ifdef KHTML_NO_SELECTION 6528 if (
d->m_doc &&
d->m_view) {
6529 QPoint diff( mouse->globalPos() -
d->m_dragLastPos );
6531 if (abs(diff.x()) > 64 || abs(diff.y()) > 64) {
6532 d->m_view->scrollBy(-diff.x(), -diff.y());
6533 d->m_dragLastPos = mouse->globalPos();
6538 QMouseEvent *mouse =
event->qmouseEvent();
6539 DOM::Node innerNode =
event->innerNode();
6541 if ( (mouse->buttons() & Qt::LeftButton) == 0 || !innerNode.
handle() || !innerNode.
handle()->renderer() ||
6542 !innerNode.
handle()->renderer()->shouldSelect())
6546 extendSelectionTo(event->
x(),
event->y(), innerNode);
6547 #endif // KHTML_NO_SELECTION 6552 if (handleMouseMoveEventDrag(event))
6555 if (handleMouseMoveEventOver(event))
6558 handleMouseMoveEventSelection(event);
6563 DOM::Node innerNode =
event->innerNode();
6566 if (
d->m_bMousePressed ) {
6567 setStatusBarText(QString(), BarHoverText);
6573 d->m_bMousePressed =
false;
6575 #ifndef QT_NO_CLIPBOARD 6576 QMouseEvent *_mouse =
event->qmouseEvent();
6578 kDebug( 6050 ) <<
"MMB shouldOpen=" <<
d->m_bOpenMiddleClick;
6580 if (
d->m_bOpenMiddleClick) {
6588 #ifndef KHTML_NO_SELECTION 6594 if (!
d->editor_context.m_beganSelectingText
6595 &&
d->m_dragStartPos.x() ==
event->x()
6596 &&
d->m_dragStartPos.y() ==
event->y()
6597 &&
d->editor_context.m_selection.state() == Selection::RANGE) {
6599 #ifdef APPLE_CHANGES 6600 if (
d->editor_context.m_selection.base().node()->isContentEditable())
6602 selection.moveTo(
d->editor_context.m_selection.base().node()->positionForCoordinates(event->
x(),
event->y()).position());
6603 setCaret(selection);
6606 #ifndef QT_NO_CLIPBOARD 6608 text.replace(QChar(0xa0),
' ');
6609 if (!text.isEmpty()) {
6610 disconnect( qApp->clipboard(), SIGNAL(
selectionChanged()),
this, SLOT(slotClearSelection()));
6611 qApp->clipboard()->setText(text,QClipboard::Selection);
6612 connect( qApp->clipboard(), SIGNAL(
selectionChanged()), SLOT(slotClearSelection()));
6616 emitSelectionChanged();
6630 emitSelectionChanged();
6631 emit
d->m_extension->enableAction(
"print",
d->m_doc != 0 );
6633 if ( !
d->m_settings->autoLoadImages() &&
d->m_paLoadImages )
6636 lst.append(
d->m_paLoadImages );
6642 void KHTMLPart::slotPrintFrame()
6644 if (
d->m_frames.count() == 0 )
6657 const QMetaObject *mo = ext->metaObject();
6660 if (mo->indexOfSlot(
"print()") != -1)
6661 QMetaObject::invokeMethod(ext,
"print()", Qt::DirectConnection);
6664 void KHTMLPart::slotSelectAll()
6667 if (part && part->inherits(
"KHTMLPart"))
6668 static_cast<KHTMLPart *>(part)->selectAll();
6671 void KHTMLPart::startAutoScroll()
6673 connect(&
d->m_scrollTimer, SIGNAL(
timeout()),
this, SLOT(slotAutoScroll()));
6674 d->m_scrollTimer.setSingleShot(
false);
6675 d->m_scrollTimer.start(100);
6678 void KHTMLPart::stopAutoScroll()
6680 disconnect(&
d->m_scrollTimer, SIGNAL(
timeout()),
this, SLOT(slotAutoScroll()));
6681 if (
d->m_scrollTimer.isActive())
6682 d->m_scrollTimer.stop();
6686 void KHTMLPart::slotAutoScroll()
6689 d->m_view->doAutoScroll();
6694 void KHTMLPart::runAdFilter()
6702 QSetIterator<khtml::CachedObject*> it(
d->m_doc->docLoader()->m_docObjects );
6703 while (it.hasNext())
6705 khtml::CachedObject* obj = it.next();
6706 if ( obj->type() == khtml::CachedObject::Image ) {
6707 khtml::CachedImage *image =
static_cast<khtml::CachedImage *
>(obj);
6708 bool wasBlocked = image->m_wasBlocked;
6710 if ( image->m_wasBlocked != wasBlocked )
6711 image->do_notify(QRect(QPoint(0,0), image->pixmap_size()));
6716 for ( NodeImpl *nextNode, *node =
d->m_doc; node; node = nextNode ) {
6719 nextNode = node->traverseNextNode();
6721 if ( node->id() == ID_IMG ||
6722 node->id() == ID_IFRAME ||
6723 (node->id() == ID_INPUT &&
static_cast<HTMLInputElementImpl *
>(node)->inputType() == HTMLInputElementImpl::IMAGE ))
6729 while (nextNode && nextNode->isAncestor(node))
6730 nextNode = nextNode->traverseNextNode();
6733 NodeImpl *parent = node->parent();
6737 parent->removeChild(node, exception);
6748 if (!
d->m_doc)
return;
6751 if (
d->m_doc->isHTMLDocument())
6752 first = static_cast<HTMLDocumentImpl*>(
d->m_doc)->body();
6759 while ( first && !(first->renderer()
6760 && ((first->nodeType() == Node::TEXT_NODE || first->nodeType() == Node::CDATA_SECTION_NODE)
6761 || (first->renderer()->isReplaced() && !first->renderer()->firstChild()))))
6763 next = first->firstChild();
6764 if ( !next ) next = first->nextSibling();
6765 while( first && !next )
6767 first = first->parentNode();
6769 next = first->nextSibling();
6775 if (
d->m_doc->isHTMLDocument())
6776 last = static_cast<HTMLDocumentImpl*>(
d->m_doc)->body();
6783 while ( last && !(last->renderer()
6784 && ((last->nodeType() == Node::TEXT_NODE || last->nodeType() == Node::CDATA_SECTION_NODE)
6785 || (last->renderer()->isReplaced() && !last->renderer()->lastChild()))))
6787 next = last->lastChild();
6788 if ( !next ) next = last->previousSibling();
6789 while ( last && !next )
6791 last = last->parentNode();
6793 next = last->previousSibling();
6798 if ( !first || !last )
6800 Q_ASSERT(first->renderer());
6801 Q_ASSERT(last->renderer());
6802 d->editor_context.m_selection.moveTo(Position(first, 0), Position(last, last->nodeValue().length()));
6803 d->m_doc->updateSelection();
6805 emitSelectionChanged();
6810 bool linkAllowed =
true;
6815 if ( !linkAllowed ) {
6816 khtml::Tokenizer *tokenizer =
d->m_doc->tokenizer();
6818 tokenizer->setOnHold(
true);
6826 i18n(
"Security Warning" ),
6835 i18n(
"<qt>Access by untrusted page to<br /><b>%1</b><br /> denied.</qt>", Qt::escape(linkURL.
prettyUrl())),
6836 i18n(
"Security Alert" ));
6840 tokenizer->setOnHold(
false);
6849 if ( part ==
d->m_activeFrame )
6851 d->m_activeFrame = 0L;
6852 if ( !part->inherits(
"KHTMLPart" ) )
6864 void KHTMLPart::slotActiveFrameChanged(
KParts::Part *part )
6869 kError(6050) <<
"strange error! we activated ourselves";
6874 if (
d->m_activeFrame &&
d->m_activeFrame->widget() &&
d->m_activeFrame->widget()->inherits(
"QFrame" ) )
6876 QFrame *frame =
static_cast<QFrame *
>(
d->m_activeFrame->widget() );
6877 if (frame->frameStyle() != QFrame::NoFrame)
6879 frame->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken);
6884 if(
d->m_activeFrame && !
d->m_activeFrame->inherits(
"KHTMLPart" ) )
6891 if( part && !part->inherits(
"KHTMLPart" ) )
6900 d->m_activeFrame = part;
6902 if (
d->m_activeFrame &&
d->m_activeFrame->widget()->inherits(
"QFrame" ) )
6904 QFrame *frame =
static_cast<QFrame *
>(
d->m_activeFrame->widget() );
6905 if (frame->frameStyle() != QFrame::NoFrame)
6907 frame->setFrameStyle( QFrame::StyledPanel | QFrame::Plain);
6910 kDebug(6050) <<
"new active frame " <<
d->m_activeFrame;
6921 if (!
d->m_doc || !
d->m_view)
6925 d->m_doc->setFocusNode(node.
handle());
6928 QRect rect = node.
handle()->getRect();
6929 d->m_view->ensureVisible(rect.right(), rect.bottom());
6930 d->m_view->ensureVisible(rect.left(), rect.top());
6935 return DOM::Node(
d->m_doc?
d->m_doc->focusNode():0);
6938 DOM::EventListener *KHTMLPart::createHTMLEventListener( QString code, QString
name, NodeImpl* node,
bool svg )
6945 return proxy->createHTMLEventHandler(
url().
url(), name, code, node, svg );
6953 void KHTMLPart::setOpener(
KHTMLPart *_opener)
6955 d->m_opener = _opener;
6958 bool KHTMLPart::openedByJS()
6960 return d->m_openedByJS;
6963 void KHTMLPart::setOpenedByJS(
bool _openedByJS)
6965 d->m_openedByJS = _openedByJS;
6970 khtml::Cache::preloadStyleSheet(url, stylesheet);
6975 khtml::Cache::preloadScript(url, script);
6978 long KHTMLPart::cacheId()
const 6980 return d->m_cacheId;
6985 return d->m_restored;
6995 return d->m_pluginPageQuestionAsked.contains(mimetype);
7003 d->m_pluginPageQuestionAsked.append(mimetype);
7009 if( !
d->m_encoding.isNull() )
7010 dec->
setEncoding(
d->m_encoding.toLatin1().constData(),
7020 d->m_doc->setDecoder(dec);
7025 void KHTMLPart::emitCaretPositionChanged(
const DOM::Position &pos) {
7027 Position rng_pos = pos.equivalentRangeCompliantPosition();
7028 Node node = rng_pos.node();
7032 void KHTMLPart::restoreScrollPosition()
7036 if (
url().hasRef() && !
d->m_restoreScrollPosition && !args.
reload()) {
7037 if ( !
d->m_doc || !
d->m_doc->parsing() )
7038 disconnect(
d->m_view, SIGNAL(finishedLayout()),
this, SLOT(restoreScrollPosition()));
7048 if (
d->m_view->contentsHeight() -
d->m_view->visibleHeight() >= args.
yOffset()
7049 ||
d->m_bComplete) {
7051 disconnect(
d->m_view, SIGNAL(finishedLayout()),
this, SLOT(restoreScrollPosition()));
7056 void KHTMLPart::openWallet(DOM::HTMLFormElementImpl *form)
7058 #ifndef KHTML_NO_WALLET 7065 p->openWallet(form);
7074 if (
d->m_bWalletOpened) {
7075 if (
d->m_wallet->isOpen()) {
7076 form->walletOpened(
d->m_wallet);
7079 d->m_wallet->deleteLater();
7081 d->m_bWalletOpened =
false;
7088 d->m_wq->wallet = wallet;
7089 connect(wallet, SIGNAL(walletOpened(
bool)),
d->m_wq, SLOT(walletOpened(
bool)));
7094 #endif // KHTML_NO_WALLET 7100 #ifndef KHTML_NO_WALLET 7107 p->saveToWallet(key, data);
7112 if (
d->m_bWalletOpened) {
7113 if (
d->m_wallet->isOpen()) {
7118 d->m_wallet->writeMap(key, data);
7121 d->m_wallet->deleteLater();
7123 d->m_bWalletOpened =
false;
7130 d->m_wq->wallet = wallet;
7131 connect(wallet, SIGNAL(walletOpened(
bool)),
d->m_wq, SLOT(walletOpened(
bool)));
7134 d->m_wq->savers.append(qMakePair(key, data));
7135 #endif // KHTML_NO_WALLET 7139 void KHTMLPart::dequeueWallet(DOM::HTMLFormElementImpl *form) {
7140 #ifndef KHTML_NO_WALLET 7147 p->dequeueWallet(form);
7154 #endif // KHTML_NO_WALLET 7159 #ifndef KHTML_NO_WALLET 7163 d->m_wq->deleteLater();
7167 d->m_bWalletOpened =
false;
7171 d->m_wallet = wallet;
7172 d->m_bWalletOpened =
true;
7173 connect(
d->m_wallet, SIGNAL(walletClosed()), SLOT(slotWalletClosed()));
7174 d->m_walletForms.clear();
7175 if (!
d->m_statusBarWalletLabel) {
7176 d->m_statusBarWalletLabel =
new KUrlLabel(
d->m_statusBarExtension->statusBar());
7177 d->m_statusBarWalletLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum));
7178 d->m_statusBarWalletLabel->setUseCursor(
false);
7179 d->m_statusBarExtension->addStatusBarItem(
d->m_statusBarWalletLabel, 0,
false);
7180 d->m_statusBarWalletLabel->setPixmap(
SmallIcon(
"wallet-open"));
7181 connect(
d->m_statusBarWalletLabel, SIGNAL(leftClickedUrl()), SLOT(launchWalletManager()));
7182 connect(
d->m_statusBarWalletLabel, SIGNAL(rightClickedUrl()), SLOT(walletMenu()));
7185 #endif // KHTML_NO_WALLET 7191 #ifndef KHTML_NO_WALLET 7203 #endif // !KHTML_NO_WALLET 7207 void KHTMLPart::slotWalletClosed()
7209 #ifndef KHTML_NO_WALLET 7211 d->m_wallet->deleteLater();
7214 d->m_bWalletOpened =
false;
7215 if (
d->m_statusBarWalletLabel) {
7216 d->m_statusBarExtension->removeStatusBarItem(
d->m_statusBarWalletLabel);
7217 delete d->m_statusBarWalletLabel;
7218 d->m_statusBarWalletLabel = 0L;
7220 #endif // KHTML_NO_WALLET 7223 void KHTMLPart::launchWalletManager()
7225 #ifndef KHTML_NO_WALLET 7226 QDBusInterface r(
"org.kde.kwalletmanager",
"/kwalletmanager/MainWindow_1",
7227 "org.kde.KMainWindow");
7231 r.call(QDBus::NoBlock,
"show");
7232 r.call(QDBus::NoBlock,
"raise");
7234 #endif // KHTML_NO_WALLET 7237 void KHTMLPart::walletMenu()
7239 #ifndef KHTML_NO_WALLET 7241 QActionGroup *menuActionGroup =
new QActionGroup(menu);
7242 connect( menuActionGroup, SIGNAL(triggered(
QAction*)),
this, SLOT(removeStoredPasswordForm(
QAction*)) );
7244 menu->addAction(
i18n(
"&Close Wallet"),
this, SLOT(slotWalletClosed()));
7246 if (
d->m_view &&
d->m_view->nonPasswordStorableSite(
toplevelURL().host())) {
7247 menu->addAction(
i18n(
"&Allow storing passwords for this site"),
this, SLOT(delNonPasswordStorableSite()));
7251 for ( QStringList::ConstIterator it =
d->m_walletForms.constBegin(); it !=
d->m_walletForms.constEnd(); ++it ) {
7253 action->setActionGroup(menuActionGroup);
7255 action->setData(var);
7259 menu->popup(QCursor::pos());
7260 #endif // KHTML_NO_WALLET 7265 #ifndef KHTML_NO_WALLET 7268 QVariant var(action->data());
7273 QString key = var.toString();
7284 if (
d->m_wallet->removeEntry(key))
7287 d->m_walletForms.removeAll(key);
7288 #endif // KHTML_NO_WALLET 7291 void KHTMLPart::addWalletFormKey(
const QString& walletFormKey)
7293 #ifndef KHTML_NO_WALLET 7296 parentPart()->addWalletFormKey(walletFormKey);
7300 if(!
d->m_walletForms.contains(walletFormKey))
7301 d->m_walletForms.append(walletFormKey);
7302 #endif // KHTML_NO_WALLET 7305 void KHTMLPart::delNonPasswordStorableSite()
7307 #ifndef KHTML_NO_WALLET 7309 d->m_view->delNonPasswordStorableSite(
toplevelURL().host());
7310 #endif // KHTML_NO_WALLET 7312 void KHTMLPart::saveLoginInformation(
const QString& host,
const QString& key,
const QMap<QString, QString>& walletMap)
7314 #ifndef KHTML_NO_WALLET 7315 d->m_storePass.saveLoginInformation(host, key, walletMap);
7316 #endif // KHTML_NO_WALLET 7319 void KHTMLPart::slotToggleCaretMode()
7325 d->m_formNotification = fn;
7329 return d->m_formNotification;
7349 return d->m_doc->unsubmittedFormChanges();
7352 void KHTMLPart::setDebugScript(
bool enable )
7356 if (!
d->m_paDebugScript) {
7357 d->m_paDebugScript =
new KAction(
i18n(
"JavaScript &Debugger" ),
this );
7359 connect(
d->m_paDebugScript, SIGNAL(triggered(
bool)),
this, SLOT(slotDebugScript()) );
7361 d->m_paDebugScript->setEnabled(
d->m_frame ?
d->m_frame->m_jscript : 0L );
7363 lst.append(
d->m_paDebugScript );
7366 d->m_bJScriptDebugEnabled = enable;
7376 if ( enable && originPart ) {
7377 d->m_openableSuppressedPopups++;
7378 if (
d->m_suppressedPopupOriginParts.indexOf( originPart ) == -1 )
7379 d->m_suppressedPopupOriginParts.append( originPart );
7382 if ( enable && !
d->m_statusBarPopupLabel ) {
7383 d->m_statusBarPopupLabel =
new KUrlLabel(
d->m_statusBarExtension->statusBar() );
7384 d->m_statusBarPopupLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ));
7385 d->m_statusBarPopupLabel->setUseCursor(
false );
7386 d->m_statusBarExtension->addStatusBarItem(
d->m_statusBarPopupLabel, 0,
false );
7387 d->m_statusBarPopupLabel->setPixmap(
SmallIcon(
"window-suppressed") );
7389 d->m_statusBarPopupLabel->setToolTip(
i18n(
"This page was prevented from opening a new window via JavaScript." ) );
7391 connect(
d->m_statusBarPopupLabel, SIGNAL(leftClickedUrl()), SLOT(suppressedPopupMenu()));
7392 if (
d->m_settings->jsPopupBlockerPassivePopup()) {
7395 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);
7397 }
else if ( !enable &&
d->m_statusBarPopupLabel ) {
7398 d->m_statusBarPopupLabel->setToolTip(
"" );
7399 d->m_statusBarExtension->removeStatusBarItem(
d->m_statusBarPopupLabel );
7400 delete d->m_statusBarPopupLabel;
7401 d->m_statusBarPopupLabel = 0L;
7405 void KHTMLPart::suppressedPopupMenu() {
7407 if (
d->m_openableSuppressedPopups )
7408 m->addAction(
i18np(
"&Show Blocked Popup Window",
"&Show %1 Blocked Popup Windows",
d->m_openableSuppressedPopups),
this, SLOT(showSuppressedPopups()));
7409 QAction *a = m->addAction(
i18n(
"Show Blocked Window Passive Popup &Notification"),
this, SLOT(togglePopupPassivePopup()));
7410 a->setChecked(
d->m_settings->jsPopupBlockerPassivePopup());
7411 m->addAction(
i18n(
"&Configure JavaScript New Window Policies..."),
this, SLOT(launchJSConfigDialog()));
7412 m->popup(QCursor::pos());
7415 void KHTMLPart::togglePopupPassivePopup() {
7417 d->m_settings->setJSPopupBlockerPassivePopup( !
d->m_settings->jsPopupBlockerPassivePopup() );
7421 void KHTMLPart::showSuppressedPopups() {
7422 foreach (
KHTMLPart* part,
d->m_suppressedPopupOriginParts ) {
7424 KJS::Window *w = KJS::Window::retrieveWindow( part );
7426 w->showSuppressedWindows();
7427 w->forgetSuppressedWindows();
7432 d->m_openableSuppressedPopups = 0;
7433 d->m_suppressedPopupOriginParts.clear();
7438 QString KHTMLPart::defaultExtension()
const 7442 if ( !
d->m_doc->isHTMLDocument() )
7444 return d->m_doc->htmlMode() == DOM::DocumentImpl::XHtml ?
".xhtml" :
".html";
7449 if (!
d->m_bComplete ||
d->m_runningScripts || (
d->m_doc &&
d->m_doc->parsing()))
7455 for (; it !=
end; ++it ) {
7456 if ((*it)->m_run || !(*it)->m_bCompleted)
7460 return d->m_submitForm || !
d->m_redirectURL.isEmpty() ||
d->m_redirectionTimer.isActive() ||
d->m_job;
7464 #include "khtml_part.moc" 7465 #include "khtmlpart_p.moc" 7466 #ifndef KHTML_NO_WALLET 7467 #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)
bool isHideAdsEnabled() const
QString m_ssl_cert_errors
Settings for the HTML view.
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())
bool metaRefreshEnabled() const
Returns true if automatic forwarding is enabled.
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.
KSelectAction * m_paUseStylesheet
void setSelection(const DOM::Range &)
Sets the current selection.
static ScriptableExtension * childObject(QObject *obj)
void setLockHistory(bool lock)
QString documentSource() const
Returns the content of the source document.
MimeType classifyMimeType(const QString &mime)
DOM::DocumentImpl * m_doc
unsigned int m_jobPercent
bool nextAnchor()
Go to the next anchor.
QString referrer() const
Referrer used for links in this page.
QString getCacheControlString(KIO::CacheControl cacheControl)
void associateWidget(QWidget *widget) const
static const int sDNSPrefetchTimerDelay
DNSPrefetch dnsPrefetch() const
Returns currently set DNS prefetching mode.
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))
KUrl completeURL(const QString &url)
returns a KUrl object for the given url.
static List split(const QString &_url)
QCursor urlCursor() const
Returns the cursor which is used when the cursor is on a link.
void addMetaData(const QString &key, const QString &value)
The Node interface is the primary datatype for the entire Document Object Model.
bool isJavaScriptDebugEnabled(const QString &hostname=QString()) const
KAction * m_paStopAnimations
virtual KActionCollection * actionCollection() const
KToggleAction * m_paToggleCaretMode
DOMString nodeName() const
The name of this node, depending on its type; see the table above.
bool autoloadImages() const
Returns whether images contained in the document are loaded automatically or not. ...
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
QStringList m_walletForms
long startOffset() const
Offset within the starting node of the range.
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".
QString lastModified() const
Last-modified date (in raw string format), if received in the [HTTP] headers.
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)
bool pluginsEnabled() const
Returns true if plugins are enabled, false if disabled.
unsigned long m_totalObjectCount
static const KComponentData & componentData()
KParts::OpenUrlArguments m_args
void removeClient(KXMLGUIClient *client)
static bool test(const QEvent *event)
KUrlLabel * m_statusBarUALabel
const QByteArray encoding() const
static QString userAgentForHost(const QString &hostname)
void removeChildClient(KXMLGUIClient *child)
KLocalizedString ki18n(const char *msg)
void setJSStatusBarText(const QString &text)
Called by KJS.
QWeakPointer< KHTMLRun > m_run
KStatusBar * statusBar() const
QString i18np(const char *sing, const char *plur, const A1 &a1)
KParts::BrowserArguments m_browserArgs
static const int zoomSizeCount
bool onlyLocalReferences() const
Returns whether only file:/ or data:/ references are allowed to be loaded ( default false )...
bool isPointInsideSelection(int x, int y)
Returns whether the given point is inside the current selection.
MimetypeJob * mimetype(const KUrl &url, JobFlags flags=DefaultFlags)
QString encodedHtmlRef() 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)
KEncodingDetector * m_decoder
DOM::DOMString url() const
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)
bool autoLoadImages() 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)
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)
Node endContainer() const
Node within which the range ends.
void setRef(const QString &fragment)
void setPluginsEnabled(bool enable)
Enables or disables plugins, default is enabled.
bool visuallyOrdered() const
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
RangeImpl * handle() const
StatJob * stat(const KUrl &url, JobFlags flags=DefaultFlags)
bool isJavaEnabled(const QString &hostname=QString()) const
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)
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) const
KXMLGUIFactory * factory() const
NamedNodeMap attributes() const
A NamedNodeMap containing the attributes of this node (if it is an Element ) or null otherwise...
friend class KHTMLPartBrowserHostExtension
void setUrl(const KUrl &url)
DOM::Node activeNode() const
Returns the node that has the keyboard focus.
KAction * m_paSaveBackground
DOM::Range selection() const
Returns the selected part of the HTML.
bool isJavaScriptEnabled(const QString &hostname=QString()) const
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()
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)
void populateMimeData(QMimeData *mimeData, const MetaDataMap &metaData=MetaDataMap(), MimeDataFlags flags=DefaultMimeDataFlags) const
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)
KSmoothScrollingMode smoothScrolling() const
KHTMLPartBrowserHostExtension * m_hostExtension
KHTMLPart * findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame, bool checkForNavigation)
QString indent(QString text, int spaces)
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.
virtual void khtmlMouseReleaseEvent(khtml::MouseReleaseEvent *event)
Eventhandler for the khtml::MouseMouseReleaseEvent.
bool run(const KUrl &_url, bool _is_local)
bool canNavigate(KParts::ReadOnlyPart *b)
BrowserArguments browserArguments() const
DOM::Node nodeUnderMouse() const
Returns the Node currently under the mouse.
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.
const QString & encoding() const
QString i18nc(const char *ctxt, const char *text)
virtual void customEvent(QEvent *event)
KSharedConfigPtr config()
QPointer< KHTMLViewBar > m_topViewBar
void setOnlyLocalReferences(bool enable)
Security option.
void setPath(const QString &path)
bool warnOnUnencrypted() const
KCodecAction * m_paSetEncoding
JobUiDelegate * ui() const
KSelectAction * m_paDecZoomFactor
friend class KHTMLPartBrowserExtension
FormNotification formNotification() const
Determine if signal should be emitted before, instead or never when a submitForm() happens...
static void deregisterPart(KHTMLPart *part)
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 ...
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)
KParts::BrowserHostExtension * browserHostExtension() const
KHTMLView * view() const
Returns a pointer to the HTML document's view.
KHTMLPart * part() const
Returns a pointer to the KHTMLPart that is rendering the page.
bool isDetached() const
not part of the DOM true if the range is detached
QPointer< KHTMLView > m_view
bool statusMessagesEnabled() const
Returns true if status messages are enabled.
QList< KParts::ReadOnlyPart * > frames() const
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 ...
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 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)
void enableAction(const char *name, bool enabled)
virtual QString errorString() const
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
QString errorString() const
void removeStatusBarItem(QWidget *widget)
Node parentNode() const
The parent of this node.
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
bool forcePermitLocalImages() const
If true, local image files will be loaded even when forbidden by the Kiosk/KAuthorized policies ( def...
long long numberValue(uint field, long long defaultValue=0) const
virtual void khtmlMousePressEvent(khtml::MousePressEvent *event)
Eventhandler of the khtml::MousePressEvent.
void canceled(const QString &errMsg)
DOM::Editor * editor() const
Returns the instance of the attached html editor interface.
long options() const
Returns the state of the options.
void setURLCursor(const QCursor &c)
Sets the cursor to use when the cursor is on a link.
QString jsDefaultStatusBarText() const
Called by KJS.
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.
KParts::BrowserExtension * browserExtension() const
Returns a pointer to the KParts::BrowserExtension.
void setWarnOnUnencrypted(bool x)
bool isAdFiltered(const QString &url) const
tests whether url is filtered.
static BrowserExtension * childObject(QObject *obj)
QString pageReferrer() const
Referrer used to obtain this page.
KService::List query(const QString &mimeType, const QString &genericServiceType=QString::fromLatin1("Application"), const QString &constraint=QString()) const
void setItems(const QStringList &lst)
static int s_DOMTreeIndentLevel
virtual ~KHTMLPart()
Destructor.
void preloadScript(const QString &url, const QString &script)
Loads a script into the script cache.
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()
bool isNull() const
tests if this Node is 0.
QString m_statusBarText[3]
This class implements the basic string we use in the DOM.
bool gotoAnchor(const QString &name)
Finds the anchor named name.
QString selectedTextAsHTML() const
Return the text the user has marked.
DOMString nodeValue() const
The value of this node, depending on its type; see the table above.
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())
virtual void khtmlMouseMoveEvent(khtml::MouseMoveEvent *event)
Eventhandler for the khtml::MouseMouseMoveEvent.
const int KDE_NO_EXPORT fastZoomSizeCount
static const QString FormDataFolder()
QString path(AdjustPathOption trailing=LeaveTrailingSlash) const
void setFontScaleFactor(int percent)
Sets the scale factor to be applied to fonts.
virtual bool openFile()
Internal empty reimplementation of KParts::ReadOnlyPart::openFile .
virtual void write(const char *str, int len=-1)
Writes another part of the HTML code to the widget.
KJobUiDelegate * uiDelegate() 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()
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()
void infoMessage(const QString &)
Node startContainer() const
Node within which the range begins.
virtual void guiActivateEvent(KParts::GUIActivateEvent *event)
Internal reimplementation of KParts::Part::guiActivateEvent .
virtual Part * activePart() const
long endOffset() const
Offset within the ending node of the range.
bool prevAnchor()
Go to previous anchor.
void loadingProgress(int percent)
KAction * next(const QObject *recvr, const char *slot, QObject *parent)
KAnimationAdvice showAnimations() 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()
bool jsErrorsEnabled() const
void setStatusMessagesEnabled(bool enable)
Enable/disable statusbar messages.
void setStandardFont(const QString &name)
Sets the standard font style.
Node firstChild() const
The first child of this node.
OpenUrlArguments arguments() const
void setSuppressedPopupIndicator(bool enable, KHTMLPart *originPart=0)
Shows or hides the suppressed popup indicator.
void setForcesNewWindow(bool forcesNewWindow)
static bool test(const QEvent *event)
QString jsStatusBarText() const
Called by KJS.
static bool isJavaScriptURL(const QString &url)
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)
virtual void setWidget(QWidget *widget)
QString formatDateTime(const QDateTime &dateTime, DateFormat format=ShortDate, bool includeSecs=false) const
int lstat(const QString &path, KDE_struct_stat *buf)
KHTMLFindBar * findBar() const
virtual void addPart(Part *part, bool setActive=true)
void addStatusBarItem(QWidget *widget, int stretch, bool permanent)
QWeakPointer< KParts::BrowserExtension > m_extension
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.
void submitFormProxy(const char *action, const QString &url, const QByteArray &formData, const QString &target, const QString &contentType=QString(), const QString &boundary=QString())
CaretDisplayPolicy caretDisplayPolicyNonFocused() const
Returns the current caret policy when the view is not focused.
Result askEmbedOrSave(int flags=0)
QStringList serviceTypes() const
friend class KHTMLPartPrivate
QString userStyleSheet() const
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.
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.
QAction * action(const char *name) const
int m_numDNSPrefetchedNames
TransferJob * http_post(const KUrl &url, const QByteArray &postData, JobFlags flags=DefaultFlags)
bool isFullyLoaded(bool *pendingRedirections) const
static void setCaretInvisibleIfNeeded(KHTMLPart *part)
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
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.
DOM::Node nonSharedNodeUnderMouse() const
Returns the Node currently under the mouse that is not shared.
virtual void showErrorMessage()
void setCaretDisplayPolicyNonFocused(CaretDisplayPolicy policy)
Sets the caret display policy when the view is not focused.
void findText()
Starts a new search by popping up a dialog asking the user what he wants to search for...
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
KAction * m_paSaveDocument
bool dndEnabled() const
Returns whether Dragn'n'Drop support is enabled or not.
Node getNamedItem(const DOMString &name) const
Retrieves a node specified by name.
void setMimeType(const QString &mime)
bool isEditable() const
Returns true if the document is editable, false otherwise.
void plugActionList(const QString &name, const QList< QAction * > &actionList)
static QString defaultMimeType()
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
QStringList frameNames() const
Returns a list of names of all frame (including iframe) objects of the current document.
QString comment(const KUrl &url=KUrl()) const
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().
bool pluginPageQuestionAsked(const QString &mimetype) const
KAction * zoomIn(const QObject *recvr, const char *slot, QObject *parent)
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
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)
int zoomFactor() const
Returns the current zoom factor.
const char * encoding() const
bool isCaretMode() const
Returns whether caret mode is on/off.
KHTMLSettings * m_settings
static bool keyDoesNotExist(const QString &wallet, const QString &folder, const QString &key)
static StatusBarExtension * childObject(QObject *obj)
static const QString NetworkWallet()
QWeakPointer< DOM::HTMLPartContainerElementImpl > m_partContainerElement
int fontScaleFactor() const
Returns the current font scale factor.
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
void setEditable(bool enable)
Makes the document editable.
bool javaEnabled() const
Return true if Java applet support is enabled, false if disabled.
void setForcePermitLocalImages(bool enable)
Security option.
KLocalizedString subs(int a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const
bool mayPrefetchHostname(const QString &name)
Will pre-resolve name according to dnsPrefetch current settings Returns true if the name will be pre-...
virtual QString selectedText() const
Returns the text the user has marked.
DOM::HTMLDocument htmlDocument() const
Returns a reference to the DOM HTML document (for non-HTML documents, returns null) ...
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)
bool isPluginsEnabled(const QString &hostname=QString()) const
DOM::Document document() const
Returns a reference to the DOM document.
bool jScriptEnabled() const
Returns true if Javascript support is enabled or false otherwise.
static const int sMaxDNSPrefetchPerPage
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
KParts::ReadOnlyPart * currentFrame() const
Return the current frame (the one that has focus) Not necessarily a direct child of ours...
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)
void setLowerWindow(bool lower)
void prefetchHost(const QString &hostName)
void selectAll()
Marks all text in the document as selected.
QString formatNumber(double num, int precision=-1) const
void nodeActivated(const DOM::Node &)
This signal is emitted when an element retrieves the keyboard focus.
quint32 elementId() const
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)
NodeImpl * handle() const
void setPageSecurity(int)
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.
static bool test(const QEvent *event)
static LiveConnectExtension * childObject(QObject *obj)
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()
bool hasSelection() const
Has the user selected anything?
void setJSDefaultStatusBarText(const QString &text)
Called by KJS.
QString encoding() const
Returns the encoding the page currently uses.
KAction * m_paDebugScript
T readEntry(const QString &key, const T &aDefault) const
bool equals(const KUrl &u, const EqualsOptions &options=0) const
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)
bool isAutoDelayedActionsEnabled() const
const KHTMLSettings * settings() const
void unplugActionList(const QString &name)
QString prettyUrl(AdjustPathOption trailing=LeaveTrailingSlash) const
static KUrl join(const List &_list)
Node nextSibling() const
The node immediately following this node.
void renameFrameForContainer(DOM::HTMLPartContainerElementImpl *cont, const QString &newName)
static const int zoomSizes[]
unsigned long m_loadedObjects
QString queryItem(const QString &item) 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.
QString errorText() const
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
KUrl backgroundURL() const
Returns the URL for the background Image (used by save background)
bool is(const QString &mimeTypeName) const
DNSPrefetch
DNS Prefetching Mode enumeration.
bool isModified() const
Checks whether the page contains unsubmitted form changes.
KDNSPrefetch dnsPrefetch() const
unsigned short nodeType() const
A code representing the type of the underlying object, as defined above.