📄 khtml_part.cpp.orig
字号:
KJSProxy *proxy = jScript(); if (!proxy || proxy->paused()) return QVariant(); KJS::Completion comp; QVariant ret = proxy->evaluate(filename, baseLine, script, n, &comp); /* * Error handling */ if (comp.complType() == KJS::Throw && !comp.value().isNull()) { KJSErrorDlg *dlg = jsErrorExtension(); if (dlg) { KJS::UString msg = comp.value().toString(proxy->interpreter()->globalExec()); dlg->addError(i18n("<b>Error</b>: %1: %2").arg(filename, msg.qstring())); } } // Handle immediate redirects now (e.g. location='foo') if ( !d->m_redirectURL.isEmpty() && d->m_delayRedirect == -1 ) { kdDebug(6070) << "executeScript done, handling immediate redirection NOW" << endl; // Must abort tokenizer, no further script must execute. khtml::Tokenizer* t = d->m_doc->tokenizer(); if(t) t->abort(); d->m_redirectionTimer.start( 0, true ); } return ret;}QVariant KHTMLPart::executeScript( const QString &script ){ return executeScript( DOM::Node(), script );}QVariant KHTMLPart::executeScript( const DOM::Node &n, const QString &script ){#ifdef KJS_VERBOSE kdDebug(6070) << "KHTMLPart::executeScript caller='" << name() << "' node=" << n.nodeName().string().latin1() << "(" << (n.isNull() ? 0 : n.nodeType()) << ") " /* << script */ << endl;#endif KJSProxy *proxy = jScript(); if (!proxy || proxy->paused()) return QVariant(); ++(d->m_runningScripts); KJS::Completion comp; const QVariant ret = proxy->evaluate( QString::null, 1, script, n, &comp ); --(d->m_runningScripts); /* * Error handling */ if (comp.complType() == KJS::Throw && !comp.value().isNull()) { KJSErrorDlg *dlg = jsErrorExtension(); if (dlg) { KJS::UString msg = comp.value().toString(proxy->interpreter()->globalExec()); dlg->addError(i18n("<b>Error</b>: node %1: %2").arg(n.nodeName().string()).arg(msg.qstring())); } } if (!d->m_runningScripts && d->m_doc && !d->m_doc->parsing() && d->m_submitForm ) submitFormAgain();#ifdef KJS_VERBOSE kdDebug(6070) << "KHTMLPart::executeScript - done" << endl;#endif return ret;}bool KHTMLPart::scheduleScript(const DOM::Node &n, const QString& script){ //kdDebug(6050) << "KHTMLPart::scheduleScript "<< script << endl; d->scheduledScript = script; d->scheduledScriptNode = n; return true;}QVariant KHTMLPart::executeScheduledScript(){ if( d->scheduledScript.isEmpty() ) return QVariant(); //kdDebug(6050) << "executing delayed " << d->scheduledScript << endl; QVariant ret = executeScript( d->scheduledScriptNode, d->scheduledScript ); d->scheduledScript = QString(); d->scheduledScriptNode = DOM::Node(); return ret;}void KHTMLPart::setJavaEnabled( bool enable ){ d->m_bJavaForce = enable; d->m_bJavaOverride = true;}bool KHTMLPart::javaEnabled() const{ if (onlyLocalReferences()) return false;#ifndef Q_WS_QWS if( d->m_bJavaOverride ) return d->m_bJavaForce; return d->m_bJavaEnabled;#else return false;#endif}KJavaAppletContext *KHTMLPart::javaContext(){ return 0;}KJavaAppletContext *KHTMLPart::createJavaContext(){ return 0;}void KHTMLPart::setPluginsEnabled( bool enable ){ d->m_bPluginsForce = enable; d->m_bPluginsOverride = true;}bool KHTMLPart::pluginsEnabled() const{ if (onlyLocalReferences()) return false; if ( d->m_bPluginsOverride ) return d->m_bPluginsForce; return d->m_bPluginsEnabled;}static int s_DOMTreeIndentLevel = 0;void KHTMLPart::slotDebugDOMTree(){ if ( d->m_doc && d->m_doc->firstChild() ) qDebug("%s", d->m_doc->firstChild()->toString().string().latin1()); // Now print the contents of the frames that contain HTML const int indentLevel = s_DOMTreeIndentLevel++; ConstFrameIt it = d->m_frames.begin(); const ConstFrameIt end = d->m_frames.end(); for (; it != end; ++it ) if ( !( *it )->m_part.isNull() && (*it)->m_part->inherits( "KHTMLPart" ) ) { KParts::ReadOnlyPart* const p = ( *it )->m_part; kdDebug(6050) << QString().leftJustify(s_DOMTreeIndentLevel*4,' ') << "FRAME " << p->name() << " " << endl; static_cast<KHTMLPart*>( p )->slotDebugDOMTree(); } s_DOMTreeIndentLevel = indentLevel;}void KHTMLPart::slotDebugScript(){ if (jScript()) jScript()->showDebugWindow();}void KHTMLPart::slotDebugRenderTree(){#ifndef NDEBUG if ( d->m_doc ) { d->m_doc->renderer()->printTree(); // dump out the contents of the rendering & DOM trees// QString dumps;// QTextStream outputStream(dumps,IO_WriteOnly);// d->m_doc->renderer()->layer()->dump( outputStream );// kdDebug() << "dump output:" << "\n" + dumps; }#endif}void KHTMLPart::slotStopAnimations(){ stopAnimations();}void KHTMLPart::setAutoloadImages( bool enable ){ if ( d->m_doc && d->m_doc->docLoader()->autoloadImages() == enable ) return; if ( d->m_doc ) d->m_doc->docLoader()->setAutoloadImages( enable ); unplugActionList( "loadImages" ); if ( enable ) { delete d->m_paLoadImages; d->m_paLoadImages = 0; } else if ( !d->m_paLoadImages ) d->m_paLoadImages = new KAction( i18n( "Display Images on Page" ), "images_display", 0, this, SLOT( slotLoadImages() ), actionCollection(), "loadImages" ); if ( d->m_paLoadImages ) { QPtrList<KAction> lst; lst.append( d->m_paLoadImages ); plugActionList( "loadImages", lst ); }}bool KHTMLPart::autoloadImages() const{ if ( d->m_doc ) return d->m_doc->docLoader()->autoloadImages(); return true;}void KHTMLPart::clear(){ if ( d->m_bCleared ) return; d->m_bCleared = true; d->m_bClearing = true; { ConstFrameIt it = d->m_frames.begin(); const ConstFrameIt end = d->m_frames.end(); for(; it != end; ++it ) { // Stop HTMLRun jobs for frames if ( (*it)->m_run ) (*it)->m_run->abort(); } } { ConstFrameIt it = d->m_objects.begin(); const ConstFrameIt end = d->m_objects.end(); for(; it != end; ++it ) { // Stop HTMLRun jobs for objects if ( (*it)->m_run ) (*it)->m_run->abort(); } } findTextBegin(); // resets d->m_findNode and d->m_findPos d->m_mousePressNode = DOM::Node(); if ( d->m_doc ) { if (d->m_doc->attached()) //the view may have detached it already d->m_doc->detach(); } // Moving past doc so that onUnload works. if ( d->m_frame && d->m_frame->m_jscript ) d->m_frame->m_jscript->clear(); // stopping marquees if (d->m_doc && d->m_doc->renderer() && d->m_doc->renderer()->layer()) d->m_doc->renderer()->layer()->suspendMarquees(); if ( d->m_view ) d->m_view->clear(); // do not dereference the document before the jscript and view are cleared, as some destructors // might still try to access the document. if ( d->m_doc ) { d->m_doc->deref(); } d->m_doc = 0; delete d->m_decoder; d->m_decoder = 0; // We don't want to change between parts if we are going to delete all of them anyway disconnect( partManager(), SIGNAL( activePartChanged( KParts::Part * ) ), this, SLOT( slotActiveFrameChanged( KParts::Part * ) ) ); if (d->m_frames.count()) { KHTMLFrameList frames = d->m_frames; d->m_frames.clear(); ConstFrameIt it = frames.begin(); const ConstFrameIt end = frames.end(); for(; it != end; ++it ) { if ( (*it)->m_part ) { partManager()->removePart( (*it)->m_part ); delete (KParts::ReadOnlyPart *)(*it)->m_part; } delete *it; } } d->m_suppressedPopupOriginParts.clear(); if (d->m_objects.count()) { KHTMLFrameList objects = d->m_objects; d->m_objects.clear(); ConstFrameIt oi = objects.begin(); const ConstFrameIt oiEnd = objects.end(); for (; oi != oiEnd; ++oi ) delete *oi; } // Listen to part changes again connect( partManager(), SIGNAL( activePartChanged( KParts::Part * ) ), this, SLOT( slotActiveFrameChanged( KParts::Part * ) ) ); d->m_delayRedirect = 0; d->m_redirectURL = QString::null; d->m_redirectionTimer.stop(); d->m_redirectLockHistory = true; d->m_bClearing = false; d->m_frameNameId = 1; d->m_bFirstData = true; d->m_bMousePressed = false; d->m_selectionStart = DOM::Node(); d->m_selectionEnd = DOM::Node(); d->m_startOffset = 0; d->m_endOffset = 0;#ifndef QT_NO_CLIPBOARD connect( kapp->clipboard(), SIGNAL( selectionChanged()), SLOT( slotClearSelection()));#endif d->m_jobPercent = 0; if ( !d->m_haveEncoding ) d->m_encoding = QString::null;#ifdef SPEED_DEBUG d->m_parsetime.restart();#endif}bool KHTMLPart::openFile(){ return true;}DOM::HTMLDocumentImpl *KHTMLPart::docImpl() const{ if ( d && d->m_doc && d->m_doc->isHTMLDocument() ) return static_cast<HTMLDocumentImpl*>(d->m_doc); return 0;}DOM::DocumentImpl *KHTMLPart::xmlDocImpl() const{ if ( d ) return d->m_doc; return 0;}void KHTMLPart::slotInfoMessage(KIO::Job* kio_job, const QString& msg){ assert(d->m_job == kio_job); if (!parentPart()) setStatusBarText(msg, BarDefaultText);}void KHTMLPart::setPageSecurity( PageSecurity sec ){#ifndef KONQ_EMBEDDED emit d->m_extension->setPageSecurity( sec ); if ( sec != NotCrypted && !d->m_statusBarIconLabel && !parentPart() ) { d->m_statusBarIconLabel = new KURLLabel( d->m_statusBarExtension->statusBar() ); d->m_statusBarIconLabel->setFixedHeight( instance()->iconLoader()->currentSize(KIcon::Small) ); d->m_statusBarIconLabel->setSizePolicy(QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed )); d->m_statusBarIconLabel->setUseCursor( false ); d->m_statusBarExtension->addStatusBarItem( d->m_statusBarIconLabel, 0, false ); connect( d->m_statusBarIconLabel, SIGNAL( leftClickedURL() ), SLOT( slotSecurity() ) ); } else if (d->m_statusBarIconLabel) { QToolTip::remove(d->m_statusBarIconLabel);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -