00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
KParts::BrowserHostExtension *browserHostExtension()
const;
00291
00295
KHTMLView *
view()
const;
00296
00303
void setJScriptEnabled(
bool enable );
00304
00309
bool jScriptEnabled()
const;
00310
00328 KJS::Interpreter *
jScriptInterpreter();
00329
00333
void setStatusMessagesEnabled(
bool enable );
00334
00338
bool statusMessagesEnabled()
const;
00339
00343
void setMetaRefreshEnabled(
bool enable );
00344
00348
bool metaRefreshEnabled()
const;
00349
00354
QVariant executeScript(
const DOM::Node &n,
const QString &script );
00355
00360
void setDNDEnabled(
bool b );
00361
00365
bool dndEnabled()
const;
00366
00373
void setJavaEnabled(
bool enable );
00374
00378
bool javaEnabled()
const;
00379
00383 KJavaAppletContext *
javaContext();
00384
00389 KJavaAppletContext *
createJavaContext();
00390
00394
void setPluginsEnabled(
bool enable );
00395
00399
bool pluginsEnabled()
const;
00400
00407
void setAutoloadImages(
bool enable );
00414
bool autoloadImages()
const;
00415
00432
void setOnlyLocalReferences(
bool enable );
00433
00438
bool onlyLocalReferences()
const;
00439
00443
bool isCaretMode()
const;
00444
00449
bool isEditable()
const;
00450
00464
void setCaretPosition(
DOM::Node node,
long offset,
bool extendSelection =
false);
00465
00473 enum CaretDisplayPolicy {
00474 CaretVisible, CaretInvisible, CaretBlink
00475 };
00476
00481 CaretDisplayPolicy
caretDisplayPolicyNonFocused() const;
00482
00493
void setCaretDisplayPolicyNonFocused(CaretDisplayPolicy policy);
00494
00495 #ifndef KDE_NO_COMPAT
00496
void enableJScript(
bool e ) { setJScriptEnabled(e); }
00497
void enableJava(
bool e ) { setJavaEnabled(e); }
00498
void enablePlugins(
bool e ) { setPluginsEnabled(e); }
00499
void autoloadImages(
bool e ) { setAutoloadImages(e); }
00500
void enableMetaRefresh(
bool e ) { setMetaRefreshEnabled(e); }
00501
bool setCharset(
const QString &,
bool ) {
return true; }
00502
00503
KURL baseURL() const;
00504
QString baseTarget() const;
00505 #endif
00506
00510
KURL backgroundURL() const;
00511
00515
void scheduleRedirection(
int delay, const
QString &url,
bool lockHistory = true );
00516
00539 virtual
void begin( const
KURL &url =
KURL(),
int xOffset = 0,
int yOffset = 0 );
00540
00561 virtual
void write( const
char *str,
int len = -1 );
00562
00570 virtual
void write( const
QString &str );
00571
00575 virtual
void end();
00576
00577
00578
00579
00580
00581
00582
00583
00587
void paint(
QPainter *, const
QRect &,
int = 0,
bool * = 0 );
00588
00595
bool setEncoding( const
QString &name,
bool override = false );
00596
00602
QString encoding() const;
00603
00611
void setUserStyleSheet( const KURL &url );
00612
00620
void setUserStyleSheet( const
QString &styleSheet );
00621
00622 public:
00623
00629
void setStandardFont( const
QString &name );
00630
00637
void setFixedFont( const
QString &name );
00638
00646
bool gotoAnchor( const
QString &name );
00647
00654
bool nextAnchor();
00655
00660
bool prevAnchor();
00661
00665
void setURLCursor( const
QCursor &c );
00666
00670
QCursor urlCursor() const;
00671
00675
void findTextBegin();
00676
00681
bool findTextNext( const
QString &str,
bool forward,
bool caseSensitive,
bool isRegExp );
00682
00693
void setZoomFactor(
int percent);
00694
00698
int zoomFactor() const;
00699
00703 virtual
QString selectedText() const;
00704
00708 DOM::Range selection() const;
00709
00721
void selection(DOM::
Node &startNode,
long &startOffset,
00722 DOM::
Node &endNode,
long &endOffset) const;
00723
00727
void setSelection( const DOM::Range & );
00728
00737
bool hasSelection() const;
00738
00742
void selectAll();
00743
00749
void show();
00750
00756
void hide();
00757
00762 KParts::PartManager *partManager();
00763
00771 virtual
void saveState(
QDataStream &stream );
00781 virtual
void restoreState(
QDataStream &stream );
00782
00786 DOM::
Node nodeUnderMouse() const;
00787
00791 const
KHTMLSettings *settings() const;
00792
00799
KHTMLPart *parentPart();
00800
00806
QStringList frameNames() const;
00807
00808
QPtrList<KParts::ReadOnlyPart> frames() const;
00809
00813
KHTMLPart *findFrame( const
QString &f );
00814
00823
KHTMLPart *findFrameParent( KParts::ReadOnlyPart *callingPart, const
QString &f, khtml::ChildFrame **childFrame=0 );
00824
00830 KParts::ReadOnlyPart *currentFrame() const;
00831
00838
bool frameExists( const
QString &frameName );
00839
00840
00846
void setJSStatusBarText( const
QString &text );
00847
00853
void setJSDefaultStatusBarText( const
QString &text );
00854
00860
QString jsStatusBarText() const;
00861
00867
QString jsDefaultStatusBarText() const;
00868
00872
QString referrer() const;
00873
00877
QString pageReferrer() const;
00878
00882
QString lastModified() const;
00883
00887
void preloadStyleSheet( const
QString &url, const
QString &stylesheet );
00888
00892
void preloadScript( const
QString &url, const
QString &script );
00893
00897
bool restored() const;
00898
00899
00900 enum FormNotification { NoNotification = 0, Before, Only, Unused=255 };
00907
void setFormNotification(FormNotification fn);
00908
00915 FormNotification
formNotification() const;
00916
00924
KURL toplevelURL();
00925
00926
00927 signals:
00931
void onURL( const
QString &url );
00932
00936
void popupMenu( const
QString &url, const
QPoint &point );
00937
00941
void selectionChanged();
00942
00950
void nodeActivated( const DOM::
Node & );
00951
00954
void docCreated();
00955
00967
void caretPositionChanged(const DOM::Node &node,
long offset);
00968
00969
00976
void formSubmitNotification(const
char *action, const
QString& url,
00977 const
QByteArray& formData, const
QString& target,
00978 const
QString& contentType, const
QString& boundary);
00979
00980
00981 protected:
00982
00987
KURL completeURL( const
QString &url );
00988
00995
void htmlError(
int errorCode, const
QString& text, const
KURL& reqUrl );
00996
00997 virtual
void customEvent(
QCustomEvent *event );
00998
01002 virtual
void khtmlMousePressEvent( khtml::MousePressEvent *event );
01006 virtual
void khtmlMouseDoubleClickEvent( khtml::MouseDoubleClickEvent * );
01010 virtual
void khtmlMouseMoveEvent( khtml::MouseMoveEvent *event );
01014 virtual
void khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *event );
01018 virtual
void khtmlDrawContentsEvent( khtml::DrawContentsEvent * );
01019
01023 virtual
void guiActivateEvent( KParts::GUIActivateEvent *event );
01024
01028 virtual
bool openFile();
01029
01030 virtual
void urlSelected( const
QString &url,
int button,
int state,
01031 const
QString &_target, KParts::URLArgs args = KParts::URLArgs());
01032
01041 virtual KParts::ReadOnlyPart *createPart(
QWidget *parentWidget, const
char *widgetName,
01042
QObject *parent, const
char *name,
01043 const
QString &mimetype,
QString &serviceName,
01044
QStringList &serviceTypes, const
QStringList ¶ms);
01045
01046
01047
01048
bool pluginPageQuestionAsked( const
QString& mimetype ) const;
01049
void setPluginPageQuestionAsked( const
QString& mimetype );
01050
01051 enum PageSecurity { NotCrypted, Encrypted, Mixed };
01052
void setPageSecurity( PageSecurity sec );
01053
01057
virtual bool doOpenStream(
const QString& mimeType );
01058
01062
virtual bool doWriteStream(
const QByteArray& data );
01063
01067
virtual bool doCloseStream();
01068
01069
public slots:
01070
01080
void setActiveNode(
const DOM::Node &node );
01081
01085
void stopAnimations();
01086
01087
QCString dcopObjectId() const;
01088
01096
QVariant executeScript( const
QString &script );
01097
01108
void setCaretMode(
bool enable);
01109
01114
void setEditable(
bool enable);
01115
01132
void setCaretVisible(
bool show);
01133
01134
01135
01136
01137
01138
void submitFormProxy( const
char *action, const
QString &url,
01139 const
QByteArray &formData,
01140 const
QString &target,
01141 const
QString& contentType =
QString::null,
01142 const
QString& boundary =
QString::null );
01143
01144 private slots:
01149
void gotoAnchor();
01150
01154
void reparseConfiguration();
01155
01159
void slotData( KIO::Job*, const
QByteArray &data );
01163
void slotInfoMessage( KIO::Job*, const
QString& msg );
01167
void slotRestoreData( const
QByteArray &data );
01171
void slotFinished( KIO::Job* );
01175
void slotFinishedParsing();
01179
void slotRedirect();
01183
void slotRedirection( KIO::Job*, const
KURL& );
01187
void slotDebugScript();
01191
void slotDebugDOMTree();
01195
void slotDebugRenderTree();
01199
void slotStopAnimations();
01203 virtual
void slotViewDocumentSource();
01207 virtual
void slotViewFrameSource();
01211
void slotViewPageInfo();
01215 virtual
void slotSaveBackground();
01219 virtual
void slotSaveDocument();
01223 virtual
void slotSaveFrame();
01227 virtual
void slotSecurity();
01231 virtual
void slotSetEncoding();
01232
01236 virtual
void slotUseStylesheet();
01237
01238 virtual
void slotFind();
01239 virtual
void slotFindDone();
01240 virtual
void slotFindDialogDestroyed();
01241
void slotFindNext();
01242
01243
void slotIncZoom();
01244
void slotDecZoom();
01245
01246
void slotLoadImages();
01247
void slotWalletClosed();
01248
void launchWalletManager();
01249
void walletMenu();
01250
01254
void submitFormAgain();
01255
01259
void updateActions();
01263
void slotPartRemoved( KParts::Part *part );
01267
void slotActiveFrameChanged( KParts::Part *part );
01271
void slotChildStarted( KIO::Job *job );
01275
void slotChildCompleted();
01279
void slotChildCompleted(
bool );
01283
void slotParentCompleted();
01287
void slotChildURLRequest( const KURL &url, const KParts::URLArgs &args );
01291
void slotChildDocCreated();
01292
01293
void slotLoaderRequestStarted( khtml::DocLoader*, khtml::CachedObject* obj);
01294
void slotLoaderRequestDone( khtml::DocLoader*, khtml::CachedObject *obj );
01295
void checkCompleted();
01296
01300
void slotAutoScroll();
01301
01302
void slotPrintFrame();
01303
01304
void slotSelectAll();
01305
01309
void slotProgressUpdate();
01310
01311
01312
01313
01314
void slotJobPercent( KIO::Job*,
unsigned long );
01315
01316
01317
01318
01319
void slotJobDone( KIO::Job* );
01320
01321
01322
01323
01324
void slotUserSheetStatDone( KIO::Job* );
01325
01326
01327
01328
01329
void slotJobSpeed( KIO::Job*,
unsigned long );
01330
01334
void slotClearSelection();
01335
01339
void slotZoomView(
int );
01340
01344
void slotHighlight( const
QString &,
int index,
int length );
01345
01349
void slotAutomaticDetectionLanguage(
int _id );
01350
01354
void slotToggleCaretMode();
01355
01359
void launchJSErrorDialog();
01360
01364
void removeJSErrorExtension();
01365
01369
void disableJSErrorExtension();
01370
01374
void jsErrorDialogContextMenu();
01375
01379
void restoreScrollPosition();
01380
01381 private:
01382
01383 KJSErrorDlg *jsErrorExtension();
01384
01385 enum StatusBarPriority { BarDefaultText, BarHoverText, BarOverrideText };
01386
void setStatusBarText(
const QString& text, StatusBarPriority p);
01387
01388
bool restoreURL(
const KURL &url );
01389
void emitSelectionChanged();
01390
01391
bool checkFrameAccess(
KHTMLPart *callingHtmlPart);
01392
bool openURLInFrame(
const KURL &url,
const KParts::URLArgs &urlArgs );
01393
void startAutoScroll();
01394
void stopAutoScroll();
01395
void overURL(
const QString &url,
const QString &target,
bool shiftPressed =
false );
01396
01397
bool processObjectRequest( khtml::ChildFrame *child,
const KURL &url,
const QString &mimetype );
01398
01399 KWallet::Wallet* wallet();
01400
01404
01405
01406
01407
01408
01409
01410
01411
void submitForm(
const char *action,
const QString &url,
const QByteArray &formData,
01412
const QString &target,
const QString& contentType = QString::null,
01413
const QString& boundary = QString::null );
01414
01415
void popupMenu(
const QString &url );
01416
01417
void init(
KHTMLView *view, GUIProfile prof );
01418
01419
01420
void clear();
01421
01422
bool scheduleScript(
const DOM::Node &n,
const QString& script);
01423
01424
QVariant crossFrameExecuteScript(
const QString& target,
const QString& script);
01425
QVariant executeScheduledScript();
01426
01427
bool requestFrame( khtml::RenderPart *frame,
const QString &url,
const QString &frameName,
01428
const QStringList &args =
QStringList(),
bool isIFrame =
false );
01429
01437
QString requestFrameName();
01438
01439
bool requestObject( khtml::RenderPart *frame,
const QString &url,
const QString &serviceType,
01440
const QStringList &args =
QStringList() );
01441
01442
bool requestObject( khtml::ChildFrame *child,
const KURL &url,
const KParts::URLArgs &args =
KParts::URLArgs() );
01443
01444
DOM::EventListener *createHTMLEventListener(
QString code,
QString name );
01445
01446 DOM::HTMLDocumentImpl *docImpl() const;
01447 DOM::DocumentImpl *xmlDocImpl() const;
01448 khtml::ChildFrame *frame( const
QObject *obj );
01449
01450 khtml::ChildFrame *recursiveFrameRequest(
KHTMLPart *callingHtmlPart, const
KURL &url, const KParts::URLArgs &args,
bool callParent = true );
01451
01452
bool checkLinkSecurity( const
KURL &linkURL,const
QString &message =
QString::null, const
QString &button =
QString::null );
01453
QVariant executeScript( const
QString& filename,
int baseLine, const DOM::
Node &n, const
QString& script );
01454
01455 KJSProxy *jScript();
01456
01457
KHTMLPart *opener();
01458
long cacheId() const;
01459
void setOpener(
KHTMLPart *_opener );
01460
bool openedByJS();
01461
void setOpenedByJS(
bool _openedByJS );
01462
01463
void checkEmitLoadEvent();
01464
void emitLoadEvent();
01465
01466
bool initFindNode(
bool selection,
bool reverse,
bool fromCursor );
01467
void findText();
01468
void findTextNext();
01469
void extendSelection( DOM::NodeImpl* node,
long offset, DOM::
Node& selectionNode,
long& selectionOffset,
bool right,
bool paragraph );
01479
void extendSelectionTo(
int x,
int y,
int absX,
int absY, const DOM::
Node &innerNode);
01483
bool isExtendingSelection() const;
01484 khtml::Decoder *createDecoder();
01485
QString defaultEncoding() const;
01486
01490
void zoomIn(const
int stepping[],
int count);
01494
void zoomOut(const
int stepping[],
int count);
01495
01496
void emitCaretPositionChanged(const DOM::
Node &node,
long offset);
01497
01498
void setDebugScript(
bool enable );
01499
01500 KHTMLPartPrivate *d;
01501 friend class KHTMLPartPrivate;
01502 };
01503
01504
01505 #endif