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

📄 khtml_part.cpp.orig

📁 konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版本源码包.
💻 ORIG
📖 第 1 页 / 共 5 页
字号:
// -*- c-basic-offset: 2 -*-/* This file is part of the KDE project * * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> *                     1999 Lars Knoll <knoll@kde.org> *                     1999 Antti Koivisto <koivisto@kde.org> *                     2000 Simon Hausmann <hausmann@kde.org> *                     2000 Stefan Schimanski <1Stein@gmx.de> *                     2001-2003 George Staikos <staikos@kde.org> *                     2001-2003 Dirk Mueller <mueller@kde.org> *                     2000-2005 David Faure <faure@kde.org> *                     2002 Apple Computer, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB.  If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. *///#define SPEED_DEBUG#include "khtml_part.h"#include "khtml_pagecache.h"#include "dom/dom_string.h"#include "dom/dom_element.h"#include "dom/dom_exception.h"#include "html/html_documentimpl.h"#include "html/html_baseimpl.h"#include "html/html_objectimpl.h"#include "html/html_miscimpl.h"#include "html/html_imageimpl.h"#include "html/html_objectimpl.h"#include "rendering/render_text.h"#include "rendering/render_frames.h"#include "rendering/render_layer.h"#include "misc/htmlhashes.h"#include "misc/loader.h"#include "xml/dom2_eventsimpl.h"#include "xml/dom2_rangeimpl.h"#include "xml/xml_tokenizer.h"#include "css/cssstyleselector.h"#include "css/csshelper.h"using namespace DOM;#include "khtmlview.h"#include <kparts/partmanager.h>#include "ecma/kjs_proxy.h"#include "ecma/kjs_window.h"#include "khtml_settings.h"#include "kjserrordlg.h"#include <kjs/function.h>#include <kjs/interpreter.h>#include "htmlpageinfo.h"#include <sys/types.h>#include <assert.h>#include <unistd.h>#include <config.h>#include <dcopclient.h>#include <dcopref.h>#include <kstandarddirs.h>#include <kstringhandler.h>#include <kio/job.h>#include <kio/global.h>#include <kio/netaccess.h>#include <kprotocolmanager.h>#include <kdebug.h>#include <kiconloader.h>#include <klocale.h>#include <kcharsets.h>#include <kmessagebox.h>#include <kstdaction.h>#include <kfiledialog.h>#include <ktrader.h>#include <kdatastream.h>#include <ktempfile.h>#include <kglobalsettings.h>#include <kurldrag.h>#include <kapplication.h>#include <kparts/browserinterface.h>#if !defined(QT_NO_DRAGANDDROP)#include <kmultipledrag.h>#endif#include "../kutils/kfinddialog.h"#include "../kutils/kfind.h"#include <ksslcertchain.h>#include <ksslinfodlg.h>#include <kfileitem.h>#include <kurifilter.h>#include <kstatusbar.h>#include <kurllabel.h>#include <qclipboard.h>#include <qfile.h>#include <qtooltip.h>#include <qmetaobject.h>#include <private/qucomextra_p.h>#include "khtmlpart_p.h"#include "kpassivepopup.h"#include "kpopupmenu.h"#include "rendering/render_form.h"#include <kwin.h>#define HINT_UTF8	106namespace khtml {    class PartStyleSheetLoader : public CachedObjectClient    {    public:        PartStyleSheetLoader(KHTMLPart *part, DOM::DOMString url, DocLoader* dl)        {            m_part = part;            m_cachedSheet = dl->requestStyleSheet(url, QString::null, "text/css",                                                  true /* "user sheet" */);            if (m_cachedSheet)		m_cachedSheet->ref( this );        }        virtual ~PartStyleSheetLoader()        {            if ( m_cachedSheet ) m_cachedSheet->deref(this);        }        virtual void setStyleSheet(const DOM::DOMString&, const DOM::DOMString &sheet)        {          if ( m_part )            m_part->setUserStyleSheet( sheet.string() );            delete this;        }        virtual void error( int, const QString& ) {          delete this;        }        QGuardedPtr<KHTMLPart> m_part;        khtml::CachedCSSStyleSheet *m_cachedSheet;    };}void khtml::ChildFrame::liveConnectEvent(const unsigned long, const QString & event, const KParts::LiveConnectExtension::ArgList & args){    if (!m_part || !m_frame || !m_liveconnect)        // hmmm        return;    QString script;    script.sprintf("%s(", event.latin1());    KParts::LiveConnectExtension::ArgList::const_iterator i = args.begin();    const KParts::LiveConnectExtension::ArgList::const_iterator argsBegin = i;    const KParts::LiveConnectExtension::ArgList::const_iterator argsEnd = args.end();    for ( ; i != argsEnd; ++i) {        if (i != argsBegin)            script += ",";        if ((*i).first == KParts::LiveConnectExtension::TypeString) {            script += "\"";            script += QString((*i).second).replace('\\', "\\\\").replace('"', "\\\"");            script += "\"";        } else            script += (*i).second;    }    script += ")";    kdDebug(6050) << "khtml::ChildFrame::liveConnectEvent " << script << endl;    KHTMLPart * part = ::qt_cast<KHTMLPart *>(m_part->parent());    if (!part)        return;    if (!m_jscript)        part->framejScript(m_part);    if (m_jscript) {        // we have a jscript => a part in an iframe        KJS::Completion cmp;        m_jscript->evaluate(QString::null, 1, script, 0L, &cmp);    } else        part->executeScript(m_frame->element(), script);}KHTMLFrameList::Iterator KHTMLFrameList::find( const QString &name ){    Iterator it = begin();    const Iterator e = end();    for (; it!=e; ++it )        if ( (*it)->m_name==name )            break;    return it;}KHTMLPart::KHTMLPart( QWidget *parentWidget, const char *widgetname, QObject *parent, const char *name, GUIProfile prof ): KParts::ReadOnlyPart( parent, name ){    d = 0;    KHTMLFactory::registerPart( this );    setInstance(  KHTMLFactory::instance(), prof == BrowserViewGUI && !parentPart() );    // TODO KDE4 - don't load plugins yet    //setInstance( KHTMLFactory::instance(), false );    init( new KHTMLView( this, parentWidget, widgetname ), prof );}KHTMLPart::KHTMLPart( KHTMLView *view, QObject *parent, const char *name, GUIProfile prof ): KParts::ReadOnlyPart( parent, name ){    d = 0;    KHTMLFactory::registerPart( this );    setInstance(  KHTMLFactory::instance(), prof == BrowserViewGUI && !parentPart() );    // TODO KDE4 - don't load plugins yet    //setInstance( KHTMLFactory::instance(), false );    assert( view );    init( view, prof );}void KHTMLPart::init( KHTMLView *view, GUIProfile prof ){  if ( prof == DefaultGUI )    setXMLFile( "khtml.rc" );  else if ( prof == BrowserViewGUI )    setXMLFile( "khtml_browser.rc" );  d = new KHTMLPartPrivate(parent());  d->m_view = view;  setWidget( d->m_view );  d->m_guiProfile = prof;  d->m_extension = new KHTMLPartBrowserExtension( this, "KHTMLBrowserExtension" );  d->m_hostExtension = new KHTMLPartBrowserHostExtension( this );  d->m_statusBarExtension = new KParts::StatusBarExtension( this );  d->m_statusBarIconLabel = 0L;  d->m_statusBarPopupLabel = 0L;  d->m_openableSuppressedPopups = 0;  d->m_bSecurityInQuestion = false;  d->m_paLoadImages = 0;  d->m_paDebugScript = 0;  d->m_bMousePressed = false;  d->m_bRightMousePressed = false;  d->m_bCleared = false;  d->m_paViewDocument = new KAction( i18n( "View Do&cument Source" ), CTRL + Key_U, this, SLOT( slotViewDocumentSource() ), actionCollection(), "viewDocumentSource" );  d->m_paViewFrame = new KAction( i18n( "View Frame Source" ), 0, this, SLOT( slotViewFrameSource() ), actionCollection(), "viewFrameSource" );  d->m_paViewInfo = new KAction( i18n( "View Document Information" ), CTRL+Key_I, this, SLOT( slotViewPageInfo() ), actionCollection(), "viewPageInfo" );  d->m_paSaveBackground = new KAction( i18n( "Save &Background Image As..." ), 0, this, SLOT( slotSaveBackground() ), actionCollection(), "saveBackground" );  d->m_paSaveDocument = KStdAction::saveAs( this, SLOT( slotSaveDocument() ), actionCollection(), "saveDocument" );  if ( parentPart() )      d->m_paSaveDocument->setShortcut( KShortcut() ); // avoid clashes  d->m_paSaveFrame = new KAction( i18n( "Save &Frame As..." ), 0, this, SLOT( slotSaveFrame() ), actionCollection(), "saveFrame" );  d->m_paSecurity = new KAction( i18n( "Security..." ), "decrypted", 0, this, SLOT( slotSecurity() ), actionCollection(), "security" );  d->m_paSecurity->setWhatsThis( i18n( "Security Settings<p>"                                       "Shows the certificate of the displayed page. Only "				       "pages that have been transmitted using a secure, encrypted connection have a "				       "certificate.<p> "				       "Hint: If the image shows a closed lock, the page has been transmitted over a "				       "secure connection.") );  d->m_paDebugRenderTree = new KAction( i18n( "Print Rendering Tree to STDOUT" ), 0, this, SLOT( slotDebugRenderTree() ), actionCollection(), "debugRenderTree" );  d->m_paDebugDOMTree = new KAction( i18n( "Print DOM Tree to STDOUT" ), 0, this, SLOT( slotDebugDOMTree() ), actionCollection(), "debugDOMTree" );  d->m_paStopAnimations = new KAction( i18n( "Stop Animated Images" ), 0, this, SLOT( slotStopAnimations() ), actionCollection(), "stopAnimations" );#ifndef KONQ_EMBEDDED  d->m_paSetEncoding = new KActionMenu( i18n( "Set &Encoding" ), "charset", actionCollection(), "setEncoding" );  d->m_paSetEncoding->setDelayed( false );  d->m_automaticDetection = new KPopupMenu( 0L );  d->m_automaticDetection->insertItem( i18n( "Semi-Automatic" ), 0 );  d->m_automaticDetection->insertItem( i18n( "Arabic" ), 1 );  d->m_automaticDetection->insertItem( i18n( "Baltic" ), 2 );  d->m_automaticDetection->insertItem( i18n( "Central European" ), 3 );  //d->m_automaticDetection->insertItem( i18n( "Chinese" ), 4 );  d->m_automaticDetection->insertItem( i18n( "Greek" ), 5 );  d->m_automaticDetection->insertItem( i18n( "Hebrew" ), 6 );  d->m_automaticDetection->insertItem( i18n( "Japanese" ), 7 );  //d->m_automaticDetection->insertItem( i18n( "Korean" ), 8 );  d->m_automaticDetection->insertItem( i18n( "Russian" ), 9 );  //d->m_automaticDetection->insertItem( i18n( "Thai" ), 10 );  d->m_automaticDetection->insertItem( i18n( "Turkish" ), 11 );  d->m_automaticDetection->insertItem( i18n( "Ukrainian" ), 12 );  //d->m_automaticDetection->insertItem( i18n( "Unicode" ), 13 );  d->m_automaticDetection->insertItem( i18n( "Western European" ), 14 );  connect( d->m_automaticDetection, SIGNAL( activated( int ) ), this, SLOT( slotAutomaticDetectionLanguage( int ) ) );  d->m_paSetEncoding->popupMenu()->insertItem( i18n( "Automatic Detection" ), d->m_automaticDetection, 0 );  d->m_paSetEncoding->insert( new KActionSeparator( actionCollection() ) );  d->m_manualDetection = new KSelectAction( i18n( "short for Manual Detection", "Manual" ), 0, this, SLOT( slotSetEncoding() ), actionCollection(), "manualDetection" );  QStringList encodings = KGlobal::charsets()->descriptiveEncodingNames();  d->m_manualDetection->setItems( encodings );  d->m_manualDetection->setCurrentItem( -1 );  d->m_paSetEncoding->insert( d->m_manualDetection );#endif  KConfig *config = KGlobal::config();  if ( config->hasGroup( "HTML Settings" ) ) {    config->setGroup( "HTML Settings" );    khtml::Decoder::AutoDetectLanguage language;    QCString name = QTextCodec::codecForLocale()->name();    name = name.lower();    if ( name == "cp1256" || name == "iso-8859-6" ) {      language = khtml::Decoder::Arabic;    }    else if ( name == "cp1257" || name == "iso-8859-13" || name == "iso-8859-4" ) {      language = khtml::Decoder::Baltic;    }    else if ( name == "cp1250" || name == "ibm852" || name == "iso-8859-2" || name == "iso-8859-3" ) {      language = khtml::Decoder::CentralEuropean;    }    else if ( name == "cp1251" || name == "koi8-r" || name == "iso-8859-5" ) {      language = khtml::Decoder::Russian;    }    else if ( name == "koi8-u" ) {      language = khtml::Decoder::Ukrainian;    }    else if ( name == "cp1253" || name == "iso-8859-7" ) {      language = khtml::Decoder::Greek;    }    else if ( name == "cp1255" || name == "iso-8859-8" || name == "iso-8859-8-i" ) {      language = khtml::Decoder::Hebrew;    }    else if ( name == "jis7" || name == "eucjp" || name == "sjis"  ) {      language = khtml::Decoder::Japanese;    }    else if ( name == "cp1254" || name == "iso-8859-9" ) {      language = khtml::Decoder::Turkish;    }    else if ( name == "cp1252" || name == "iso-8859-1" || name == "iso-8859-15" ) {      language = khtml::Decoder::WesternEuropean;    }    else      language = khtml::Decoder::SemiautomaticDetection;    int _id = config->readNumEntry( "AutomaticDetectionLanguage", language );#ifndef KONQ_EMBEDDED    d->m_automaticDetection->setItemChecked( _id, true );    d->m_paSetEncoding->popupMenu()->setItemChecked( 0, true );#endif    d->m_autoDetectLanguage = static_cast< khtml::Decoder::AutoDetectLanguage >( _id );  }  d->m_paUseStylesheet = new KSelectAction( i18n( "Use S&tylesheet"), 0, this, SLOT( slotUseStylesheet() ), actionCollection(), "useStylesheet" );  if ( prof == BrowserViewGUI ) {      d->m_paIncZoomFactor = new KHTMLZoomFactorAction( this, true, i18n(                  "Enlarge Font" ), "viewmag+", "CTRL++;CTRL+=", this,              SLOT( slotIncZoomFast() ), actionCollection(), "incFontSizes" );      d->m_paIncZoomFactor->setWhatsThis( i18n( "Enlarge Font<p>"                                                "Make the font in this window bigger. "                            "Click and hold down the mouse button for a menu with all available font sizes." ) );      d->m_paDecZoomFactor = new KHTMLZoomFactorAction( this, false, i18n(                  "Shrink Font" ), "viewmag-", CTRL + Key_Minus, this,              SLOT( slotDecZoomFast() ), actionCollection(), "decFontSizes" );      d->m_paDecZoomFactor->setWhatsThis( i18n( "Shrink Font<p>"                                                "Make the font in this window smaller. "                            "Click and hold down the mouse button for a menu with all available font sizes." ) );  }  d->m_paFind = KStdAction::find( this, SLOT( slotFind() ), actionCollection(), "find" );  d->m_paFind->setWhatsThis( i18n( "Find text<p>"				   "Shows a dialog that allows you to find text on the displayed page." ) );  d->m_paFindNext = KStdAction::findNext( this, SLOT( slotFindNext() ), actionCollection(), "findNext" );  d->m_paFindNext->setWhatsThis( i18n( "Find next<p>"				       "Find the next occurrence of the text that you "				       "have found using the <b>Find Text</b> function" ) );  d->m_paFindPrev = KStdAction::findPrev( this, SLOT( slotFindPrev() ), actionCollection(), "findPrevious" );

⌨️ 快捷键说明

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