⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 khtml_part.cpp

📁 khtml在gtk上的移植版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
  if (d->m_doc && !d->m_doc->parsing() && !d->m_focusNodeRestored)  {      if (d->m_focusNodeNumber >= 0)          d->m_doc->setFocusNode(d->m_doc->nodeWithAbsIndex(d->m_focusNodeNumber));      else          d->m_doc->setFocusNode(0);      d->m_focusNodeRestored = true;  }#endif  // Any frame that hasn't completed yet ?  ConstFrameIt it = d->m_frames.begin();  ConstFrameIt end = d->m_frames.end();  for (; it != end; ++it )    if ( !(*it).m_bCompleted )      return;  // Are we still parsing - or have we done the completed stuff already ?  if ( d->m_bComplete || (d->m_doc && d->m_doc->parsing()) )    return;  // Still waiting for images/scripts from the loader ?  int requests = 0;  if ( d->m_doc && d->m_doc->docLoader() )    requests = khtml::Cache::loader()->numRequests( d->m_doc->docLoader() );  if ( requests > 0 )    return;  // OK, completed.  // Now do what should be done when we are really completed.  d->m_bComplete = true;  checkEmitLoadEvent(); // if we didn't do it before#if APPLE_CHANGES  if (d->m_view) {#endif#if !APPLE_CHANGES  // check that the view has not been moved by the user    if ( !m_url.hasRef() && d->m_view->contentsY() == 0 )      d->m_view->setContentsPos( d->m_extension->urlArgs().xOffset,                                 d->m_extension->urlArgs().yOffset );#endif#if APPLE_CHANGES  } // if (d->m_view)#endif  if ( d->m_scheduledRedirection != noRedirectionScheduled )  {    // Do not start redirection for frames here! That action is    // deferred until the parent emits a completed signal.    if ( parentPart() == 0 )      d->m_redirectionTimer.start( (int)(1000 * d->m_delayRedirect), true );    emit completed( true );  }  else  {    if ( d->m_bPendingChildRedirection )      emit completed ( true );    else      emit completed();  }#if !APPLE_CHANGES  // find the alternate stylesheets  QStringList sheets;  if (d->m_doc)     sheets = d->m_doc->availableStyleSheets();  d->m_paUseStylesheet->setItems( sheets );  d->m_paUseStylesheet->setEnabled( !sheets.isEmpty() );  if (!sheets.isEmpty())  {    d->m_paUseStylesheet->setCurrentItem(kMax(sheets.findIndex(d->m_sheetUsed), 0));    slotUseStylesheet();  }  if (!parentPart())      emit setStatusBarText(i18n("Done."));#endif#ifdef SPEED_DEBUG  kdDebug(6050) << "DONE: " <<d->m_parsetime.elapsed() << endl;#endif}void KHTMLPart::checkEmitLoadEvent(){  if ( d->m_bLoadEventEmitted || !d->m_doc || d->m_doc->parsing() ) return;  ConstFrameIt it = d->m_frames.begin();  ConstFrameIt end = d->m_frames.end();  for (; it != end; ++it )    if ( !(*it).m_bCompleted ) // still got a frame running -> too early      return;  // All frames completed -> set their domain to the frameset's domain  // This must only be done when loading the frameset initially (#22039),  // not when following a link in a frame (#44162).  if ( d->m_doc )  {    DOMString domain = d->m_doc->domain();    ConstFrameIt it = d->m_frames.begin();    ConstFrameIt end = d->m_frames.end();    for (; it != end; ++it )    {      KParts::ReadOnlyPart *p = (*it).m_part;      if ( p && p->inherits( "KHTMLPart" ))      {        KHTMLPart* htmlFrame = static_cast<KHTMLPart *>(p);        if (htmlFrame->d->m_doc)        {          kdDebug() << "KHTMLPart::checkCompleted setting frame domain to " << domain.string() << endl;          htmlFrame->d->m_doc->setDomain( domain );        }      }    }  }  d->m_bLoadEventEmitted = true;  d->m_bUnloadEventEmitted = false;  if (d->m_doc)    d->m_doc->close();}const KHTMLSettings *KHTMLPart::settings() const{  return d->m_settings;}#ifndef KDE_NO_COMPATKURL KHTMLPart::baseURL() const{  if ( !d->m_doc ) return KURL();  return d->m_doc->baseURL();}QString KHTMLPart::baseTarget() const{  if ( !d->m_doc ) return QString::null;  return d->m_doc->baseTarget();}#endifKURL KHTMLPart::completeURL( const QString &url ){  if ( !d->m_doc ) return url;#if !APPLE_CHANGES  if (d->m_decoder)    return KURL(d->m_doc->completeURL(url), d->m_decoder->codec()->mibEnum());#endif  return KURL( d->m_doc->completeURL( url ) );}void KHTMLPart::scheduleRedirection( double delay, const QString &url, bool doLockHistory, bool userGesture ){    kdDebug(6050) << "KHTMLPart::scheduleRedirection delay=" << delay << " url=" << url << endl;    if (delay < 0 || delay > INT_MAX / 1000)      return;    if ( d->m_scheduledRedirection == noRedirectionScheduled || delay < d->m_delayRedirect )    {       if (d->m_doc == 0){        // Handle a location change of a page with no document as a special case.        // This may happens when a frame changes the location of another frame.        d->m_scheduledRedirection = redirectionDuringLoad;       }       else         d->m_scheduledRedirection = redirectionScheduled;       d->m_delayRedirect = delay;       d->m_redirectURL = url;       d->m_redirectLockHistory = doLockHistory;       d->m_redirectUserGesture = userGesture;       if ( d->m_bComplete ) {         d->m_redirectionTimer.stop();         d->m_redirectionTimer.start( (int)(1000 * d->m_delayRedirect), true );       }    }}void KHTMLPart::scheduleHistoryNavigation( int steps ){    d->m_scheduledRedirection = historyNavigationScheduled;    d->m_delayRedirect = 0;    d->m_redirectURL = QString::null;    d->m_scheduledHistoryNavigationSteps = steps;    if ( d->m_bComplete ) {        d->m_redirectionTimer.stop();        d->m_redirectionTimer.start( (int)(1000 * d->m_delayRedirect), true );    }}void KHTMLPart::cancelRedirection(bool cancelWithLoadInProgress){    if (d) {        d->m_cancelWithLoadInProgress = cancelWithLoadInProgress;        d->m_scheduledRedirection = noRedirectionScheduled;        d->m_redirectionTimer.stop();    }}void KHTMLPart::slotRedirect(){    if (d->m_scheduledRedirection == historyNavigationScheduled) {        d->m_scheduledRedirection = noRedirectionScheduled;        // Special case for go(0) from a frame -> reload only the frame        // go(i!=0) from a frame navigates into the history of the frame only,        // in both IE and NS (but not in Mozilla).... we can't easily do that        // in Konqueror...        if (d->m_scheduledHistoryNavigationSteps == 0) // add && parentPart() to get only frames, but doesn't matter            openURL( url() ); /// ## need args.reload=true?        else {            if (d->m_extension) {                BrowserInterface *interface = d->m_extension->browserInterface();                if (interface)                    interface->callMethod( "goHistory(int)", d->m_scheduledHistoryNavigationSteps );            }        }        return;    }    QString u = d->m_redirectURL;  d->m_scheduledRedirection = noRedirectionScheduled;  d->m_delayRedirect = 0;  d->m_redirectURL = QString::null;  if ( u.find( QString::fromLatin1( "javascript:" ), 0, false ) == 0 )  {    QString script = KURL::decode_string( u.right( u.length() - 11 ) );    //kdDebug( 6050 ) << "KHTMLPart::slotRedirect script=" << script << endl;    QVariant res = executeScript( script, d->m_redirectUserGesture );    if ( res.type() == QVariant::String ) {      begin( url() );      write( res.asString() );      end();    }    return;  }  KParts::URLArgs args;  if ( urlcmp( u, m_url.url(), true, false ) )    args.reload = true;  args.setLockHistory( d->m_redirectLockHistory );  urlSelected( u, 0, 0, "_self", args );}void KHTMLPart::slotRedirection(KIO::Job*, const KURL& url){  // the slave told us that we got redirected  // kdDebug( 6050 ) << "redirection by KIO to " << url.url() << endl;  emit d->m_extension->setLocationBarURL( url.prettyURL() );  d->m_workingURL = url;}#if !APPLE_CHANGESbool KHTMLPart::setEncoding( const QString &name, bool override ){    d->m_encoding = name;    d->m_haveEncoding = override;    if( !m_url.isEmpty() ) {        // reload document        closeURL();        KURL url = m_url;        m_url = 0;        d->m_restored = true;        openURL(url);        d->m_restored = false;    }    return true;}#endifQString KHTMLPart::encoding() const{    if(d->m_haveEncoding && !d->m_encoding.isEmpty())        return d->m_encoding;    if(d->m_decoder && d->m_decoder->encoding())        return QString(d->m_decoder->encoding());    return(settings()->encoding());}void KHTMLPart::setUserStyleSheet(const KURL &url){  if ( d->m_doc && d->m_doc->docLoader() )    (void) new khtml::PartStyleSheetLoader(this, url.url(), d->m_doc->docLoader());}void KHTMLPart::setUserStyleSheet(const QString &styleSheet){  if ( d->m_doc )    d->m_doc->setUserStyleSheet( styleSheet );}bool KHTMLPart::gotoAnchor( const QString &name ){  if (!d->m_doc)    return false;  NodeImpl *n = d->m_doc->getElementById(name);  if (!n) {    HTMLCollectionImpl *anchors =        new HTMLCollectionImpl( d->m_doc, HTMLCollectionImpl::DOC_ANCHORS);    anchors->ref();    n = anchors->namedItem(name, !d->m_doc->inCompatMode());    anchors->deref();  }  d->m_doc->setCSSTarget(n); // Setting to null will clear the current target.    // Implement the rule that "" and "top" both mean top of page as in other browsers.  if (!n && !(name.isEmpty() || name.lower() == "top")) {    kdDebug(6050) << "KHTMLPart::gotoAnchor node '" << name << "' not found" << endl;    return false;  }  // We need to update the layout before scrolling, otherwise we could  // really mess things up if an anchor scroll comes at a bad moment.  if ( d->m_doc ) {    d->m_doc->updateRendering();    // Only do a layout if changes have occurred that make it necessary.          if ( d->m_view && d->m_doc->renderer() && d->m_doc->renderer()->needsLayout() ) {      d->m_view->layout();    }  }    int x = 0, y = 0;  if (n) {    static_cast<HTMLElementImpl *>(n)->getUpperLeftCorner(x, y);  }  // Scroll to actual top left of element with no slop, since some pages expect anchors to be exactly scrolled to.#if APPLE_CHANGES  // Call recursive version so this will expose correctly from within nested frames.  d->m_view->setContentsPosRecursive(x, y);#else  d->m_view->setContentsPos(x, y);#endif  return true;}void KHTMLPart::setStandardFont( const QString &name ){    d->m_settings->setStdFontName(name);}void KHTMLPart::setFixedFont( const QString &name ){    d->m_settings->setFixedFontName(name);}#if !APPLE_CHANGESvoid KHTMLPart::setURLCursor( const QCursor &c ){  d->m_linkCursor = c;}#endifQCursor KHTMLPart::urlCursor() const{#if APPLE_CHANGES  // Don't load the link cursor until it's actually used.  // Also, we don't need setURLCursor.  // This speeds up startup time.  return KCursor::handCursor();#else  return d->m_linkCursor;#endif}bool KHTMLPart::onlyLocalReferences() const{  return d->m_onlyLocalReferences;}void KHTMLPart::setOnlyLocalReferences(bool enable){  d->m_onlyLocalReferences = enable;}#if !APPLE_CHANGESvoid KHTMLPart::findTextBegin(NodeImpl *startNode, int startPos){    d->m_findPos = startPos;    d->m_findNode = startNode;}bool KHTMLPart::findTextNext( const QString &str, bool forward, bool caseSensitive, bool isRegExp ){    if ( !d->m_doc )        return false;    if(!d->m_findNode) {        if (d->m_doc->isHTMLDocument())            d->m_findNode = static_cast<HTMLDocumentImpl*>(d->m_doc)->body();        else            d->m_findNode = d->m_doc;    }    if ( !d->m_findNode )    {      kdDebug() << "KHTMLPart::findTextNext no findNode -> return false" << endl;      return false;    }    if ( d->m_findNode->id() == ID_FRAMESET )    {      kdDebug() << "KHTMLPart::findTextNext FRAMESET -> return false" << endl;      return false;    }    while(1)    {        if( (d->m_findNode->nodeType() == Node::TEXT_NODE || d->m_findNode->nodeType() == Node::CDATA_SECTION_NODE) && d->m_findNode->renderer() )        {            DOMString nodeText = d->m_findNode->nodeValue();            DOMStringImpl *t = nodeText.implementation();            QConstString s(t->s, t->l);            int matchLen = 0;            if ( isRegExp ) {              QRegExp matcher( str );              matcher.setCaseSensitive( caseSensitive );              d->m_findPos = matc

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -