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
#include <kfinddialog.h>
00036
00037
#include <qregexp.h>
00038
00039
class KHTMLPartPrivate;
00040
class KHTMLPartBrowserExtension;
00041
class KJSProxy;
00042
class KHTMLView;
00043
class KHTMLSettings;
00044
class KJavaAppletContext;
00045
class KJSErrorDlg;
00046
00047
namespace DOM
00048 {
00049
class HTMLDocument;
00050
class HTMLDocumentImpl;
00051
class DocumentImpl;
00052
class HTMLTitleElementImpl;
00053
class HTMLElementImpl;
00054
class HTMLFrameElementImpl;
00055
class HTMLIFrameElementImpl;
00056
class HTMLObjectElementImpl;
00057
class HTMLFormElementImpl;
00058
class HTMLAnchorElementImpl;
00059
class HTMLMetaElementImpl;
00060
class NodeImpl;
00061
class Node;
00062
class HTMLEventListener;
00063
class EventListener;
00064 }
00065
00066
namespace KJS
00067 {
00068
class Interpreter;
00069 }
00070
00071
namespace khtml
00072 {
00073
class DocLoader;
00074
class RenderPart;
00075
class RenderPartObject;
00076
struct ChildFrame;
00077
class MouseEvent;
00078
class MousePressEvent;
00079
class MouseDoubleClickEvent;
00080
class MouseMoveEvent;
00081
class MouseReleaseEvent;
00082
class DrawContentsEvent;
00083
class CachedObject;
00084
class RenderWidget;
00085
class CSSStyleSelector;
00086
class HTMLTokenizer;
00087
class Decoder;
00088
class XMLTokenizer;
00089 }
00090
00091
namespace KJS {
00092
class Window;
00093
class WindowFunc;
00094
class ExternalFunc;
00095
class JSEventListener;
00096
class JSLazyEventListener;
00097
class JSNodeFilter;
00098
class DOMDocument;
00099
class SourceFile;
00100
class ScheduledAction;
00101 }
00102
00103
namespace KParts
00104 {
00105
class PartManager;
00106
class LiveConnectExtension;
00107 }
00108
00109
namespace KWallet
00110 {
00111
class Wallet;
00112 }
00113
00185 class KHTMLPart :
public KParts::
ReadOnlyPart
00186 {
00187 Q_OBJECT
00188
friend class KHTMLView;
00189
friend class DOM::HTMLTitleElementImpl;
00190
friend class DOM::HTMLFrameElementImpl;
00191
friend class DOM::HTMLIFrameElementImpl;
00192
friend class DOM::HTMLObjectElementImpl;
00193
friend class DOM::HTMLAnchorElementImpl;
00194
friend class DOM::HTMLMetaElementImpl;
00195
friend class DOM::NodeImpl;
00196
friend class KHTMLRun;
00197
friend class DOM::HTMLFormElementImpl;
00198
friend class khtml::RenderPartObject;
00199
friend class KJS::Window;
00200
friend class KJS::ScheduledAction;
00201
friend class KJS::JSNodeFilter;
00202
friend class KJS::WindowFunc;
00203
friend class KJS::ExternalFunc;
00204
friend class KJS::JSEventListener;
00205
friend class KJS::JSLazyEventListener;
00206
friend class KJS::DOMDocument;
00207
friend class KJS::SourceFile;
00208
friend class KJSProxy;
00209
friend class KHTMLPartBrowserExtension;
00210
friend class DOM::DocumentImpl;
00211
friend class DOM::HTMLDocumentImpl;
00212
friend class KHTMLPartBrowserHostExtension;
00213
friend class khtml::HTMLTokenizer;
00214
friend class khtml::XMLTokenizer;
00215
friend class khtml::RenderWidget;
00216
friend class khtml::CSSStyleSelector;
00217
friend class KHTMLPartIface;
00218
friend class KHTMLPartFunction;
00219
00220 Q_PROPERTY(
bool javaScriptEnabled READ
jScriptEnabled WRITE
setJScriptEnabled )
00221 Q_PROPERTY(
bool javaEnabled READ javaEnabled WRITE
setJavaEnabled )
00222 Q_PROPERTY(
bool autoloadImages READ autoloadImages WRITE
setAutoloadImages )
00223 Q_PROPERTY(
bool dndEnabled READ dndEnabled WRITE
setDNDEnabled )
00224 Q_PROPERTY(
bool pluginsEnabled READ pluginsEnabled WRITE
setPluginsEnabled )
00225 Q_PROPERTY(
bool onlyLocalReferences READ onlyLocalReferences WRITE
setOnlyLocalReferences )
00226 Q_PROPERTY(
QCString dcopObjectId READ dcopObjectId )
00227 Q_PROPERTY(
bool modified READ
isModified )
00228
00229
public:
00230
enum GUIProfile { DefaultGUI, BrowserViewGUI };
00231
00244
KHTMLPart(
QWidget *parentWidget = 0,
const char *widgetname = 0,
00245
QObject *parent = 0,
const char *name = 0, GUIProfile prof = DefaultGUI );
00246
00247
KHTMLPart(
KHTMLView *
view,
QObject *parent = 0,
const char *name = 0, GUIProfile prof = DefaultGUI );
00248
00252
virtual ~KHTMLPart();
00253
00259
virtual bool openURL(
const KURL &url );
00260
00264
virtual bool closeURL();
00265
00272
virtual void showError(
KIO::Job* job );
00273
00277
DOM::HTMLDocument htmlDocument()
const;
00278
00282
DOM::Document document()
const;
00283
00287
DOM::Node activeNode()
const;
00288
00292
KParts::BrowserExtension *
browserExtension()
const;
00293
KParts::LiveConnectExtension *liveConnectExtension(
const khtml::RenderPart *)
const;
00294
KParts::BrowserHostExtension *browserHostExtension()
const;
00295
00299
KHTMLView *
view()
const;
00300
00307
void setJScriptEnabled(
bool enable );
00308
00313
bool jScriptEnabled()
const;
00314
00332 KJS::Interpreter *
jScriptInterpreter();
00333
00337
void setStatusMessagesEnabled(
bool enable );
00338
00342
bool statusMessagesEnabled()
const;
00343
00347
void setMetaRefreshEnabled(
bool enable );
00348
00352
bool metaRefreshEnabled()
const;
00353
00358
QVariant executeScript(
const DOM::Node &n,
const QString &script );
00359
00364
void setDNDEnabled(
bool b );
00365
00369
bool dndEnabled()
const;
00370
00377
void setJavaEnabled(
bool enable );
00378
00382
bool javaEnabled()
const;
00383
00387 KJavaAppletContext *
javaContext();
00388
00393 KJavaAppletContext *
createJavaContext();
00394
00398
void setPluginsEnabled(
bool enable );
00399
00403
bool pluginsEnabled()
const;
00404
00411
void setAutoloadImages(
bool enable );
00418
bool autoloadImages()
const;
00419
00436
void setOnlyLocalReferences(
bool enable );
00437
00442
bool onlyLocalReferences()
const;
00443
00447
bool isCaretMode()
const;
00448
00453
bool isEditable()
const;
00454
00468
void setCaretPosition(
DOM::Node node,
long offset,
bool extendSelection =
false);
00469
00477 enum CaretDisplayPolicy {
00478 CaretVisible, CaretInvisible, CaretBlink
00479 };
00480
00485 CaretDisplayPolicy
caretDisplayPolicyNonFocused() const;
00486
00497
void setCaretDisplayPolicyNonFocused(CaretDisplayPolicy policy);
00498
00499 #ifndef KDE_NO_COMPAT
00500
void enableJScript(
bool e ) {
setJScriptEnabled(e); }
00501
void enableJava(
bool e ) {
setJavaEnabled(e); }
00502
void enablePlugins(
bool e ) {
setPluginsEnabled(e); }
00503
void autoloadImages(
bool e ) {
setAutoloadImages(e); }
00504
void enableMetaRefresh(
bool e ) {
setMetaRefreshEnabled(e); }
00505
bool setCharset(
const QString &,
bool ) {
return true; }
00506
00507
KURL baseURL() const;
00508
QString baseTarget() const;
00509 #endif
00510
00514
KURL backgroundURL() const;
00515
00519
void scheduleRedirection(
int delay, const
QString &url,
bool lockHistory = true );
00520
00543 virtual
void begin( const
KURL &url =
KURL(),
int xOffset = 0,
int yOffset = 0 );
00544
00565 virtual
void write( const
char *str,
int len = -1 );
00566
00574 virtual
void write( const
QString &str );
00575
00579 virtual
void end();
00580
00581
00582
00583
00584
00585
00586
00587
00591
void paint(
QPainter *, const
QRect &,
int = 0,
bool * = 0 );
00592
00599
bool setEncoding( const
QString &name,
bool override = false );
00600
00606
QString encoding() const;
00607
00615
void setUserStyleSheet( const KURL &url );
00616
00624
void setUserStyleSheet( const
QString &styleSheet );
00625
00626 public:
00627
00633
void setStandardFont( const
QString &name );
00634
00641
void setFixedFont( const
QString &name );
00642
00650
bool gotoAnchor( const
QString &name );
00651
00658
bool nextAnchor();
00659
00664
bool prevAnchor();
00665
00669
void setURLCursor( const
QCursor &c );
00670
00674
QCursor urlCursor() const;
00675
00680 enum FindOptions
00681 {
00682 FindLinksOnly = 1 * KFindDialog::MinimumUserOption,
00683 FindNoPopups = 2 * KFindDialog::MinimumUserOption
00684
00685 };
00686
00692
void findText();
00693
00702
void findText(
const QString &str,
long options,
QWidget *parent = 0,
00703 KFindDialog *findDialog = 0 );
00704
00708
void findTextBegin();
00709
00715
bool findTextNext(
const QString &str,
bool forward,
bool caseSensitive,
bool isRegExp );
00716
00722
bool findTextNext();
00723
00734
void setZoomFactor(
int percent);
00735
00739
int zoomFactor() const;
00740
00744 virtual
QString selectedText() const;
00745
00749 DOM::Range selection() const;
00750
00762
void selection(DOM::
Node &startNode,
long &startOffset,
00763 DOM::
Node &endNode,
long &endOffset) const;
00764
00768
void setSelection( const DOM::Range & );
00769
00778
bool hasSelection() const;
00779
00783
void selectAll();
00784
00790
void show();
00791
00797
void hide();
00798
00803 KParts::PartManager *partManager();
00804
00812 virtual
void saveState(
QDataStream &stream );
00822 virtual
void restoreState(
QDataStream &stream );
00823
00830 DOM::
Node nodeUnderMouse() const;
00831
00840 DOM::
Node nonSharedNodeUnderMouse() const;
00841
00845 const
KHTMLSettings *settings() const;
00846
00853
KHTMLPart *parentPart();
00854
00860
QStringList frameNames() const;
00861
00862
QPtrList<KParts::ReadOnlyPart> frames() const;
00863
00867
KHTMLPart *findFrame( const
QString &f );
00868
00877
KHTMLPart *findFrameParent( KParts::ReadOnlyPart *callingPart, const
QString &f, khtml::ChildFrame **childFrame=0 );
00878
00884 KParts::ReadOnlyPart *currentFrame() const;
00885
00892
bool frameExists( const
QString &frameName );
00893
00894
00900
void setJSStatusBarText( const
QString &text );
00901
00907
void setJSDefaultStatusBarText( const
QString &text );
00908
00914
QString jsStatusBarText() const;
00915
00921
QString jsDefaultStatusBarText() const;
00922
00926
QString referrer() const;
00927
00931
QString pageReferrer() const;
00932
00936
QString lastModified() const;
00937
00941
void preloadStyleSheet( const
QString &url, const
QString &stylesheet );
00942
00946
void preloadScript( const
QString &url, const
QString &script );
00947
00951
bool restored() const;
00952
00953
00954 enum FormNotification { NoNotification = 0, Before, Only, Unused=255 };
00961
void setFormNotification(FormNotification fn);
00962
00969 FormNotification
formNotification() const;
00970
00978
KURL toplevelURL();
00979
00986
bool isModified() const;
00987
00988 signals:
00992
void onURL( const
QString &url );
00993
00997
void popupMenu( const
QString &url, const
QPoint &point );
00998
01002
void selectionChanged();
01003
01011
void nodeActivated( const DOM::
Node & );
01012
01015
void docCreated();
01016
01028
void caretPositionChanged(const DOM::Node &node,
long offset);
01029
01030
01037
void formSubmitNotification(const
char *action, const
QString& url,
01038 const
QByteArray& formData, const
QString& target,
01039 const
QString& contentType, const
QString& boundary);
01040
01041
01042 protected:
01043
01048
KURL completeURL( const
QString &url );
01049
01056
void htmlError(
int errorCode, const
QString& text, const
KURL& reqUrl );
01057
01058 virtual
void customEvent(
QCustomEvent *event );
01059
01063 virtual
void khtmlMousePressEvent( khtml::MousePressEvent *event );
01067 virtual
void khtmlMouseDoubleClickEvent( khtml::MouseDoubleClickEvent * );
01071 virtual
void khtmlMouseMoveEvent( khtml::MouseMoveEvent *event );
01075 virtual
void khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *event );
01079 virtual
void khtmlDrawContentsEvent( khtml::DrawContentsEvent * );
01080
01084 virtual
void guiActivateEvent( KParts::GUIActivateEvent *event );
01085
01089 virtual
bool openFile();
01090
01091 virtual
void urlSelected( const
QString &url,
int button,
int state,
01092 const
QString &_target, KParts::URLArgs args = KParts::URLArgs());
01093
01102 virtual KParts::ReadOnlyPart *createPart(
QWidget *parentWidget, const
char *widgetName,
01103
QObject *parent, const
char *name,
01104 const
QString &mimetype,
QString &serviceName,
01105
QStringList &serviceTypes, const
QStringList ¶ms);
01106
01107
01108
01109
bool pluginPageQuestionAsked( const
QString& mimetype ) const;
01110
void setPluginPageQuestionAsked( const
QString& mimetype );
01111
01112 enum PageSecurity { NotCrypted, Encrypted, Mixed };
01113
void setPageSecurity( PageSecurity sec );
01114
01118
virtual bool doOpenStream(
const QString& mimeType );
01119
01123
virtual bool doWriteStream(
const QByteArray& data );
01124
01128
virtual bool doCloseStream();
01129
01130
public slots:
01131
01141
void setActiveNode(
const DOM::Node &node );
01142
01146
void stopAnimations();
01147
01148
QCString dcopObjectId() const;
01149
01157
QVariant executeScript( const
QString &script );
01158
01169
void setCaretMode(
bool enable);
01170
01182
void setEditable(
bool enable);
01183
01200
void setCaretVisible(
bool show);
01201
01202
01203
01204
01205
01206
void submitFormProxy( const
char *action, const
QString &url,
01207 const
QByteArray &formData,
01208 const
QString &target,
01209 const
QString& contentType =
QString::null,
01210 const
QString& boundary =
QString::null );
01211
01212 private slots:
01217
void gotoAnchor();
01218
01222
void reparseConfiguration();
01223
01227
void slotData( KIO::Job*, const
QByteArray &data );
01231
void slotInfoMessage( KIO::Job*, const
QString& msg );
01235
void slotRestoreData( const
QByteArray &data );
01239
void slotFinished( KIO::Job* );
01243
void slotFinishedParsing();
01247
void slotRedirect();
01251
void slotRedirection( KIO::Job*, const
KURL& );
01255
void slotDebugScript();
01259
void slotDebugDOMTree();
01263
void slotDebugRenderTree();
01267
void slotStopAnimations();
01271 virtual
void slotViewDocumentSource();
01275 virtual
void slotViewFrameSource();
01279
void slotViewPageInfo();
01283 virtual
void slotSaveBackground();
01287 virtual
void slotSaveDocument();
01291 virtual
void slotSaveFrame();
01295 virtual
void slotSecurity();
01299 virtual
void slotSetEncoding();
01300
01304 virtual
void slotUseStylesheet();
01305
01306 virtual
void slotFind();
01307 virtual
void slotFindDone();
01308 virtual
void slotFindDialogDestroyed();
01309
void slotFindNext();
01310
01311
void slotIncZoom();
01312
void slotDecZoom();
01313
void slotIncZoomFast();
01314
void slotDecZoomFast();
01315
01316
void slotLoadImages();
01317
void slotWalletClosed();
01318
void launchWalletManager();
01319
void walletMenu();
01320
01324
void submitFormAgain();
01325
01329
void updateActions();
01333
void slotPartRemoved( KParts::Part *part );
01337
void slotActiveFrameChanged( KParts::Part *part );
01341
void slotChildStarted( KIO::Job *job );
01345
void slotChildCompleted();
01349
void slotChildCompleted(
bool );
01353
void slotParentCompleted();
01357
void slotChildURLRequest( const KURL &url, const KParts::URLArgs &args );
01361
void slotChildDocCreated();
01365
void slotRequestFocus( KParts::ReadOnlyPart * );
01366
void slotLoaderRequestStarted( khtml::DocLoader*, khtml::CachedObject* obj);
01367
void slotLoaderRequestDone( khtml::DocLoader*, khtml::CachedObject *obj );
01368
void checkCompleted();
01369
01373
void slotAutoScroll();
01374
01375
void slotPrintFrame();
01376
01377
void slotSelectAll();
01378
01382
void slotProgressUpdate();
01383
01384
01385
01386
01387
void slotJobPercent( KIO::Job*,
unsigned long );
01388
01389
01390
01391
01392
void slotJobDone( KIO::Job* );
01393
01394
01395
01396
01397
void slotUserSheetStatDone( KIO::Job* );
01398
01399
01400
01401
01402
void slotJobSpeed( KIO::Job*,
unsigned long );
01403
01407
void slotClearSelection();
01408
01412
void slotZoomView(
int );
01413
01417
void slotHighlight( const
QString &,
int index,
int length );
01418
01422
void slotAutomaticDetectionLanguage(
int _id );
01423
01427
void slotToggleCaretMode();
01428
01432
void launchJSErrorDialog();
01433
01437
void removeJSErrorExtension();
01438
01442
void disableJSErrorExtension();
01443
01447
void jsErrorDialogContextMenu();
01448
01452
void restoreScrollPosition();
01453
01454 private:
01455
01456 KJSErrorDlg *jsErrorExtension();
01457
01458 enum StatusBarPriority { BarDefaultText, BarHoverText, BarOverrideText };
01459
void setStatusBarText(
const QString& text, StatusBarPriority p);
01460
01461
bool restoreURL(
const KURL &url );
01462
void emitSelectionChanged();
01463
01464
bool checkFrameAccess(
KHTMLPart *callingHtmlPart);
01465
bool openURLInFrame(
const KURL &url,
const KParts::URLArgs &urlArgs );
01466
void startAutoScroll();
01467
void stopAutoScroll();
01468
void overURL(
const QString &url,
const QString &target,
bool shiftPressed =
false );
01469
01470
bool processObjectRequest( khtml::ChildFrame *child,
const KURL &url,
const QString &mimetype );
01471
01472 KWallet::Wallet* wallet();
01473
01477
01478
01479
01480
01481
01482
01483
01484
void submitForm(
const char *action,
const QString &url,
const QByteArray &formData,
01485
const QString &target,
const QString& contentType = QString::null,
01486
const QString& boundary = QString::null );
01487
01488
void popupMenu(
const QString &url );
01489
01490
void init(
KHTMLView *view, GUIProfile prof );
01491
01492
01493
void clear();
01494
01495
bool scheduleScript(
const DOM::Node &n,
const QString& script);
01496
01497
QVariant crossFrameExecuteScript(
const QString& target,
const QString& script);
01498
QVariant executeScheduledScript();
01499
01500
bool requestFrame( khtml::RenderPart *frame,
const QString &url,
const QString &frameName,
01501
const QStringList &args =
QStringList(),
bool isIFrame =
false );
01502
01510
QString requestFrameName();
01511
01512
bool requestObject( khtml::RenderPart *frame,
const QString &url,
const QString &serviceType,
01513
const QStringList &args =
QStringList() );
01514
01515
bool requestObject( khtml::ChildFrame *child,
const KURL &url,
const KParts::URLArgs &args =
KParts::URLArgs() );
01516
01517
DOM::EventListener *createHTMLEventListener(
QString code,
QString name );
01518
01519 DOM::HTMLDocumentImpl *docImpl() const;
01520 DOM::DocumentImpl *xmlDocImpl() const;
01521 khtml::ChildFrame *frame( const
QObject *obj );
01522
01523 khtml::ChildFrame *recursiveFrameRequest(
KHTMLPart *callingHtmlPart, const
KURL &url, const KParts::URLArgs &args,
bool callParent = true );
01524
01525
bool checkLinkSecurity( const
KURL &linkURL,const
QString &message =
QString::null, const
QString &button =
QString::null );
01526
QVariant executeScript( const
QString& filename,
int baseLine, const DOM::
Node &n, const
QString& script );
01527
01528 KJSProxy *jScript();
01529
01530
KHTMLPart *opener();
01531
long cacheId() const;
01532
void setOpener(
KHTMLPart *_opener );
01533
bool openedByJS();
01534
void setOpenedByJS(
bool _openedByJS );
01535
01536
void checkEmitLoadEvent();
01537
void emitLoadEvent();
01538
01539
bool initFindNode(
bool selection,
bool reverse,
bool fromCursor );
01540
01541
void extendSelection( DOM::NodeImpl* node,
long offset, DOM::
Node& selectionNode,
long& selectionOffset,
bool right,
bool paragraph );
01551
void extendSelectionTo(
int x,
int y,
int absX,
int absY, const DOM::
Node &innerNode);
01555
bool isExtendingSelection() const;
01556 khtml::Decoder *createDecoder();
01557
QString defaultEncoding() const;
01558
01562
void zoomIn(const
int stepping[],
int count);
01566
void zoomOut(const
int stepping[],
int count);
01567
01568
void emitCaretPositionChanged(const DOM::
Node &node,
long offset);
01569
01570
void setDebugScript(
bool enable );
01571
01572 KHTMLPartPrivate *d;
01573 friend class KHTMLPartPrivate;
01574 };
01575
01576
01577 #endif