khtml Library API Documentation

khtml_part.h

00001 // -*- c-basic-offset: 2 -*- 00002 /* This file is part of the KDE project 00003 * 00004 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 00005 * 1999-2001 Lars Knoll <knoll@kde.org> 00006 * 1999-2001 Antti Koivisto <koivisto@kde.org> 00007 * 2000-2001 Simon Hausmann <hausmann@kde.org> 00008 * 2000-2001 Dirk Mueller <mueller@kde.org> 00009 * 2000 Stefan Schimanski <1Stein@gmx.de> 00010 * 00011 * This library is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU Library General Public 00013 * License as published by the Free Software Foundation; either 00014 * version 2 of the License, or (at your option) any later version. 00015 * 00016 * This library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Library General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Library General Public License 00022 * along with this library; see the file COPYING.LIB. If not, write to 00023 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00024 * Boston, MA 02111-1307, USA. 00025 */ 00026 #ifndef __khtml_part_h__ 00027 #define __khtml_part_h__ 00028 00029 #include "dom/html_document.h" 00030 #include "dom/dom2_range.h" 00031 00032 #include <kparts/part.h> 00033 #include <kparts/browserextension.h> 00034 #include <kdemacros.h> 00035 00036 #include <qregexp.h> 00037 00038 class KHTMLPartPrivate; 00039 class KHTMLPartBrowserExtension; 00040 class KJSProxy; 00041 class KHTMLView; 00042 class KHTMLSettings; 00043 class KJavaAppletContext; 00044 class KJSErrorDlg; 00045 00046 namespace DOM 00047 { 00048 class HTMLDocument; 00049 class HTMLDocumentImpl; 00050 class DocumentImpl; 00051 class HTMLTitleElementImpl; 00052 class HTMLElementImpl; 00053 class HTMLFrameElementImpl; 00054 class HTMLIFrameElementImpl; 00055 class HTMLObjectElementImpl; 00056 class HTMLFormElementImpl; 00057 class HTMLAnchorElementImpl; 00058 class HTMLMetaElementImpl; 00059 class NodeImpl; 00060 class Node; 00061 class HTMLEventListener; 00062 class EventListener; 00063 } 00064 00065 namespace KJS 00066 { 00067 class Interpreter; 00068 } 00069 00070 namespace khtml 00071 { 00072 class DocLoader; 00073 class RenderPart; 00074 class RenderPartObject; 00075 struct ChildFrame; 00076 class MouseEvent; 00077 class MousePressEvent; 00078 class MouseDoubleClickEvent; 00079 class MouseMoveEvent; 00080 class MouseReleaseEvent; 00081 class DrawContentsEvent; 00082 class CachedObject; 00083 class RenderWidget; 00084 class CSSStyleSelector; 00085 class HTMLTokenizer; 00086 class Decoder; 00087 class XMLTokenizer; 00088 } 00089 00090 namespace KJS { 00091 class Window; 00092 class WindowFunc; 00093 class ExternalFunc; 00094 class JSEventListener; 00095 class JSNodeFilter; 00096 class DOMDocument; 00097 class SourceFile; 00098 class ScheduledAction; 00099 } 00100 00101 namespace KParts 00102 { 00103 class PartManager; 00104 class LiveConnectExtension; 00105 } 00106 00107 namespace KWallet 00108 { 00109 class Wallet; 00110 } 00111 00183 class KHTMLPart : public KParts::ReadOnlyPart 00184 { 00185 Q_OBJECT 00186 friend class KHTMLView; 00187 friend class DOM::HTMLTitleElementImpl; 00188 friend class DOM::HTMLFrameElementImpl; 00189 friend class DOM::HTMLIFrameElementImpl; 00190 friend class DOM::HTMLObjectElementImpl; 00191 friend class DOM::HTMLAnchorElementImpl; 00192 friend class DOM::HTMLMetaElementImpl; 00193 friend class DOM::NodeImpl; 00194 friend class KHTMLRun; 00195 friend class DOM::HTMLFormElementImpl; 00196 friend class khtml::RenderPartObject; 00197 friend class KJS::Window; 00198 friend class KJS::ScheduledAction; 00199 friend class KJS::JSNodeFilter; 00200 friend class KJS::WindowFunc; 00201 friend class KJS::ExternalFunc; 00202 friend class KJS::JSEventListener; 00203 friend class KJS::DOMDocument; 00204 friend class KJS::SourceFile; 00205 friend class KJSProxy; 00206 friend class KHTMLPartBrowserExtension; 00207 friend class DOM::DocumentImpl; 00208 friend class DOM::HTMLDocumentImpl; 00209 friend class KHTMLPartBrowserHostExtension; 00210 friend class khtml::HTMLTokenizer; 00211 friend class khtml::XMLTokenizer; 00212 friend class khtml::RenderWidget; 00213 friend class khtml::CSSStyleSelector; 00214 friend class KHTMLPartIface; 00215 friend class KHTMLPartFunction; 00216 00217 Q_PROPERTY( bool javaScriptEnabled READ jScriptEnabled WRITE setJScriptEnabled ) 00218 Q_PROPERTY( bool javaEnabled READ javaEnabled WRITE setJavaEnabled ) 00219 Q_PROPERTY( bool autoloadImages READ autoloadImages WRITE setAutoloadImages ) 00220 Q_PROPERTY( bool dndEnabled READ dndEnabled WRITE setDNDEnabled ) 00221 Q_PROPERTY( bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled ) 00222 Q_PROPERTY( bool onlyLocalReferences READ onlyLocalReferences WRITE setOnlyLocalReferences ) 00223 Q_PROPERTY( QCString dcopObjectId READ dcopObjectId ) 00224 00225 public: 00226 enum GUIProfile { DefaultGUI, BrowserViewGUI /* ... */ }; 00227 00240 KHTMLPart( QWidget *parentWidget = 0, const char *widgetname = 0, 00241 QObject *parent = 0, const char *name = 0, GUIProfile prof = DefaultGUI ); 00242 00243 KHTMLPart( KHTMLView *view, QObject *parent = 0, const char *name = 0, GUIProfile prof = DefaultGUI ); 00244 00248 virtual ~KHTMLPart(); 00249 00255 virtual bool openURL( const KURL &url ); 00256 00260 virtual bool closeURL(); 00261 00268 virtual void showError( KIO::Job* job ); 00269 00273 DOM::HTMLDocument htmlDocument() const; 00274 00278 DOM::Document document() const; 00279 00283 DOM::Node activeNode() const; 00284 00288 KParts::BrowserExtension *browserExtension() const; 00289 KParts::LiveConnectExtension *liveConnectExtension( const khtml::RenderPart *) const; 00290 00294 KHTMLView *view() const; 00295 00302 void setJScriptEnabled( bool enable ); 00303 00308 bool jScriptEnabled() const; 00309 00327 KJS::Interpreter *jScriptInterpreter(); 00328 00332 void setStatusMessagesEnabled( bool enable ); 00333 00337 bool statusMessagesEnabled() const; 00338 00342 void setMetaRefreshEnabled( bool enable ); 00343 00347 bool metaRefreshEnabled() const; 00348 00353 QVariant executeScript( const DOM::Node &n, const QString &script ); 00354 00359 void setDNDEnabled( bool b ); 00360 00364 bool dndEnabled() const; 00365 00372 void setJavaEnabled( bool enable ); 00373 00377 bool javaEnabled() const; 00378 00382 KJavaAppletContext *javaContext(); 00383 00388 KJavaAppletContext *createJavaContext(); 00389 00393 void setPluginsEnabled( bool enable ); 00394 00398 bool pluginsEnabled() const; 00399 00406 void setAutoloadImages( bool enable ); 00413 bool autoloadImages() const; 00414 00431 void setOnlyLocalReferences( bool enable ); 00432 00437 bool onlyLocalReferences() const; 00438 00442 bool isCaretMode() const; 00443 00448 bool isEditable() const; 00449 00463 void setCaretPosition(DOM::Node node, long offset, bool extendSelection = false); 00464 00472 enum CaretDisplayPolicy { 00473 CaretVisible, CaretInvisible, CaretBlink 00474 }; 00475 00480 CaretDisplayPolicy caretDisplayPolicyNonFocused() const; 00481 00492 void setCaretDisplayPolicyNonFocused(CaretDisplayPolicy policy); 00493 00494 #ifndef KDE_NO_COMPAT 00495 void enableJScript( bool e ) { setJScriptEnabled(e); } 00496 void enableJava( bool e ) { setJavaEnabled(e); } 00497 void enablePlugins( bool e ) { setPluginsEnabled(e); } 00498 void autoloadImages( bool e ) { setAutoloadImages(e); } 00499 void enableMetaRefresh( bool e ) { setMetaRefreshEnabled(e); } 00500 bool setCharset( const QString &, bool ) { return true; } 00501 00502 KURL baseURL() const; 00503 QString baseTarget() const; 00504 #endif 00505 00509 KURL backgroundURL() const; 00510 00514 void scheduleRedirection( int delay, const QString &url, bool lockHistory = true ); 00515 00538 virtual void begin( const KURL &url = KURL(), int xOffset = 0, int yOffset = 0 ); 00539 00560 virtual void write( const char *str, int len = -1 ); 00561 00569 virtual void write( const QString &str ); 00570 00574 virtual void end(); 00575 00576 /* 00577 * Prints the current HTML page laid out for the printer. 00578 * 00579 * (not implemented at the moment) 00580 */ 00581 // void print(QPainter *, int pageHeight, int pageWidth); 00582 00586 void paint( QPainter *, const QRect &, int = 0, bool * = 0 ); 00587 00594 bool setEncoding( const QString &name, bool override = false ); 00595 00601 QString encoding() const; 00602 00610 void setUserStyleSheet( const KURL &url ); 00611 00619 void setUserStyleSheet( const QString &styleSheet ); 00620 00621 public: 00622 00628 void setStandardFont( const QString &name ); 00629 00636 void setFixedFont( const QString &name ); 00637 00645 bool gotoAnchor( const QString &name ); 00646 00653 bool nextAnchor(); 00654 00659 bool prevAnchor(); 00660 00664 void setURLCursor( const QCursor &c ); 00665 00669 QCursor urlCursor() const; 00670 00674 void findTextBegin(); 00675 00680 bool findTextNext( const QString &str, bool forward, bool caseSensitive, bool isRegExp ); 00681 00692 void setZoomFactor(int percent); 00693 00697 int zoomFactor() const; 00698 00702 virtual QString selectedText() const; 00703 00707 DOM::Range selection() const; 00708 00720 void selection(DOM::Node &startNode, long &startOffset, 00721 DOM::Node &endNode, long &endOffset) const; 00722 00726 void setSelection( const DOM::Range & ); 00727 00736 bool hasSelection() const; 00737 00741 void selectAll(); 00742 00748 void show(); 00749 00755 void hide(); 00756 00761 KParts::PartManager *partManager(); 00762 00770 virtual void saveState( QDataStream &stream ); 00780 virtual void restoreState( QDataStream &stream ); 00781 00785 DOM::Node nodeUnderMouse() const; 00786 00790 const KHTMLSettings *settings() const; 00791 00798 KHTMLPart *parentPart(); 00799 00805 QStringList frameNames() const; 00806 00807 QPtrList<KParts::ReadOnlyPart> frames() const; 00808 00812 KHTMLPart *findFrame( const QString &f ); 00813 00819 KParts::ReadOnlyPart *currentFrame() const; 00820 00827 bool frameExists( const QString &frameName ); 00828 00829 00835 void setJSStatusBarText( const QString &text ); 00836 00842 void setJSDefaultStatusBarText( const QString &text ); 00843 00849 QString jsStatusBarText() const; 00850 00856 QString jsDefaultStatusBarText() const; 00857 00861 QString referrer() const; 00862 00866 QString pageReferrer() const; 00867 00871 QString lastModified() const; 00872 00876 void preloadStyleSheet( const QString &url, const QString &stylesheet ); 00877 00881 void preloadScript( const QString &url, const QString &script ); 00882 00886 bool restored() const; 00887 00888 // ### KDE4 remove me 00889 enum FormNotification { NoNotification = 0, Before, Only, Unused=255 }; 00896 void setFormNotification(FormNotification fn); 00897 00904 FormNotification formNotification() const; 00905 00913 KURL toplevelURL(); 00914 00915 00916 signals: 00920 void onURL( const QString &url ); 00921 00925 void popupMenu( const QString &url, const QPoint &point ); 00926 00930 void selectionChanged(); 00931 00939 void nodeActivated( const DOM::Node & ); 00940 00943 void docCreated(); 00944 00956 void caretPositionChanged(const DOM::Node &node, long offset); 00957 00958 00965 void formSubmitNotification(const char *action, const QString& url, 00966 const QByteArray& formData, const QString& target, 00967 const QString& contentType, const QString& boundary); 00968 00969 00970 protected: 00971 00976 KURL completeURL( const QString &url ); 00977 00984 void htmlError( int errorCode, const QString& text, const KURL& reqUrl ); 00985 00986 virtual void customEvent( QCustomEvent *event ); 00987 00991 virtual void khtmlMousePressEvent( khtml::MousePressEvent *event ); 00995 virtual void khtmlMouseDoubleClickEvent( khtml::MouseDoubleClickEvent * ); 00999 virtual void khtmlMouseMoveEvent( khtml::MouseMoveEvent *event ); 01003 virtual void khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *event ); 01007 virtual void khtmlDrawContentsEvent( khtml::DrawContentsEvent * ); 01008 01012 virtual void guiActivateEvent( KParts::GUIActivateEvent *event ); 01013 01017 virtual bool openFile(); 01018 01019 virtual void urlSelected( const QString &url, int button, int state, 01020 const QString &_target, KParts::URLArgs args = KParts::URLArgs()); 01021 01030 virtual KParts::ReadOnlyPart *createPart( QWidget *parentWidget, const char *widgetName, 01031 QObject *parent, const char *name, 01032 const QString &mimetype, QString &serviceName, 01033 QStringList &serviceTypes, const QStringList &params); 01034 01035 // This is for RenderPartObject. We want to ask the 'download plugin?' 01036 // question only once per mimetype 01037 bool pluginPageQuestionAsked( const QString& mimetype ) const; 01038 void setPluginPageQuestionAsked( const QString& mimetype ); 01039 01040 enum PageSecurity { NotCrypted, Encrypted, Mixed }; 01041 void setPageSecurity( PageSecurity sec ); 01042 01046 virtual bool doOpenStream( const QString& mimeType ); 01047 01051 virtual bool doWriteStream( const QByteArray& data ); 01052 01056 virtual bool doCloseStream(); 01057 01058 public slots: 01059 01069 void setActiveNode( const DOM::Node &node ); 01070 01074 void stopAnimations(); 01075 01076 QCString dcopObjectId() const; 01077 01085 QVariant executeScript( const QString &script ); 01086 01097 void setCaretMode(bool enable); 01098 01103 void setEditable(bool enable); 01104 01121 void setCaretVisible(bool show); 01122 01123 // ### KDE4 FIXME: 01124 // Remove this and make the one below protected+virtual slot. 01125 // Warning: this is effectively "internal". Be careful. 01126 // @since 3.2 01127 void submitFormProxy( const char *action, const QString &url, 01128 const QByteArray &formData, 01129 const QString &target, 01130 const QString& contentType = QString::null, 01131 const QString& boundary = QString::null ); 01132 01133 private slots: 01134 01138 void reparseConfiguration(); 01139 01143 void slotData( KIO::Job*, const QByteArray &data ); 01147 void slotInfoMessage( KIO::Job*, const QString& msg ); 01151 void slotRestoreData( const QByteArray &data ); 01155 void slotFinished( KIO::Job* ); 01159 void slotFinishedParsing(); 01163 void slotRedirect(); 01167 void slotRedirection( KIO::Job*, const KURL& ); 01171 void slotDebugScript(); 01175 void slotDebugDOMTree(); 01179 void slotDebugRenderTree(); 01183 void slotStopAnimations(); 01187 virtual void slotViewDocumentSource(); 01191 virtual void slotViewFrameSource(); 01195 void slotViewPageInfo(); 01199 virtual void slotSaveBackground(); 01203 virtual void slotSaveDocument(); 01207 virtual void slotSaveFrame(); 01211 virtual void slotSecurity(); 01215 virtual void slotSetEncoding(); 01216 01220 virtual void slotUseStylesheet(); 01221 01222 virtual void slotFind(); 01223 virtual void slotFindDone(); // ### remove me 01224 virtual void slotFindDialogDestroyed(); 01225 void slotFindNext(); 01226 01227 void slotIncZoom(); 01228 void slotDecZoom(); 01229 01230 void slotLoadImages(); 01231 void slotWalletClosed(); 01232 void launchWalletManager(); 01233 void walletMenu(); 01234 01238 void submitFormAgain(); 01239 01243 void updateActions(); 01247 void slotPartRemoved( KParts::Part *part ); 01251 void slotActiveFrameChanged( KParts::Part *part ); 01255 void slotChildStarted( KIO::Job *job ); 01259 void slotChildCompleted(); 01263 void slotChildCompleted( bool ); 01267 void slotParentCompleted(); 01271 void slotChildURLRequest( const KURL &url, const KParts::URLArgs &args ); 01275 void slotChildDocCreated(); 01276 01277 void slotLoaderRequestStarted( khtml::DocLoader*, khtml::CachedObject* obj); 01278 void slotLoaderRequestDone( khtml::DocLoader*, khtml::CachedObject *obj ); 01279 void checkCompleted(); 01280 01284 void slotAutoScroll(); 01285 01286 void slotPrintFrame(); 01287 01288 void slotSelectAll(); 01289 01293 void slotProgressUpdate(); 01294 01295 /* 01296 * @internal 01297 */ 01298 void slotJobPercent( KIO::Job*, unsigned long ); 01299 01300 /* 01301 * @internal 01302 */ 01303 void slotJobDone( KIO::Job* ); 01304 01305 /* 01306 * @internal 01307 */ 01308 void slotUserSheetStatDone( KIO::Job* ); 01309 01310 /* 01311 * @internal 01312 */ 01313 void slotJobSpeed( KIO::Job*, unsigned long ); 01314 01318 void slotClearSelection(); 01319 01323 void slotZoomView( int ); 01324 01328 void slotHighlight( const QString &, int index, int length ); 01329 01333 void slotAutomaticDetectionLanguage( int _id ); 01334 01338 void slotToggleCaretMode(); 01339 01343 void launchJSErrorDialog(); 01344 01348 void removeJSErrorExtension(); 01349 01353 void disableJSErrorExtension(); 01354 01358 void jsErrorDialogContextMenu(); 01359 01360 01361 01362 private: 01363 01364 KJSErrorDlg *jsErrorExtension(); 01365 01366 enum StatusBarPriority { BarDefaultText, BarHoverText, BarOverrideText }; 01367 void setStatusBarText( const QString& text, StatusBarPriority p); 01368 01369 bool restoreURL( const KURL &url ); 01370 void emitSelectionChanged(); 01371 bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs ); 01372 void startAutoScroll(); 01373 void stopAutoScroll(); 01374 void overURL( const QString &url, const QString &target, bool shiftPressed = false ); 01375 01376 bool processObjectRequest( khtml::ChildFrame *child, const KURL &url, const QString &mimetype ); 01377 01378 KWallet::Wallet* wallet(); 01379 01383 // ### KDE4 FIXME: 01384 // It is desirable to be able to filter form submissions as well. 01385 // For instance, forms can have a target and an inheriting class 01386 // might want to filter based on the target. Make this protected 01387 // and virtual, or provide a better solution. 01388 // See the web_module for the sidebar for an example where this is 01389 // necessary. 01390 void submitForm( const char *action, const QString &url, const QByteArray &formData, 01391 const QString &target, const QString& contentType = QString::null, 01392 const QString& boundary = QString::null ); 01393 01394 void popupMenu( const QString &url ); 01395 01396 void init( KHTMLView *view, GUIProfile prof ); 01397 01398 01399 void clear(); 01400 01401 bool scheduleScript( const DOM::Node &n, const QString& script); 01402 01403 QVariant crossFrameExecuteScript(const QString& target, const QString& script); 01404 QVariant executeScheduledScript(); 01405 01406 bool requestFrame( khtml::RenderPart *frame, const QString &url, const QString &frameName, 01407 const QStringList &args = QStringList(), bool isIFrame = false ); 01408 01416 QString requestFrameName(); 01417 01418 bool requestObject( khtml::RenderPart *frame, const QString &url, const QString &serviceType, 01419 const QStringList &args = QStringList() ); 01420 01421 bool requestObject( khtml::ChildFrame *child, const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() ); 01422 01423 DOM::EventListener *createHTMLEventListener( QString code, QString name ); 01424 01425 DOM::HTMLDocumentImpl *docImpl() const; 01426 DOM::DocumentImpl *xmlDocImpl() const; 01427 khtml::ChildFrame *frame( const QObject *obj ); 01428 01429 khtml::ChildFrame *recursiveFrameRequest( const KURL &url, const KParts::URLArgs &args, bool callParent = true ); 01430 01431 bool checkLinkSecurity( const KURL &linkURL,const QString &message = QString::null, const QString &button = QString::null ); 01432 QVariant executeScript( const QString& filename, int baseLine, const DOM::Node &n, const QString& script ); 01433 01434 KJSProxy *jScript(); 01435 01436 KHTMLPart *opener(); 01437 long cacheId() const; 01438 void setOpener( KHTMLPart *_opener ); 01439 bool openedByJS(); 01440 void setOpenedByJS( bool _openedByJS ); 01441 01442 void checkEmitLoadEvent(); 01443 void emitLoadEvent(); 01444 01445 bool initFindNode( bool selection, bool reverse, bool fromCursor ); 01446 void findText(); 01447 void findTextNext(); 01448 void extendSelection( DOM::NodeImpl* node, long offset, DOM::Node& selectionNode, long& selectionOffset, bool right, bool paragraph ); 01458 void extendSelectionTo(int x, int y, int absX, int absY, const DOM::Node &innerNode); 01462 bool isExtendingSelection() const; 01463 khtml::Decoder *createDecoder(); 01464 01468 void zoomIn(const int stepping[], int count); 01472 void zoomOut(const int stepping[], int count); 01473 01474 void emitCaretPositionChanged(const DOM::Node &node, long offset); 01475 01476 void setDebugScript( bool enable ); 01477 01478 KHTMLPartPrivate *d; 01479 friend class KHTMLPartPrivate; 01480 }; 01481 01482 01483 #endif
KDE Logo
This file is part of the documentation for khtml Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 20 09:50:29 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003