1 // -*- c-basic-offset: 2 -*-
2 /* This file is part of the KDE project
4 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
5 * 1999-2001 Lars Knoll <knoll@kde.org>
6 * 1999-2001 Antti Koivisto <koivisto@kde.org>
7 * 2000-2001 Simon Hausmann <hausmann@kde.org>
8 * 2000-2001 Dirk Mueller <mueller@kde.org>
9 * 2000 Stefan Schimanski <1Stein@gmx.de>
10 * Copyright (C) 2004 Apple Computer, Inc.
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public License
23 * along with this library; see the file COPYING.LIB. If not, write to
24 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 * Boston, MA 02111-1307, USA.
27 #ifndef __khtml_part_h__
28 #define __khtml_part_h__
30 #include "editing/text_granularity.h"
31 #include "editing/edit_actions.h"
33 #include <kparts/part.h>
34 #include <kparts/browserextension.h>
36 class KHTMLPartPrivate;
37 class KHTMLPartBrowserExtension;
41 class KJavaAppletContext;
45 class CSSComputedStyleDeclarationImpl;
46 class CSSMutableStyleDeclarationImpl;
47 class CSSStyleDeclarationImpl;
53 class HTMLAnchorElementImpl;
55 class HTMLDocumentImpl;
56 class HTMLElementImpl;
57 class HTMLEventListener;
58 class HTMLFormElementImpl;
59 class HTMLFrameElementImpl;
60 class HTMLIFrameElementImpl;
61 class HTMLMetaElementImpl;
62 class HTMLObjectElementImpl;
63 class HTMLTitleElementImpl;
73 class CSSStyleSelector;
75 class DrawContentsEvent;
79 class MouseDoubleClickEvent;
82 class MousePressEvent;
83 class MouseReleaseEvent;
85 class RenderPartObject;
93 class JSEventListener;
106 * This class is khtml's main class. It features an almost complete
107 * web browser, and html renderer.
109 * The easiest way to use this class (if you just want to display an HTML
110 * page at some URL) is the following:
113 * KURL url = "http://www.kde.org";
114 * KHTMLPart *w = new KHTMLPart();
116 * w->view()->resize(500, 400);
120 * By default Java and JavaScript support are disabled. You can enable them by
121 * using the @ref setJavaEnabled() and @ref setJScriptEnabled() methods.
123 * Some apps want to write their HTML code directly into the widget instead of
124 * it opening an url. You can also do that in the following way:
127 * QString myHTMLCode = ...;
128 * KHTMLPart *w = new KHTMLPart();
130 * w->write(myHTMLCode);
135 * You can do as many calls to write as you want. But there are two
136 * @ref write() methods, one accepting a @ref QString one accepting a
137 * @p char @p * argument. You should use one or the other
138 * (but not both) since the method using
139 * the @p char @p * argument does an additional decoding step to convert the
140 * written data to Unicode.
142 * @short HTML Browser Widget
143 * @author Lars Knoll (knoll@kde.org)
145 class KHTMLPart : public KParts::ReadOnlyPart
148 friend class KHTMLView;
149 friend class DOM::HTMLTitleElementImpl;
150 friend class DOM::HTMLFrameElementImpl;
151 friend class DOM::HTMLIFrameElementImpl;
152 friend class DOM::HTMLObjectElementImpl;
153 friend class DOM::HTMLAnchorElementImpl;
154 friend class DOM::HTMLMetaElementImpl;
155 friend class DOM::NodeImpl;
156 friend class KHTMLRun;
157 friend class DOM::HTMLFormElementImpl;
158 friend class khtml::RenderPartObject;
159 friend class KJS::Selection;
160 friend class KJS::SelectionFunc;
161 friend class KJS::Window;
162 friend class KJS::WindowFunc;
163 friend class KJS::JSEventListener;
164 friend class KJS::DOMDocument;
165 friend class KJSProxy;
166 friend class KHTMLPartBrowserExtension;
167 friend class DOM::DocumentImpl;
168 friend class DOM::HTMLDocumentImpl;
169 friend class KHTMLPartBrowserHostExtension;
170 friend class khtml::HTMLTokenizer;
171 friend class khtml::XMLTokenizer;
172 friend class khtml::RenderWidget;
173 friend class khtml::CSSStyleSelector;
174 friend class KHTMLPartIface;
176 Q_PROPERTY( bool javaScriptEnabled READ jScriptEnabled WRITE setJScriptEnabled )
177 Q_PROPERTY( bool javaEnabled READ javaEnabled WRITE setJavaEnabled )
178 Q_PROPERTY( bool autoloadImages READ autoloadImages WRITE setAutoloadImages )
179 Q_PROPERTY( bool dndEnabled READ dndEnabled WRITE setDNDEnabled )
180 Q_PROPERTY( bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled )
181 Q_PROPERTY( bool onlyLocalReferences READ onlyLocalReferences WRITE setOnlyLocalReferences )
182 Q_PROPERTY( QCString dcopObjectId READ dcopObjectId )
185 enum GUIProfile { DefaultGUI, BrowserViewGUI /* ... */ };
186 enum { NoXPosForVerticalArrowNavigation = INT_MIN };
189 * Constructs a new KHTMLPart.
191 * KHTML basically consists of two objects: The KHTMLPart itself,
192 * holding the document data (DOM document), and the @ref KHTMLView,
193 * derived from @ref QScrollView, in which the document content is
194 * rendered in. You can specify two different parent objects for a
195 * KHTMLPart, one parent for the KHTMLPart document and on parent
196 * for the @ref KHTMLView. If the second @p parent argument is 0L, then
197 * @p parentWidget is used as parent for both objects, the part and
200 KHTMLPart( QWidget *parentWidget = 0, const char *widgetname = 0,
201 QObject *parent = 0, const char *name = 0, GUIProfile prof = DefaultGUI );
203 KHTMLPart( KHTMLView *view, QObject *parent = 0, const char *name = 0, GUIProfile prof = DefaultGUI );
208 virtual ~KHTMLPart();
211 * Opens the specified URL @p url.
213 * Reimplemented from @ref KParts::ReadOnlyPart::openURL .
215 virtual bool openURL( const KURL &url );
217 void didExplicitOpen();
220 * Stops loading the document and kill all data requests (for images, etc.)
222 virtual bool closeURL();
226 * is called when a certain error situation (i.e. connection timed out) occured.
227 * default implementation either shows a KIO error dialog or loads a more verbose
228 * error description a as page, depending on the users configuration.
229 * @p job is the job that signaled the error situation
231 virtual void showError(KIO::Job* job);
235 * Returns a reference to the DOM HTML document (for non-HTML documents, returns null)
237 DOM::HTMLDocument htmlDocument() const;
240 * Returns a reference to the DOM document.
242 DOM::Document document() const;
245 * Returns the node that has the keyboard focus.
247 DOM::Node activeNode() const;
250 * Returns a pointer to the @ref KParts::BrowserExtension.
252 KParts::BrowserExtension *browserExtension() const;
255 * Returns a pointer to the HTML document's view.
257 KHTMLView *view() const;
260 * Enable/disable Javascript support. Note that this will
261 * in either case permanently override the default usersetting.
262 * If you want to have the default UserSettings, don't call this
265 void setJScriptEnabled( bool enable );
268 * Returns @p true if Javascript support is enabled or @p false
271 bool jScriptEnabled() const;
274 * Enable/disable the automatic forwarding by <meta http-equiv="refresh" ....>
276 void setMetaRefreshEnabled( bool enable );
279 * Returns @p true if automtaic forwarding is enabled.
281 bool metaRefreshEnabled() const;
284 * Execute the specified snippet of JavaScript code.
286 * Returns @p true if JavaScript was enabled, no error occured
287 * and the code returned true itself or @p false otherwise.
288 * @deprecated, use the one below.
290 QVariant executeScript( const QString &script, bool forceUserGesture = false );
292 * Same as above except the Node parameter specifying the 'this' value.
294 QVariant executeScript( const DOM::Node &n, const QString &script, bool forceUserGesture = false );
297 * Enables or disables Drag'n'Drop support. A drag operation is started if
298 * the users drags a link.
300 void setDNDEnabled( bool b );
302 * Returns whether Dragn'n'Drop support is enabled or not.
304 bool dndEnabled() const;
307 * Implementation of CSS property -khtml-user-drag == auto
309 virtual bool shouldDragAutoNode(DOM::NodeImpl*, int x, int y) const;
312 * Enables/disables Java applet support. Note that calling this function
313 * will permanently override the User settings about Java applet support.
314 * Not calling this function is the only way to let the default settings
317 void setJavaEnabled( bool enable );
320 * Return if Java applet support is enabled/disabled.
322 bool javaEnabled() const;
325 * Returns the java context of the applets. If no applet exists, 0 is returned.
327 KJavaAppletContext *javaContext();
330 * Returns the java context of the applets. If no context exists yet, a new one is
333 KJavaAppletContext *createJavaContext();
336 * Enables or disables plugins via, default is enabled
338 void setPluginsEnabled( bool enable );
341 * Returns trie if plugins are enabled/disabled.
343 bool pluginsEnabled() const;
346 * Specifies whether images contained in the document should be loaded
347 * automatically or not.
349 * @note Request will be ignored if called before @ref begin().
351 void setAutoloadImages( bool enable );
353 * Returns whether images contained in the document are loaded automatically
355 * @note that the returned information is unrelieable as long as no begin()
358 bool autoloadImages() const;
363 * Specify whether only local references ( stylesheets, images, scripts, subdocuments )
364 * should be loaded. ( default false - everything is loaded, if the more specific
367 void setOnlyLocalReferences(bool enable);
370 * Returns whether references should be loaded ( default false )
372 bool onlyLocalReferences() const;
374 #ifndef KDE_NO_COMPAT
375 void enableJScript(bool e) { setJScriptEnabled(e); }
376 void enableJava(bool e) { setJavaEnabled(e); }
377 void enablePlugins(bool e) { setPluginsEnabled(e); }
378 void autoloadImages(bool e) { setAutoloadImages(e); }
379 void enableMetaRefresh(bool e) { setMetaRefreshEnabled(e); }
380 bool setCharset( const QString &, bool ) { return true; }
382 KURL baseURL() const;
383 QString baseTarget() const;
387 * Returns the URL for the background Image (used by save background)
389 KURL backgroundURL() const;
392 * Schedules a redirection after @p delay seconds.
394 void scheduleRedirection(double delay, const QString &url, bool lockHistory = true);
397 * Schedules a location change.
398 * This is used for JavaScript-triggered location changes.
400 void scheduleLocationChange(const QString &url, bool lockHistory = true, bool userGesture = false);
401 bool isScheduledLocationChangePending() const;
404 * Schedules a history navigation operation (go forward, go back, etc.).
405 * This is used for JavaScript-triggered location changes.
407 void scheduleHistoryNavigation( int steps );
410 * Clears the widget and prepares it for new content.
412 * If you want @ref url() to return
413 * for example "file:/tmp/test.html", you can use the following code:
415 * view->begin( KURL("file:/tmp/test.html" ) );
418 * @param url is the url of the document to be displayed. Even if you
419 * are generating the HTML on the fly, it may be useful to specify
420 * a directory so that any pixmaps are found.
422 * @param xOffset is the initial horizontal scrollbar value. Usually
423 * you don't want to use this.
425 * @param yOffset is the initial vertical scrollbar value. Usually
426 * you don't want to use this.
428 * All child frames and the old document are removed if you call
431 virtual void begin( const KURL &url = KURL(), int xOffset = 0, int yOffset = 0 );
434 * Writes another part of the HTML code to the widget.
437 * this function many times in sequence. But remember: The fewer calls
438 * you make, the faster the widget will be.
440 * The HTML code is send through a decoder which decodes the stream to
443 * The @p len parameter is needed for streams encoded in utf-16,
444 * since these can have \0 chars in them. In case the encoding
445 * you're using isn't utf-16, you can safely leave out the length
448 * Attention: Don't mix calls to @ref write( const char *) with calls
449 * to @ref write( const QString & ).
451 * The result might not be what you want.
453 virtual void write( const char *str, int len = -1 );
456 * Writes another part of the HTML code to the widget.
459 * this function many times in sequence. But remember: The fewer calls
460 * you make, the faster the widget will be.
462 virtual void write( const QString &str );
465 * Call this after your last call to @ref write().
469 void endIfNotLoading();
472 * Similar to end, but called to abort a load rather than cleanly end.
477 * Prints the current HTML page layed out for the printer.
479 * (not implemented at the moment)
481 // void print(QPainter *, int pageHeight, int pageWidth);
484 * Paints the HTML page to a QPainter. See @ref KHTMLView::paint for details
486 void paint(QPainter *, const QRect &, int = 0, bool * = 0);
489 * Sets the encoding the page uses.
491 * This can be different from the charset. The widget will try to reload the current page in the new
492 * encoding, if url() is not empty.
494 bool setEncoding( const QString &name, bool override = false );
497 * Returns the encoding the page currently uses.
499 * Note that the encoding might be different from the charset.
501 QString encoding() const;
504 * Sets a user defined style sheet to be used on top of the HTML 4
505 * default style sheet.
507 * This gives a wide range of possibilities to
508 * change the layout of the page.
510 void setUserStyleSheet(const KURL &url);
513 * Sets a user defined style sheet to be used on top of the HTML 4
514 * default style sheet.
516 * This gives a wide range of possibilities to
517 * change the layout of the page.
519 void setUserStyleSheet(const QString &styleSheet);
524 * Sets the standard font style.
526 * @param name The font name to use for standard text.
528 void setStandardFont( const QString &name );
531 * Sets the fixed font style.
533 * @param name The font name to use for fixed text, e.g.
534 * the <tt><pre></tt> tag.
536 void setFixedFont( const QString &name );
539 * Finds the anchor named @p name.
541 * If the anchor is found, the widget
542 * scrolls to the closest position. Returns @p if the anchor has
545 bool gotoAnchor( const QString &name );
548 * Sets the cursor to use when the cursor is on a link.
550 void setURLCursor( const QCursor &c );
553 * Returns the cursor which is used when the cursor is on a link.
555 QCursor urlCursor() const;
558 * Initiates a text search.
560 void findTextBegin(DOM::NodeImpl *startNode = 0, int startPos = -1);
563 * Finds the next occurrence of the string or expression.
564 * If isRegExp is true then str is converted to a QRegExp, and caseSensitive is ignored.
566 bool findTextNext( const QString &str, bool forward, bool caseSensitive, bool isRegExp );
569 * Sets the Zoom factor. The value is given in percent, larger values mean a
570 * generally larger font and larger page contents. It is not guaranteed that
571 * all parts of the page are scaled with the same factor though.
573 * The given value should be in the range of 20..300, values outside that
574 * range are not guaranteed to work. A value of 100 will disable all zooming
575 * and show the page with the sizes determined via the given lengths in the
578 void setZoomFactor(int percent);
581 * Returns the current zoom factor.
583 int zoomFactor() const;
586 * Returns the text the user has marked.
588 virtual QString selectedText() const;
591 * Returns the selected part of the HTML.
593 const khtml::Selection &selection() const;
596 * Returns the granularity of the selection (character, word, line, paragraph).
598 khtml::ETextGranularity selectionGranularity() const;
601 * Sets the granularity of the selection (character, word, line, paragraph).
603 void KHTMLPart::setSelectionGranularity(khtml::ETextGranularity granularity) const;
606 * Returns the drag caret of the HTML.
608 const khtml::Selection &dragCaret() const;
611 * Sets the current selection.
613 void setSelection(const khtml::Selection &, bool closeTyping = true, bool keepTypingStyle = false);
616 * Returns a mark, to be used as emacs uses it.
618 const khtml::Selection &mark() const;
623 void setMark(const khtml::Selection &);
626 * Sets the current drag cart.
628 void setDragCaret(const khtml::Selection &);
631 * Clears the current selection.
633 void clearSelection();
636 * Invalidates the current selection.
638 void invalidateSelection();
641 * Controls the visibility of the selection.
643 void setCaretVisible(bool flag=true);
648 void paintCaret(QPainter *p, const QRect &rect) const;
651 * Paints the drag caret.
653 void paintDragCaret(QPainter *p, const QRect &rect) const;
656 * Set info for vertical arrow navigation.
658 void setXPosForVerticalArrowNavigation(int x);
661 * Get info for vertical arrow navigation.
663 int xPosForVerticalArrowNavigation() const;
666 * Returns the text for a part of the document.
668 QString text(const DOM::Range &) const;
671 * Has the user selected anything?
673 * Call @ref selectedText() to
674 * retrieve the selected text.
676 * @return @p true if there is text selected.
678 bool hasSelection() const;
681 * Marks all text in the document as selected.
686 * Returns whether editing should end in the given range
688 virtual bool shouldBeginEditing(const DOM::Range &) const;
691 * Returns whether editing should end in the given range
693 virtual bool shouldEndEditing(const DOM::Range &) const;
696 * Returns the contentEditable "override" value for the part
698 virtual bool isContentEditable() const;
701 * Returns the most recent edit command applied.
703 khtml::EditCommandPtr lastEditCommand();
706 * Called when editing has been applied.
708 void appliedEditing(khtml::EditCommandPtr &);
711 * Called when editing has been unapplied.
713 void unappliedEditing(khtml::EditCommandPtr &);
716 * Called when editing has been reapplied.
718 void reappliedEditing(khtml::EditCommandPtr &);
721 * Returns the typing style for the document.
723 DOM::CSSMutableStyleDeclarationImpl *typingStyle() const;
726 * Sets the typing style for the document.
728 void setTypingStyle(DOM::CSSMutableStyleDeclarationImpl *);
731 * Clears the typing style for the document.
733 void clearTypingStyle();
736 * Convenience method to show the document's view.
738 * Equivalent to widget()->show() or view()->show() .
743 * Convenience method to hide the document's view.
745 * Equivalent to widget()->hide() or view()->hide().
750 * Returns a reference to the partmanager instance which
751 * manages html frame objects.
753 KParts::PartManager *partManager();
757 * Saves the KHTMLPart's complete state (including child frame
758 * objects) to the provided @ref QDataStream.
760 * This is called from the @ref saveState() method of the
761 * @ref browserExtension().
763 virtual void saveState( QDataStream &stream );
765 * Restores the KHTMLPart's previously saved state (including
766 * child frame objects) from the provided QDataStream.
770 * This is called from the @ref restoreState() method of the
771 * @ref browserExtension() .
773 virtual void restoreState( QDataStream &stream );
776 virtual void tokenizerProcessedData() {};
779 * Returns the @p Node currently under the mouse
781 DOM::Node nodeUnderMouse() const;
786 const KHTMLSettings *settings() const;
789 * Returns a pointer to the parent KHTMLPart if the part is a frame
790 * in an HTML frameset.
792 * Returns 0L otherwise.
794 KHTMLPart *parentPart() const;
797 * Returns a list of names of all frame (including iframe) objects of
798 * the current document. Note that this method is not working recursively
801 QStringList frameNames() const;
803 QPtrList<KParts::ReadOnlyPart> frames() const;
805 KHTMLPart *childFrameNamed(const QString &name) const;
808 * Finds a frame by name. Returns 0L if frame can't be found.
810 KHTMLPart *findFrame( const QString &f );
813 * Return the current frame (the one that has focus)
814 * Not necessarily a direct child of ours, framesets can be nested.
815 * Returns "this" if this part isn't a frameset.
817 KParts::ReadOnlyPart *currentFrame() const;
820 * Returns whether a frame with the specified name is exists or not.
821 * In contrary to the @ref findFrame method this one also returns true
822 * if the frame is defined but no displaying component has been
825 bool frameExists( const QString &frameName );
830 * Sets the StatusBarText assigned
833 void setJSStatusBarText( const QString &text );
837 * Sets the DefaultStatusBarText assigned
838 * via window.defaultStatus
840 void setJSDefaultStatusBarText( const QString &text );
844 * Returns the StatusBarText assigned
847 QString jsStatusBarText() const;
851 * Returns the DefaultStatusBarText assigned
852 * via window.defaultStatus
854 QString jsDefaultStatusBarText() const;
857 * Referrer used for links in this page.
859 QString referrer() const;
862 * Last-modified date (in raw string format), if received in the [HTTP] headers.
864 QString lastModified() const;
867 * Loads a style sheet into the stylesheet cache.
869 void preloadStyleSheet(const QString &url, const QString &stylesheet);
872 * Loads a script into the script cache.
874 void preloadScript(const QString &url, const QString &script);
876 bool isPointInsideSelection(int x, int y);
878 virtual bool tabsToLinks() const;
879 virtual bool tabsToAllControls() const;
884 bool restored() const;
886 void incrementFrameCount();
887 void decrementFrameCount();
888 int topLevelFrameCount();
890 // Editing operations.
891 // Not clear if these will be wanted in KHTMLPart by KDE,
892 // but for now these bridge so we don't have to pepper the
893 // KHTML code with WebCore-specific stuff.
894 enum TriState { falseTriState, trueTriState, mixedTriState };
895 void copyToPasteboard();
896 void cutToPasteboard();
897 void pasteFromPasteboard();
898 bool canPaste() const;
901 bool canRedo() const;
902 bool canUndo() const;
903 void computeAndSetTypingStyle(DOM::CSSStyleDeclarationImpl *, khtml::EditAction editingAction=khtml::EditActionUnspecified);
904 void applyStyle(DOM::CSSStyleDeclarationImpl *, khtml::EditAction editingAction=khtml::EditActionUnspecified);
905 void applyParagraphStyle(DOM::CSSStyleDeclarationImpl *, khtml::EditAction editingAction=khtml::EditActionUnspecified);
906 TriState selectionHasStyle(DOM::CSSStyleDeclarationImpl *) const;
907 bool selectionStartHasStyle(DOM::CSSStyleDeclarationImpl *) const;
908 DOM::DOMString selectionStartStylePropertyValue(int stylePropertyID) const;
909 void applyEditingStyleToBodyElement() const;
910 void removeEditingStyleFromBodyElement() const;
911 void applyEditingStyleToElement(DOM::ElementImpl *) const;
912 void removeEditingStyleFromElement(DOM::ElementImpl *) const;
914 virtual bool isCharacterSmartReplaceExempt(const QChar &, bool);
916 // Used to keep the part alive when running a script that might destroy it.
921 * Emitted if the cursor is moved over an URL.
923 void onURL( const QString &url );
926 * Emitted when the user clicks the right mouse button on the document.
928 void popupMenu(const QString &url, const QPoint &point);
931 * This signal is emitted when the selection changes.
933 void selectionChanged();
936 * This signal is emitted when an element retrieves the
937 * keyboard focus. Note that the signal argument can be
938 * a null node if no element is active, meaning a node
939 * has explicitly been deactivated without a new one
942 void nodeActivated(const DOM::Node &);
947 * returns a KURL object for the given url. Use when
948 * you know what you're doing.
950 KURL completeURL( const QString &url );
955 * presents a detailed error message to the user.
956 * @p errorCode kio error code, eg KIO::ERR_SERVER_TIMEOUT.
957 * @p text kio additional information text.
958 * @p url the url that triggered the error.
960 void htmlError(int errorCode, const QString& text, const KURL& reqUrl);
962 virtual void customEvent( QCustomEvent *event );
965 * Eventhandler of the khtml::MousePressEvent.
967 virtual void khtmlMousePressEvent( khtml::MousePressEvent *event );
969 * Eventhandler for the khtml::MouseDoubleClickEvent.
971 virtual void khtmlMouseDoubleClickEvent( khtml::MouseDoubleClickEvent * );
974 * Eventhandler for the khtml::MouseDoubleMoveEvent.
976 virtual void khtmlMouseMoveEvent( khtml::MouseMoveEvent *event );
978 * Eventhandler for the khtml::MouseMoveEvent.
980 virtual void khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *event );
982 * Eventhandler for the khtml::DrawContentsEvent.
984 virtual void khtmlDrawContentsEvent( khtml::DrawContentsEvent * );
986 void selectClosestWordFromMouseEvent(QMouseEvent *mouse, DOM::Node &innerNode, int x, int y);
990 * Internal reimplementation of KParts::Part::guiActivateEvent .
992 virtual void guiActivateEvent( KParts::GUIActivateEvent *event );
996 * Internal empty reimplementation of @ref KParts::ReadOnlyPart::openFile .
998 virtual bool openFile();
1000 virtual void urlSelected( const QString &url, int button, int state,
1001 const QString &_target, KParts::URLArgs args = KParts::URLArgs());
1005 * This method is called when a new embedded object (include html frames) is to be created.
1006 * Reimplement it if you want to add support for certain embeddable objects without registering
1007 * them in the KDE wide registry system (KSyCoCa) . Another reason for re-implementing this
1008 * method could be if you want to derive from KTHMLPart and also want all html frame objects
1009 * to be a object of your derived type, in which case you should return a new instance for
1010 * the mimetype 'text/html' .
1012 virtual KParts::ReadOnlyPart *createPart( QWidget *parentWidget, const char *widgetName,
1013 QObject *parent, const char *name,
1014 const QString &mimetype, QString &serviceName,
1015 QStringList &serviceTypes, const QStringList ¶ms);
1021 * Sets the focussed node of the document to the specified node. If the node is a form control, the control will
1022 * receive focus in the same way that it would if the user had clicked on it or tabbed to it with the keyboard. For
1023 * most other types of elements, there is no visul indiction of whether or not they are focussed.
1025 * See @ref activeNode
1027 * @param node The node to focus
1029 void setActiveNode(const DOM::Node &node);
1032 * Stops all animated images on the current and child pages
1034 void stopAnimations();
1036 QCString dcopObjectId() const;
1043 void reparseConfiguration();
1048 void slotData( KIO::Job*, const QByteArray &data );
1052 void slotRestoreData( const QByteArray &data );
1056 void slotFinished( KIO::Job* );
1060 void slotFinishedParsing();
1064 void slotRedirect();
1068 void slotRedirection(KIO::Job*, const KURL&);
1072 void slotDebugDOMTree();
1076 void slotDebugRenderTree();
1081 virtual void slotViewDocumentSource();
1085 virtual void slotViewFrameSource();
1089 virtual void slotSaveBackground();
1093 virtual void slotSaveDocument();
1097 virtual void slotSaveFrame();
1101 virtual void slotSecurity();
1105 virtual void slotSetEncoding();
1110 virtual void slotUseStylesheet();
1112 virtual void slotFind();
1113 virtual void slotFindDone();
1114 virtual void slotFindDialogDestroyed();
1124 void slotLoadImages();
1129 void submitFormAgain();
1134 void updateActions();
1138 void slotPartRemoved( KParts::Part *part );
1142 void slotActiveFrameChanged( KParts::Part *part );
1146 void slotChildStarted( KIO::Job *job );
1150 void slotChildCompleted();
1154 void slotChildCompleted( bool );
1158 void slotParentCompleted();
1162 void slotChildURLRequest( const KURL &url, const KParts::URLArgs &args );
1164 void slotLoaderRequestStarted( khtml::DocLoader*, khtml::CachedObject* obj);
1165 void slotLoaderRequestDone( khtml::DocLoader*, khtml::CachedObject *obj );
1166 void checkCompleted();
1171 void slotShowDocument( const QString &url, const QString &target );
1176 void slotAutoScroll();
1178 void slotPrintFrame();
1180 void slotSelectAll();
1185 void slotProgressUpdate();
1190 void slotJobPercent(KIO::Job*, unsigned long);
1195 void slotJobSpeed(KIO::Job*, unsigned long);
1200 void slotClearSelection();
1202 void slotEndLifeSupport();
1210 bool restoreURL( const KURL &url );
1215 void clearCaretRectIfNeeded();
1220 void setFocusNodeIfNeeded();
1225 void selectionLayoutChanged();
1230 void emitSelectionChanged();
1235 void timerEvent(QTimerEvent *);
1240 bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
1242 void startAutoScroll();
1243 void stopAutoScroll();
1244 void overURL( const QString &url, const QString &target, bool shiftPressed = false );
1249 bool processObjectRequest( khtml::ChildFrame *child, const KURL &url, const QString &mimetype );
1254 void submitForm( const char *action, const QString &url, const khtml::FormData &formData,
1255 const QString &target, const QString& contentType = QString::null,
1256 const QString& boundary = QString::null );
1261 void popupMenu( const QString &url );
1264 void init( KHTMLView *view, GUIProfile prof );
1266 virtual void clear();
1268 bool scheduleScript( const DOM::Node &n, const QString& script);
1270 QVariant executeScheduledScript();
1272 bool requestFrame( khtml::RenderPart *frame, const QString &url, const QString &frameName,
1273 const QStringList ¶mNames = QStringList(), const QStringList ¶mValues = QStringList(), bool isIFrame = false );
1276 * @internal returns a name for a frame without a name.
1277 * This function returns a sequence of names.
1278 * All names in a sequence are different but the sequence is
1280 * The sequence is reset in clear().
1282 QString requestFrameName();
1284 bool requestObject( khtml::RenderPart *frame, const QString &url, const QString &serviceType,
1285 const QStringList ¶mNames = QStringList(), const QStringList ¶mValues = QStringList() );
1287 bool requestObject( khtml::ChildFrame *child, const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
1289 DOM::EventListener *createHTMLEventListener( QString code );
1292 DOM::DocumentImpl *xmlDocImpl() const;
1293 void replaceDocImpl(DOM::DocumentImpl* newDoc);
1296 khtml::ChildFrame *childFrame( const QObject *obj );
1298 khtml::ChildFrame *recursiveFrameRequest( const KURL &url, const KParts::URLArgs &args, bool callParent = true );
1300 void connectChild(const khtml::ChildFrame *) const;
1301 void disconnectChild(const khtml::ChildFrame *) const;
1303 bool checkLinkSecurity(const KURL &linkURL,const QString &message = QString::null, const QString &button = QString::null);
1304 QVariant executeScript(QString filename, int baseLine, const DOM::Node &n, const QString &script);
1306 void cancelRedirection(bool newLoadInProgress = false);
1308 KJSProxy *jScript();
1313 KHTMLPart *opener();
1317 long cacheId() const;
1318 void setOpener(KHTMLPart *_opener);
1320 void setOpenedByJS(bool _openedByJS);
1322 void checkEmitLoadEvent();
1323 void emitLoadEvent();
1325 void receivedFirstData();
1327 void replaceContentsWithScriptResult( const KURL &url );
1329 bool handleMouseMoveEventDrag(khtml::MouseMoveEvent *event);
1330 bool handleMouseMoveEventOver(khtml::MouseMoveEvent *event);
1331 void handleMouseMoveEventSelection(khtml::MouseMoveEvent *event);
1334 * @internal Extracts anchor and tries both encoded and decoded form.
1339 void handleMousePressEventSingleClick(khtml::MousePressEvent *event);
1340 void handleMousePressEventDoubleClick(khtml::MousePressEvent *event);
1341 void handleMousePressEventTripleClick(khtml::MousePressEvent *event);
1344 DOM::CSSComputedStyleDeclarationImpl *selectionComputedStyle(DOM::NodeImpl *&nodeToRemove) const;
1346 KHTMLPartPrivate *d;
1347 friend class KHTMLPartPrivate;
1348 friend class khtml::Selection;
1352 friend class KWQKHTMLPart;
1355 void completed(bool);
1356 bool didOpenURL(const KURL &);
1357 void setStatusBarText(const QString &);
1358 void started(KIO::Job *);
1359 void frameDetached();
1360 virtual void didFirstLayout() {}
1367 #include "KWQKHTMLPart.h"