fix logic
[personal-kdelibs.git] / khtml / khtml_part.h
blob1464f4bb4f58e49530f4a126b7c6a6f2a510b875
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>
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
26 #ifndef __khtml_part_h__
27 #define __khtml_part_h__
29 #include "dom/dom_doc.h"
30 #include "dom/dom2_range.h"
32 #include <kparts/part.h>
33 #include <kparts/browserextension.h>
34 #include <kdemacros.h>
35 #include <kfind.h>
36 #include <kfinddialog.h>
37 #include <klocalizedstring.h>
38 #include <kencodingdetector.h>
39 #include <QtCore/QRegExp>
41 class KHTMLPartPrivate;
42 class KHTMLPartBrowserExtension;
43 class KJSProxy;
44 class KHTMLView;
45 class KHTMLViewBar;
46 class KHTMLSettings;
47 class KJavaAppletContext;
48 class KJSErrorDlg;
50 namespace DOM
52 class HTMLDocument;
53 class HTMLDocumentImpl;
54 class DocumentImpl;
55 class Document;
56 class XMLDocumentImpl;
57 class HTMLTitleElementImpl;
58 class HTMLFrameElementImpl;
59 class HTMLIFrameElementImpl;
60 class HTMLObjectElementImpl;
61 class HTMLFormElementImpl;
62 class HTMLAnchorElementImpl;
63 class HTMLMetaElementImpl;
64 class NodeImpl;
65 class ElementImpl;
66 class Node;
67 class HTMLEventListener;
68 class EventListener;
69 class HTMLPartContainerElementImpl;
70 class HTMLObjectBaseElementImpl;
71 class Position;
72 class Selection;
73 class Range;
74 class Editor;
77 namespace WebCore
79 class SVGDocumentExtensions;
82 namespace KJS
84 class Interpreter;
85 class HTMLElement;
88 namespace khtml
90 class DocLoader;
91 class RenderPart;
92 class ChildFrame;
93 class MousePressEvent;
94 class MouseDoubleClickEvent;
95 class MouseMoveEvent;
96 class MouseReleaseEvent;
97 class DrawContentsEvent;
98 class CachedObject;
99 class RenderWidget;
100 class RenderBlock;
101 class CSSStyleSelector;
102 class HTMLTokenizer;
103 class XMLTokenizer;
104 struct EditorContext;
105 class EditCommandImpl;
106 class KHTMLPartAccessor;
109 namespace KJS {
110 class Window;
111 class WindowFunc;
112 class ExternalFunc;
113 class JSEventListener;
114 class JSLazyEventListener;
115 class JSNodeFilter;
116 class DOMDocument;
117 class SourceFile;
118 class ScheduledAction;
119 // class DebugDocument;
122 namespace KParts
124 class PartManager;
125 class LiveConnectExtension;
128 namespace KWallet
130 class Wallet;
134 * This class is khtml's main class. It features an almost complete
135 * web browser, and html renderer.
137 * The easiest way to use this class (if you just want to display an HTML
138 * page at some URL) is the following:
140 * \code
141 * KUrl url = "http://www.kde.org";
142 * KHTMLPart *w = new KHTMLPart();
143 * w->openUrl(url);
144 * w->view()->resize(500, 400);
145 * w->show();
146 * \endcode
148 * Java and JavaScript are enabled by default depending on the user's
149 * settings. If you do not need them, and especially if you display
150 * unfiltered data from untrusted sources, it is strongly recommended to
151 * turn them off. In that case, you should also turn off the automatic
152 * redirect and plugins:
154 * \code
155 * w->setJScriptEnabled(false);
156 * w->setJavaEnabled(false);
157 * w->setMetaRefreshEnabled(false);
158 * w->setPluginsEnabled(false);
159 * \endcode
161 * You may also wish to disable external references. This will prevent KHTML
162 * from loading images, frames, etc, or redirecting to external sites.
164 * \code
165 * w->setOnlyLocalReferences(true);
166 * \endcode
168 * Some apps want to write their HTML code directly into the widget instead of
169 * opening an url. You can do this in the following way:
171 * \code
172 * QString myHTMLCode = ...;
173 * KHTMLPart *w = new KHTMLPart();
174 * w->begin();
175 * w->write(myHTMLCode);
176 * ...
177 * w->end();
178 * \endcode
180 * You can do as many calls to write() as you wish. There are two
181 * write() methods, one accepting a QString and one accepting a
182 * @p char @p * argument. You should use one or the other
183 * (but not both) since the method using
184 * the @p char @p * argument does an additional decoding step to convert the
185 * written data to Unicode.
187 * It is also possible to write content to the HTML part using the
188 * standard streaming API from KParts::ReadOnlyPart. The usage of
189 * the API is similar to that of the begin(), write(), end() process
190 * described above as the following example shows:
192 * \code
193 * KHTMLPart *doc = new KHTMLPart();
194 * doc->openStream( "text/html", KUrl() );
195 * doc->writeStream( QCString( "<html><body><p>KHTML Rocks!</p></body></html>" ) );
196 * doc->closeStream();
197 * \endcode
199 * @short HTML Browser Widget
200 * @author Lars Knoll (knoll@kde.org)
203 class KHTML_EXPORT KHTMLPart : public KParts::ReadOnlyPart
205 Q_OBJECT
206 friend class KHTMLView;
207 friend class DOM::HTMLTitleElementImpl;
208 friend class DOM::HTMLFrameElementImpl;
209 friend class DOM::HTMLIFrameElementImpl;
210 friend class DOM::HTMLObjectBaseElementImpl;
211 friend class DOM::HTMLObjectElementImpl;
212 friend class DOM::HTMLAnchorElementImpl;
213 friend class DOM::HTMLMetaElementImpl;
214 friend class DOM::NodeImpl;
215 friend class DOM::ElementImpl;
216 friend class KHTMLRun;
217 friend class DOM::HTMLFormElementImpl;
218 friend class KJS::Window;
219 friend class KJS::ScheduledAction;
220 friend class KJS::JSNodeFilter;
221 friend class KJS::WindowFunc;
222 friend class KJS::ExternalFunc;
223 friend class KJS::JSEventListener;
224 friend class KJS::JSLazyEventListener;
225 friend class KJS::DOMDocument;
226 friend class KJS::HTMLElement;
227 friend class KJS::SourceFile;
228 // friend class KJS::DebugDocument;
229 friend class KJSProxy;
230 friend class KHTMLPartBrowserExtension;
231 friend class DOM::DocumentImpl;
232 friend class DOM::HTMLDocumentImpl;
233 friend class DOM::Selection;
234 friend class DOM::Editor;
235 friend class KHTMLPartBrowserHostExtension;
236 friend class khtml::HTMLTokenizer;
237 friend class khtml::XMLTokenizer;
238 friend class khtml::RenderWidget;
239 friend class khtml::RenderBlock;
240 friend class khtml::CSSStyleSelector;
241 friend class khtml::EditCommandImpl;
242 friend class khtml::KHTMLPartAccessor;
243 friend class KHTMLPartIface;
244 friend class KHTMLPartFunction;
245 friend class KHTMLPopupGUIClient;
246 friend class KHTMLFind;
247 friend class WebCore::SVGDocumentExtensions;
249 Q_PROPERTY( bool javaScriptEnabled READ jScriptEnabled WRITE setJScriptEnabled )
250 Q_PROPERTY( bool javaEnabled READ javaEnabled WRITE setJavaEnabled )
251 Q_PROPERTY( bool dndEnabled READ dndEnabled WRITE setDNDEnabled )
252 Q_PROPERTY( bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled )
253 Q_PROPERTY( DNSPrefetch dnsPrefetch READ dnsPrefetch WRITE setDNSPrefetch )
257 * Don't add setOnlyLocalReferences here. It shouldn't be accessible via DBus.
260 Q_PROPERTY( bool modified READ isModified )
261 Q_PROPERTY( QString encoding READ encoding WRITE setEncoding )
262 Q_PROPERTY( QString lastModified READ lastModified )
263 Q_PROPERTY( bool metaRefreshEnabled READ metaRefreshEnabled WRITE setMetaRefreshEnabled )
265 public:
266 enum GUIProfile { DefaultGUI, BrowserViewGUI /* ... */ };
269 * DNS Prefetching Mode enumeration
270 * @li DNSPrefetchDisabled do not prefetch hostnames
271 * @li DNSPrefetchEnabled always prefetch hostnames
272 * @li DNSPrefetchOnlyWWWAndSLD only do DNS prefetching for bare SLD and www sub-domain
275 enum DNSPrefetch {
276 DNSPrefetchDisabled=0,
277 DNSPrefetchEnabled,
278 DNSPrefetchOnlyWWWAndSLD
282 * Constructs a new KHTMLPart.
284 * KHTML basically consists of two objects: The KHTMLPart itself,
285 * holding the document data (DOM document), and the KHTMLView,
286 * derived from QScrollArea, in which the document content is
287 * rendered in. You can specify two different parent objects for a
288 * KHTMLPart, one parent for the KHTMLPart document and one parent
289 * for the KHTMLView. If the second @p parent argument is 0L, then
290 * @p parentWidget is used as parent for both objects, the part and
291 * the view.
293 KHTMLPart( QWidget *parentWidget = 0,
294 QObject *parent = 0, GUIProfile prof = DefaultGUI );
296 * Constructs a new KHTMLPart.
298 * This constructor is useful if you wish to subclass KHTMLView.
299 * If the @p view passed as first argument to the constructor was built with a
300 * null KHTMLPart pointer, then the newly created KHTMLPart will be assigned as the view's part.
302 * Therefore, you might either initialize the view as part of the initialization list of
303 * your derived KHTMLPart class constructor:
304 * \code
305 * MyKHTMLPart() : KHTMLPart( new MyKHTMLView( this ), ...
306 * \endcode
307 * Or separately build the KHTMLView beforehand:
308 * \code
309 * KHTMLView * v = KHTMLView( 0L, parentWidget());
310 * KHTMLPart * p = KHTMLPart( v ); // p will be assigned to v, so that v->part() == p
311 * \endcode
313 KHTMLPart( KHTMLView *view, QObject *parent = 0, GUIProfile prof = DefaultGUI );
316 * Destructor.
318 virtual ~KHTMLPart();
321 * Opens the specified URL @p url.
323 * Reimplemented from KParts::ReadOnlyPart::openUrl .
325 virtual bool openUrl( const KUrl &url );
328 * Stops loading the document and kills all data requests (for images, etc.)
330 virtual bool closeUrl();
333 * Called when a certain error situation (i.e. connection timed out) occurred.
334 * The default implementation either shows a KIO error dialog or loads a more
335 * verbose error description a as page, depending on the users configuration.
336 * @p job is the job that signaled the error situation
338 virtual void showError( KJob* job );
341 * Returns a reference to the DOM HTML document (for non-HTML documents, returns null)
343 DOM::HTMLDocument htmlDocument() const;
346 * Returns a reference to the DOM document.
348 DOM::Document document() const;
351 * Returns the content of the source document.
353 QString documentSource() const;
356 * Returns the node that has the keyboard focus.
358 DOM::Node activeNode() const;
361 * Returns a pointer to the KParts::BrowserExtension.
363 KParts::BrowserExtension *browserExtension() const;
364 KParts::BrowserHostExtension *browserHostExtension() const;
367 * Returns a pointer to the HTML document's view.
369 KHTMLView *view() const;
372 * Enable/disable Javascript support. Note that this will
373 * in either case permanently override the default usersetting.
374 * If you want to have the default UserSettings, don't call this
375 * method.
377 void setJScriptEnabled( bool enable );
380 * Returns @p true if Javascript support is enabled or @p false
381 * otherwise.
383 bool jScriptEnabled() const;
386 * Returns the JavaScript interpreter the part is using. This method is
387 * mainly intended for applications which embed and extend the part and
388 * provides a mechanism for adding additional native objects to the
389 * interpreter (or removing the built-ins).
391 * One thing people using this method to add things to the interpreter must
392 * consider, is that when you start writing new content to the part, the
393 * interpreter is cleared. This includes both use of the
394 * begin( const KUrl &, int, int ) method, and the openUrl( const KUrl & )
395 * method. If you want your objects to have a longer lifespan, then you must
396 * retain a KJS::Object yourself to ensure that the reference count of your
397 * custom objects never reaches 0. You will also need to re-add your
398 * bindings every time this happens - one way to detect the need for this is
399 * to connect to the docCreated() signal, another is to reimplement the
400 * begin() method.
402 KJS::Interpreter *jScriptInterpreter();
405 * Enable/disable statusbar messages.
406 * When this class wants to set the statusbar text, it emits
407 * setStatusBarText(const QString & text)
408 * If you want to catch this for your own statusbar, note that it returns
409 * back a rich text string, starting with "<qt>". This you need to
410 * either pass this into your own QLabel or to strip out the tags
411 * before passing it to QStatusBar::message(const QString & message)
413 * @see KParts::Part::setStatusBarText( const QString & text )
415 void setStatusMessagesEnabled( bool enable );
418 * Returns @p true if status messages are enabled.
420 bool statusMessagesEnabled() const;
423 * Enable/disable automatic forwarding by &lt;meta http-equiv="refresh" ....&gt;
425 void setMetaRefreshEnabled( bool enable );
428 * Returns @p true if automatic forwarding is enabled.
430 bool metaRefreshEnabled() const;
433 * Same as executeScript( const QString & ) except with the Node parameter
434 * specifying the 'this' value.
436 QVariant executeScript( const DOM::Node &n, const QString &script );
439 * Enables or disables Drag'n'Drop support. A drag operation is started if
440 * the users drags a link.
442 void setDNDEnabled( bool b );
445 * Returns whether Dragn'n'Drop support is enabled or not.
447 bool dndEnabled() const;
450 * Enables/disables Java applet support. Note that calling this function
451 * will permanently override the User settings about Java applet support.
452 * Not calling this function is the only way to let the default settings
453 * apply.
455 void setJavaEnabled( bool enable );
458 * Return @p true if Java applet support is enabled, @p false if disabled
460 bool javaEnabled() const;
463 * Enables or disables plugins, default is enabled
465 void setPluginsEnabled( bool enable );
468 * Returns @p true if plugins are enabled, @p false if disabled.
470 bool pluginsEnabled() const;
473 * Specifies whether images contained in the document should be loaded
474 * automatically or not.
476 * @note Request will be ignored if called before begin().
478 void setAutoloadImages( bool enable );
480 * Returns whether images contained in the document are loaded automatically
481 * or not.
482 * @note that the returned information is unrelieable as long as no begin()
483 * was called.
485 bool autoloadImages() const;
488 * Security option.
490 * Specify whether only file:/ or data:/ urls are allowed to be loaded without
491 * user confirmation by KHTML.
492 * ( for example referenced by stylesheets, images, scripts, subdocuments, embedded elements ).
494 * This option is mainly intended for enabling the "mail reader mode", where you load untrusted
495 * content with a file:/ url.
497 * Please note that enabling this option currently automatically disables Javascript,
498 * Java and Plugins support. This might change in the future if the security model
499 * is becoming more sophisticated, so don't rely on this behaviour.
501 * ( default @p false - everything is loaded unless forbidden by KApplication::authorizeURLAction).
503 void setOnlyLocalReferences( bool enable );
506 * Sets whether DNS Names found in loaded documents'anchors should be pre-fetched (pre-resolved).
507 * Note that calling this function will permanently override the User settings about
508 * DNS prefetch support.
509 * Not calling this function is the only way to let the default settings apply.
511 * @note This setting has no effect if @ref setOnlyLocalReferences() mode is enabled.
513 * @param pmode the mode to set. See @ref DNSPrefetch enum for explanation of values.
515 * @since 4.2
517 void setDNSPrefetch( DNSPrefetch pmode );
520 * Returns currently set DNS prefetching mode.
521 * See @p DNSPrefetch enum for explanation of values.
523 * @note Always returns @p DNSPrefetchDisabled if @ref setOnlyLocalReferences() mode is enabled.
525 * @since 4.2
527 DNSPrefetch dnsPrefetch() const;
530 * Returns whether only file:/ or data:/ references are allowed
531 * to be loaded ( default @p false ). See setOnlyLocalReferences.
533 bool onlyLocalReferences() const;
535 /** Returns whether caret mode is on/off.
537 bool isCaretMode() const;
540 * Returns @p true if the document is editable, @p false otherwise.
542 bool isEditable() const;
545 * Sets the caret to the given position.
547 * If the given location is invalid, it will snap to the nearest valid
548 * location. Immediately afterwards a @p caretPositionChanged signal
549 * containing the effective position is emitted
550 * @param node node to set to
551 * @param offset zero-based offset within the node
552 * @param extendSelection If @p true, a selection will be spanned from the
553 * last caret position to the given one. Otherwise, any existing selection
554 * will be deselected.
556 void setCaretPosition(DOM::Node node, long offset, bool extendSelection = false);
559 * Enumeration for displaying the caret.
561 enum CaretDisplayPolicy {
562 CaretVisible, /**< caret is displayed */
563 CaretInvisible, /**< caret is not displayed */
564 CaretBlink /**< caret toggles between visible and invisible */
568 * Returns the current caret policy when the view is not focused.
570 CaretDisplayPolicy caretDisplayPolicyNonFocused() const;
573 * Sets the caret display policy when the view is not focused.
575 * Whenever the caret is in use, this property determines how the
576 * caret should be displayed when the document view is not focused.
578 * The default policy is CaretInvisible.
579 * @param policy new display policy
581 void setCaretDisplayPolicyNonFocused(CaretDisplayPolicy policy);
583 #ifndef KDE_NO_COMPAT
584 KUrl baseURL() const;
585 #endif
588 * Returns the URL for the background Image (used by save background)
590 KUrl backgroundURL() const;
593 * Schedules a redirection after @p delay seconds.
595 void scheduleRedirection( int delay, const QString &url, bool lockHistory = true );
598 * Clears the widget and prepares it for new content.
600 * If you want url() to return
601 * for example "file:/tmp/test.html", you can use the following code:
602 * \code
603 * view->begin( KUrl("file:/tmp/test.html" ) );
604 * \endcode
606 * @param url is the url of the document to be displayed. Even if you
607 * are generating the HTML on the fly, it may be useful to specify
608 * a directory so that any pixmaps are found.
610 * @param xOffset is the initial horizontal scrollbar value. Usually
611 * you don't want to use this.
613 * @param yOffset is the initial vertical scrollbar value. Usually
614 * you don't want to use this.
616 * All child frames and the old document are removed if you call
617 * this method.
619 virtual void begin( const KUrl &url = KUrl(), int xOffset = 0, int yOffset = 0 );
622 * Writes another part of the HTML code to the widget.
624 * You may call
625 * this function many times in sequence. But remember: The fewer calls
626 * you make, the faster the widget will be.
628 * The HTML code is send through a decoder which decodes the stream to
629 * Unicode.
631 * The @p len parameter is needed for streams encoded in utf-16,
632 * since these can have \\0 chars in them. In case the encoding
633 * you're using isn't utf-16, you can safely leave out the length
634 * parameter.
636 * Attention: Don't mix calls to write( const char *) with calls
637 * to write( const QString & ).
639 * The result might not be what you want.
641 virtual void write( const char *str, int len = -1 );
644 * Writes another part of the HTML code to the widget.
646 * You may call
647 * this function many times in sequence. But remember: The fewer calls
648 * you make, the faster the widget will be.
650 * For historic and backward compatibility reasons, this method will force
651 * the use of strict mode for the document, unless setAlwaysHonourDoctype()
652 * has been called previously.
654 // FIXME KDE5: always honour doctype, remove setAlwaysHonourDoctype()
655 virtual void write( const QString &str );
658 * Call this after your last call to write().
660 virtual void end();
663 * Prints the current HTML page laid out for the printer.
665 * (not implemented at the moment)
667 // void print(QPainter *, int pageHeight, int pageWidth);
670 * Paints the HTML page to a QPainter. See KHTMLView::paint for details
672 void paint( QPainter *, const QRect &, int = 0, bool * = 0 );
675 * Sets the encoding the page uses.
677 * This can be different from the charset. The widget will try to reload the current page in the new
678 * encoding, if url() is not empty.
680 bool setEncoding( const QString &name, bool override = false );
683 * Returns the encoding the page currently uses.
685 * Note that the encoding might be different from the charset.
687 QString encoding() const;
690 * Sets a user defined style sheet to be used on top of the HTML 4
691 * default style sheet.
693 * This gives a wide range of possibilities to
694 * change the layout of the page.
696 * To have an effect this function has to be called after calling begin().
698 void setUserStyleSheet( const KUrl &url );
701 * Sets a user defined style sheet to be used on top of the HTML 4
702 * default style sheet.
704 * This gives a wide range of possibilities to
705 * change the layout of the page.
707 * To have an effect this function has to be called after calling begin().
709 void setUserStyleSheet( const QString &styleSheet );
711 public:
714 * Sets the standard font style.
716 * @param name The font name to use for standard text.
718 void setStandardFont( const QString &name );
721 * Sets the fixed font style.
723 * @param name The font name to use for fixed text, e.g.
724 * the <tt>&lt;pre&gt;</tt> tag.
726 void setFixedFont( const QString &name );
729 * Finds the anchor named @p name.
731 * If the anchor is found, the widget
732 * scrolls to the closest position. Returns @p if the anchor has
733 * been found.
735 bool gotoAnchor( const QString &name );
738 * Go to the next anchor
740 * This is useful to navigate from outside the navigator
742 bool nextAnchor();
745 * Go to previous anchor
747 bool prevAnchor();
750 * Sets the cursor to use when the cursor is on a link.
752 void setURLCursor( const QCursor &c );
755 * Returns the cursor which is used when the cursor is on a link.
757 QCursor urlCursor() const;
760 * Extra Find options that can be used when calling the extended findText().
762 enum FindOptions
764 FindLinksOnly = 1 * KFind::MinimumUserOption,
765 FindNoPopups = 2 * KFind::MinimumUserOption
766 //FindIncremental = 4 * KFind::MinimumUserOption
770 * Starts a new search by popping up a dialog asking the user what he wants to
771 * search for.
773 void findText();
776 * Starts a new search, but bypasses the user dialog.
777 * @param str The string to search for.
778 * @param options Find options.
779 * @param parent Parent used for centering popups like "string not found".
780 * @param findDialog Optionally, you can supply your own dialog.
782 void findText( const QString &str, long options, QWidget *parent = 0,
783 KFindDialog *findDialog = 0 );
786 * Initiates a text search.
788 void findTextBegin();
791 * Finds the next occurrence of a string set by @ref findText()
792 * @param reverse if @p true, revert seach direction (only if no find dialog is used)
793 * @return @p true if a new match was found.
795 bool findTextNext( bool reverse = false );
798 * Sets the Zoom factor. The value is given in percent, larger values mean a
799 * generally larger font and larger page contents.
801 * The given value should be in the range of 20..300, values outside that
802 * range are not guaranteed to work. A value of 100 will disable all zooming
803 * and show the page with the sizes determined via the given lengths in the
804 * stylesheets.
806 void setZoomFactor(int percent);
809 * Returns the current zoom factor.
811 int zoomFactor() const;
814 * Sets the scale factor to be applied to fonts. The value is given in percent,
815 * larger values mean generally larger fonts.
817 * The given value should be in the range of 20..300, values outside that
818 * range are not guaranteed to work. A value of 100 will disable all scaling of font sizes
819 * and show the page with the sizes determined via the given lengths in the
820 * stylesheets.
822 void setFontScaleFactor(int percent);
825 * Returns the current font scale factor.
827 int fontScaleFactor() const;
830 * Returns the text the user has marked.
832 virtual QString selectedText() const;
835 * Return the text the user has marked. This is guaranteed to be valid xml,
836 * and to contain the \<html> and \<body> tags.
838 * FIXME probably should make virtual for 4.0 ?
840 QString selectedTextAsHTML() const;
843 * Returns the selected part of the HTML.
845 DOM::Range selection() const;
848 * Returns the selected part of the HTML by returning the starting and end
849 * position.
851 * If there is no selection, both nodes and offsets are equal.
852 * @param startNode returns node selection starts in
853 * @param startOffset returns offset within starting node
854 * @param endNode returns node selection ends in
855 * @param endOffset returns offset within end node.
857 void selection(DOM::Node &startNode, long &startOffset,
858 DOM::Node &endNode, long &endOffset) const;
861 * Sets the current selection.
863 void setSelection( const DOM::Range & );
866 * Has the user selected anything?
868 * Call selectedText() to
869 * retrieve the selected text.
871 * @return @p true if there is text selected.
873 bool hasSelection() const;
876 * Returns the instance of the attached html editor interface.
879 DOM::Editor *editor() const;
882 * Marks all text in the document as selected.
884 void selectAll();
887 * Convenience method to show the document's view.
889 * Equivalent to widget()->show() or view()->show() .
891 void show();
894 * Convenience method to hide the document's view.
896 * Equivalent to widget()->hide() or view()->hide().
898 void hide();
901 * Returns a reference to the partmanager instance which
902 * manages html frame objects.
904 KParts::PartManager *partManager();
907 * Saves the KHTMLPart's complete state (including child frame
908 * objects) to the provided QDataStream.
910 * This is called from the saveState() method of the
911 * browserExtension().
913 virtual void saveState( QDataStream &stream );
915 * Restores the KHTMLPart's previously saved state (including
916 * child frame objects) from the provided QDataStream.
918 * @see saveState()
920 * This is called from the restoreState() method of the
921 * browserExtension() .
923 virtual void restoreState( QDataStream &stream );
926 * Returns the @p Node currently under the mouse.
928 * The returned node may be a shared node (e. g. an \<area> node if the
929 * mouse is hovering over an image map).
931 DOM::Node nodeUnderMouse() const;
934 * Returns the @p Node currently under the mouse that is not shared.
936 * The returned node is always the node that is physically under the mouse
937 * pointer (irrespective of logically overlying elements like, e. g.,
938 * \<area> on image maps).
940 DOM::Node nonSharedNodeUnderMouse() const;
943 * @internal
945 const KHTMLSettings *settings() const;
948 * Returns a pointer to the parent KHTMLPart if the part is a frame
949 * in an HTML frameset.
951 * Returns 0L otherwise.
953 // ### KDE5 make const
954 KHTMLPart *parentPart();
957 * Returns a list of names of all frame (including iframe) objects of
958 * the current document. Note that this method is not working recursively
959 * for sub-frames.
961 QStringList frameNames() const;
963 QList<KParts::ReadOnlyPart*> frames() const;
966 * Finds a frame by name. Returns 0L if frame can't be found.
968 KHTMLPart *findFrame( const QString &f );
971 * Recursively finds the part containing the frame with name @p f
972 * and checks if it is accessible by @p callingPart
973 * Returns 0L if no suitable frame can't be found.
974 * Returns parent part if a suitable frame was found and
975 * frame info in @p *childFrame
977 KHTMLPart *findFrameParent( KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame=0 );
980 * Return the current frame (the one that has focus)
981 * Not necessarily a direct child of ours, framesets can be nested.
982 * Returns "this" if this part isn't a frameset.
984 KParts::ReadOnlyPart *currentFrame() const;
987 * Returns whether a frame with the specified name is exists or not.
988 * In contrast to the findFrame method this one also returns @p true
989 * if the frame is defined but no displaying component has been
990 * found/loaded, yet.
992 bool frameExists( const QString &frameName );
995 * Returns child frame framePart its script interpreter
997 KJSProxy *framejScript(KParts::ReadOnlyPart *framePart);
1000 * Finds a frame by name. Returns 0L if frame can't be found.
1002 KParts::ReadOnlyPart *findFramePart( const QString &f );
1004 * Called by KJS.
1005 * Sets the StatusBarText assigned
1006 * via window.status
1008 void setJSStatusBarText( const QString &text );
1011 * Called by KJS.
1012 * Sets the DefaultStatusBarText assigned
1013 * via window.defaultStatus
1015 void setJSDefaultStatusBarText( const QString &text );
1018 * Called by KJS.
1019 * Returns the StatusBarText assigned
1020 * via window.status
1022 QString jsStatusBarText() const;
1025 * Called by KJS.
1026 * Returns the DefaultStatusBarText assigned
1027 * via window.defaultStatus
1029 QString jsDefaultStatusBarText() const;
1032 * Referrer used for links in this page.
1034 QString referrer() const;
1037 * Referrer used to obtain this page.
1039 QString pageReferrer() const;
1042 * Last-modified date (in raw string format), if received in the [HTTP] headers.
1044 QString lastModified() const;
1047 * Loads a style sheet into the stylesheet cache.
1049 void preloadStyleSheet( const QString &url, const QString &stylesheet );
1052 * Loads a script into the script cache.
1054 void preloadScript( const QString &url, const QString &script );
1057 * Returns whether the given point is inside the current selection.
1059 * The coordinates are content-coordinates.
1061 bool isPointInsideSelection(int x, int y);
1064 * @internal
1066 bool restored() const;
1069 * Sets whether the document's Doctype should always be used
1070 * to determine the parsing mode for the document.
1072 * Without this, parsing will be forced to
1073 * strict mode when using the write( const QString &str )
1074 * method for backward compatibility reasons.
1077 // ### KDE5 remove - fix write( const QString &str ) instead
1078 void setAlwaysHonourDoctype( bool b = true );
1080 // ### KDE5 remove me
1081 enum FormNotification { NoNotification = 0, Before, Only, Unused=255 };
1083 * Determine if signal should be emitted before, instead or never when a
1084 * submitForm() happens.
1085 * ### KDE5 remove me
1087 void setFormNotification(FormNotification fn);
1090 * Determine if signal should be emitted before, instead or never when a
1091 * submitForm() happens.
1092 * ### KDE5 remove me
1094 FormNotification formNotification() const;
1097 * Returns the toplevel (origin) URL of this document, even if this
1098 * part is a frame or an iframe.
1100 * @return the actual original url.
1102 KUrl toplevelURL();
1105 * Checks whether the page contains unsubmitted form changes.
1107 * @return @p true if form changes exist
1109 bool isModified() const;
1112 * Shows or hides the suppressed popup indicator
1114 void setSuppressedPopupIndicator( bool enable, KHTMLPart *originPart = 0 );
1117 * @internal
1119 bool inProgress() const;
1121 Q_SIGNALS:
1123 * Emitted if the cursor is moved over an URL.
1125 void onURL( const QString &url );
1128 * Emitted when the user clicks the right mouse button on the document.
1129 * See KParts::BrowserExtension for two more popupMenu signals emitted by khtml,
1130 * with much more information in the signal.
1132 void popupMenu( const QString &url, const QPoint &point );
1135 * This signal is emitted when the selection changes.
1137 void selectionChanged();
1140 * This signal is emitted when an element retrieves the
1141 * keyboard focus. Note that the signal argument can be
1142 * a null node if no element is active, meaning a node
1143 * has explicitly been deactivated without a new one
1144 * becoming active.
1146 void nodeActivated( const DOM::Node & );
1149 * @internal */
1150 void docCreated();
1153 * This signal is emitted whenever the caret position has been changed.
1155 * The signal transmits the position the DOM::Range way, the node and
1156 * the zero-based offset within this node.
1157 * @param node node which the caret is in. This can be null if the caret
1158 * has been deactivated.
1159 * @param offset offset within the node. If the node is null, the offset
1160 * is meaningless.
1162 void caretPositionChanged(const DOM::Node &node, long offset);
1166 * If form notification is on, this will be emitted either for a form
1167 * submit or before the form submit according to the setting.
1168 * ### KDE4 remove me
1170 void formSubmitNotification(const char *action, const QString& url,
1171 const QByteArray& formData, const QString& target,
1172 const QString& contentType, const QString& boundary);
1175 * Emitted whenever the configuration has changed
1177 void configurationChanged();
1180 protected:
1183 * returns a KUrl object for the given url. Use when
1184 * you know what you're doing.
1186 KUrl completeURL( const QString &url );
1189 * presents a detailed error message to the user.
1190 * @p errorCode kio error code, eg KIO::ERR_SERVER_TIMEOUT.
1191 * @p text kio additional information text.
1192 * @p url the url that triggered the error.
1194 void htmlError( int errorCode, const QString& text, const KUrl& reqUrl );
1196 virtual void customEvent( QEvent *event );
1199 * Eventhandler of the khtml::MousePressEvent.
1201 virtual void khtmlMousePressEvent( khtml::MousePressEvent *event );
1203 * Eventhandler for the khtml::MouseDoubleClickEvent.
1205 virtual void khtmlMouseDoubleClickEvent( khtml::MouseDoubleClickEvent * );
1207 * Eventhandler for the khtml::MouseMouseMoveEvent.
1209 virtual void khtmlMouseMoveEvent( khtml::MouseMoveEvent *event );
1211 * Eventhandler for the khtml::MouseMouseReleaseEvent.
1213 virtual void khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *event );
1215 * Eventhandler for the khtml::DrawContentsEvent.
1217 virtual void khtmlDrawContentsEvent( khtml::DrawContentsEvent * );
1220 * Internal reimplementation of KParts::Part::guiActivateEvent .
1222 virtual void guiActivateEvent( KParts::GUIActivateEvent *event );
1225 * Internal empty reimplementation of KParts::ReadOnlyPart::openFile .
1227 virtual bool openFile();
1229 virtual bool urlSelected( const QString &url, int button, int state,
1230 const QString &_target,
1231 const KParts::OpenUrlArguments& args = KParts::OpenUrlArguments(),
1232 const KParts::BrowserArguments& browserArgs = KParts::BrowserArguments() );
1235 * This method is called when a new embedded object (include html frames) is to be created.
1236 * Reimplement it if you want to add support for certain embeddable objects without registering
1237 * them in the KDE wide registry system (KSyCoCa) . Another reason for re-implementing this
1238 * method could be if you want to derive from KTHMLPart and also want all html frame objects
1239 * to be a object of your derived type, in which case you should return a new instance for
1240 * the mimetype 'text/html' .
1242 virtual KParts::ReadOnlyPart *createPart( QWidget *parentWidget,
1243 QObject *parent,
1244 const QString &mimetype, QString &serviceName,
1245 QStringList &serviceTypes, const QStringList &params);
1247 // This is for RenderPartObject. We want to ask the 'download plugin?'
1248 // question only once per mimetype
1249 bool pluginPageQuestionAsked( const QString& mimetype ) const;
1250 void setPluginPageQuestionAsked( const QString& mimetype );
1252 enum PageSecurity { NotCrypted, Encrypted, Mixed };
1253 void setPageSecurity( PageSecurity sec );
1256 * Implements the streaming API of KParts::ReadOnlyPart.
1258 virtual bool doOpenStream( const QString& mimeType );
1261 * Implements the streaming API of KParts::ReadOnlyPart.
1263 virtual bool doWriteStream( const QByteArray& data );
1266 * Implements the streaming API of KParts::ReadOnlyPart.
1268 virtual bool doCloseStream();
1271 * @internal
1273 virtual void timerEvent(QTimerEvent *);
1276 * Will pre-resolve @p name according to dnsPrefetch current settings
1277 * Returns @p true if the name will be pre-resolved.
1278 * Otherwise returns false.
1281 bool mayPrefetchHostname( const QString& name );
1283 public Q_SLOTS:
1286 * Sets the focused node of the document to the specified node. If the node is a form control, the control will
1287 * receive focus in the same way that it would if the user had clicked on it or tabbed to it with the keyboard. For
1288 * most other types of elements, there is no visual indication of whether or not they are focused.
1290 * See activeNode
1292 * @param node The node to focus
1294 void setActiveNode( const DOM::Node &node );
1297 * Stops all animated images on the current and child pages
1299 void stopAnimations();
1302 * Execute the specified snippet of JavaScript code.
1304 * Returns @p true if JavaScript was enabled, no error occurred
1305 * and the code returned @p true itself or @p false otherwise.
1306 * @deprecated, use executeString( DOM::Node(), script)
1308 QVariant executeScript( const QString &script );
1311 * Enables/disables caret mode.
1313 * Enabling caret mode displays a caret which can be used to navigate
1314 * the document using the keyboard only. Caret mode is switched off by
1315 * default.
1317 * @param enable @p true to enable, @p false to disable caret mode.
1319 void setCaretMode(bool enable);
1322 * Makes the document editable.
1324 * Setting this property to @p true makes the document, and its
1325 * subdocuments (such as frames, iframes, objects) editable as a whole.
1326 * FIXME: insert more information about navigation, features etc. as seen fit
1328 * @param enable @p true to set document editable, @p false to set it
1329 * read-only.
1331 void setEditable(bool enable);
1334 * Sets the visibility of the caret.
1336 * This methods displays or hides the caret regardless of the current
1337 * caret display policy (see setCaretDisplayNonFocused), and regardless
1338 * of focus.
1340 * The caret will be shown/hidden only under at least one of
1341 * the following conditions:
1342 * @li the document is editable
1343 * @li the document is in caret mode
1344 * @li the document's currently focused element is editable
1346 * @param show @p true to make visible, @p false to hide.
1348 void setCaretVisible(bool show);
1350 // ### KDE4 FIXME:
1351 // Remove this and make the one below protected+virtual slot.
1352 // Warning: this is effectively "internal". Be careful.
1353 void submitFormProxy( const char *action, const QString &url,
1354 const QByteArray &formData,
1355 const QString &target,
1356 const QString& contentType = QString(),
1357 const QString& boundary = QString() );
1359 protected Q_SLOTS:
1362 * Called when the job downloading the page is finished.
1363 * Can be reimplemented, for instance to get metadata out of the job,
1364 * but make sure to call KHTMLPart::slotFinished() too.
1366 virtual void slotFinished( KJob* );
1368 protected:
1370 * Hook for adding code before a job is started.
1371 * This can be used to add metadata, like job->addMetaData("PropagateHttpHeader", "true")
1372 * to get the HTTP headers.
1374 virtual void startingJob( KIO::Job * ) {}
1376 private Q_SLOTS:
1379 * @internal
1381 void reparseConfiguration();
1384 * @internal
1386 void slotData( KIO::Job*, const QByteArray &data );
1388 * @internal
1390 void slotInfoMessage( KJob*, const QString& msg );
1392 * @internal
1394 void slotRestoreData( const QByteArray &data );
1396 * @internal
1398 void slotFinishedParsing();
1400 * @internal
1402 void slotRedirect();
1404 * @internal
1406 void slotRedirection( KIO::Job*, const KUrl& );
1408 * @internal
1410 void slotDebugScript();
1412 * @internal
1414 void slotDebugDOMTree();
1416 * @internal
1418 void slotDebugRenderTree();
1420 * @internal
1422 void slotStopAnimations();
1424 * @internal
1426 virtual void slotViewDocumentSource();
1428 * @internal
1430 virtual void slotViewFrameSource();
1432 * @internal
1434 void slotViewPageInfo();
1436 * @internal
1438 virtual void slotSaveBackground();
1440 * @internal
1442 virtual void slotSaveDocument();
1444 * @internal
1446 virtual void slotSaveFrame();
1448 * @internal
1450 virtual void slotSecurity();
1452 * @internal
1454 virtual void slotSetEncoding(const QString &);
1457 * @internal
1459 virtual void slotUseStylesheet();
1461 virtual void slotFind();
1462 virtual void slotFindDone(); // ### remove me
1463 virtual void slotFindDialogDestroyed(); // ### remove me
1464 void slotFindNext();
1465 void slotFindPrev();
1466 void slotFindAheadText();
1467 void slotFindAheadLink();
1469 void slotIncZoom();
1470 void slotDecZoom();
1471 void slotIncZoomFast();
1472 void slotDecZoomFast();
1474 void slotIncFontSize();
1475 void slotDecFontSize();
1476 void slotIncFontSizeFast();
1477 void slotDecFontSizeFast();
1479 void slotLoadImages();
1480 void slotWalletClosed();
1481 void launchWalletManager();
1482 void walletMenu();
1485 * @internal
1487 void submitFormAgain();
1490 * @internal
1492 void updateActions();
1494 * @internal
1496 void slotPartRemoved( KParts::Part *part );
1498 * @internal
1500 void slotActiveFrameChanged( KParts::Part *part );
1502 * @internal
1504 void slotChildStarted( KIO::Job *job );
1506 * @internal
1508 void slotChildCompleted();
1510 * @internal
1512 void slotChildCompleted( bool );
1514 * @internal
1516 void slotParentCompleted();
1518 * @internal
1520 void slotChildURLRequest( const KUrl &url, const KParts::OpenUrlArguments&, const KParts::BrowserArguments &args );
1522 * @internal
1524 void slotChildDocCreated();
1526 * @internal
1528 void slotRequestFocus( KParts::ReadOnlyPart * );
1529 void slotLoaderRequestStarted( khtml::DocLoader*, khtml::CachedObject* obj);
1530 void slotLoaderRequestDone( khtml::DocLoader*, khtml::CachedObject *obj );
1531 void checkCompleted();
1534 * @internal
1536 void slotAutoScroll();
1538 void slotPrintFrame();
1540 void slotSelectAll();
1543 * @internal
1545 void slotProgressUpdate();
1548 * @internal
1550 void slotJobPercent( KJob*, unsigned long );
1553 * @internal
1555 void slotJobDone( KJob* );
1558 * @internal
1560 void slotUserSheetStatDone( KJob* );
1563 * @internal
1565 void slotJobSpeed( KJob*, unsigned long );
1568 * @internal
1570 void slotClearSelection();
1573 * @internal
1575 void slotZoomView( int );
1578 * @internal
1580 void slotAutomaticDetectionLanguage(KEncodingDetector::AutoDetectScript scri);
1583 * @internal
1585 void slotToggleCaretMode();
1588 * @internal
1590 void suppressedPopupMenu();
1593 * @internal
1595 void togglePopupPassivePopup();
1598 * @internal
1600 void showSuppressedPopups();
1603 * @internal
1605 void launchJSConfigDialog();
1608 * @internal
1610 void launchJSErrorDialog();
1613 * @internal
1615 void removeJSErrorExtension();
1618 * @internal
1620 void disableJSErrorExtension();
1623 * @internal
1625 void jsErrorDialogContextMenu();
1628 * @internal
1629 * used to restore or reset the view's scroll position (including positioning on anchors)
1630 * once a sufficient portion of the document as been laid out.
1632 void restoreScrollPosition();
1634 void walletOpened(KWallet::Wallet*);
1636 private:
1638 KJSErrorDlg *jsErrorExtension();
1640 enum StatusBarPriority { BarDefaultText, BarHoverText, BarOverrideText };
1641 void setStatusBarText( const QString& text, StatusBarPriority p);
1643 bool restoreURL( const KUrl &url );
1644 void clearCaretRectIfNeeded();
1645 void setFocusNodeIfNeeded(const DOM::Selection &);
1646 void selectionLayoutChanged();
1647 void notifySelectionChanged(bool closeTyping=true);
1648 void resetFromScript();
1649 void emitSelectionChanged();
1650 void onFirstData();
1651 // Returns whether callingHtmlPart may access this part
1652 bool checkFrameAccess(KHTMLPart *callingHtmlPart);
1653 bool openUrlInFrame(const KUrl &url, const KParts::OpenUrlArguments& arguments, const KParts::BrowserArguments &browserArguments);
1654 void startAutoScroll();
1655 void stopAutoScroll();
1656 void overURL( const QString &url, const QString &target, bool shiftPressed = false );
1657 void resetHoverText(); // Undo overURL and reset HoverText
1659 bool processObjectRequest( khtml::ChildFrame *child, const KUrl &url, const QString &mimetype );
1660 KParts::LiveConnectExtension *liveConnectExtension( const DOM::NodeImpl *);
1662 KWallet::Wallet* wallet();
1664 void openWallet(DOM::HTMLFormElementImpl*);
1665 void saveToWallet(const QString& key, const QMap<QString,QString>& data);
1666 void dequeueWallet(DOM::HTMLFormElementImpl*);
1668 void enableFindAheadActions(bool);
1671 * Returns a pointer to the top view bar.
1673 KHTMLViewBar *pTopViewBar() const;
1676 * Returns a pointer to the bottom view bar.
1678 KHTMLViewBar *pBottomViewBar() const;
1681 * @internal
1683 // ### KDE4 FIXME:
1684 // It is desirable to be able to filter form submissions as well.
1685 // For instance, forms can have a target and an inheriting class
1686 // might want to filter based on the target. Make this protected
1687 // and virtual, or provide a better solution.
1688 // See the web_module for the sidebar for an example where this is
1689 // necessary.
1690 void submitForm( const char *action, const QString &url, const QByteArray &formData,
1691 const QString &target, const QString& contentType = QString(),
1692 const QString& boundary = QString() );
1694 void popupMenu( const QString &url );
1696 void init( KHTMLView *view, GUIProfile prof );
1699 void clear();
1701 QVariant crossFrameExecuteScript(const QString& target, const QString& script);
1703 bool requestFrame( DOM::HTMLPartContainerElementImpl *frame, const QString &url, const QString &frameName,
1704 const QStringList &args = QStringList(), bool isIFrame = false );
1707 * @internal returns a name for a frame without a name.
1708 * This function returns a sequence of names.
1709 * All names in a sequence are different but the sequence is
1710 * always the same.
1711 * The sequence is reset in clear().
1713 QString requestFrameName();
1715 bool requestObject( DOM::HTMLPartContainerElementImpl *frame, const QString &url, const QString &serviceType,
1716 const QStringList &args = QStringList() );
1718 bool requestObject( khtml::ChildFrame *child, const KUrl &url,
1719 const KParts::OpenUrlArguments &args = KParts::OpenUrlArguments(),
1720 const KParts::BrowserArguments& browserArgs = KParts::BrowserArguments() );
1722 // Called when a child could not be loaded.
1723 void childLoadFailure( khtml::ChildFrame *child );
1725 DOM::EventListener *createHTMLEventListener( QString code, QString name, DOM::NodeImpl *node, bool svg = false );
1727 DOM::HTMLDocumentImpl *docImpl() const;
1728 DOM::DocumentImpl *xmlDocImpl() const;
1729 khtml::ChildFrame *frame( const QObject *obj );
1731 khtml::ChildFrame *recursiveFrameRequest( KHTMLPart *callingHtmlPart, const KUrl &url,
1732 const KParts::OpenUrlArguments& args, const KParts::BrowserArguments &browserArgs,
1733 bool callParent = true );
1735 bool checkLinkSecurity( const KUrl &linkURL,const KLocalizedString &message = KLocalizedString(), const QString &button = QString() );
1736 QVariant executeScript( const QString& filename, int baseLine, const DOM::Node &n, const QString& script );
1738 KJSProxy *jScript();
1740 KHTMLPart *opener();
1741 long cacheId() const;
1742 void setOpener( KHTMLPart *_opener );
1743 bool openedByJS();
1744 void setOpenedByJS( bool _openedByJS );
1746 void checkEmitLoadEvent();
1747 void emitLoadEvent();
1749 bool initFindNode( bool selection, bool reverse, bool fromCursor );
1751 /** extends the current selection to the given content-coordinates @p x, @p y
1752 * @param x content x-coordinate
1753 * @param y content y-coordinate
1754 * @param absX absolute x-coordinate of @p innerNode
1755 * @param absY absolute y-coordinate of @p innerNode
1756 * @param innerNode node from which to start extending the selection. The
1757 * caller has to ensure that the node has a renderer.
1758 * @internal
1760 void extendSelectionTo(int x, int y, const DOM::Node &innerNode);
1761 /** checks whether a selection is extended.
1762 * @return @p true if a selection is extended by the mouse.
1764 bool isExtendingSelection() const;
1765 KEncodingDetector *createDecoder();
1766 QString defaultEncoding() const;
1768 /** .html, .xhtml or .xml */
1769 QString defaultExtension() const;
1771 /** @internal
1772 * generic zoom in
1774 void zoomIn(const int stepping[], int count);
1775 /** @internal
1776 * generic zoom out
1778 void zoomOut(const int stepping[], int count);
1780 void incFontSize(const int stepping[], int count);
1782 void decFontSize(const int stepping[], int count);
1784 void emitCaretPositionChanged(const DOM::Position &pos);
1786 void setDebugScript( bool enable );
1788 void runAdFilter();
1790 khtml::EditorContext *editorContext() const;
1793 * initialises the caret if it hasn't been used yet.
1794 * @internal
1796 void initCaret();
1799 * Returns the selected part of the HTML.
1801 const DOM::Selection &caret() const;
1804 * Returns the drag caret of the HTML.
1806 const DOM::Selection &dragCaret() const;
1809 * Sets the current caret to the given selection.
1811 void setCaret(const DOM::Selection &, bool closeTyping=true);
1814 * Sets the current drag caret.
1816 void setDragCaret(const DOM::Selection &);
1819 * Clears the current selection.
1821 void clearSelection();
1824 * Invalidates the current selection.
1826 void invalidateSelection();
1829 * Controls the visibility of the selection.
1831 void setSelectionVisible(bool flag=true);
1834 * Paints the caret.
1836 void paintCaret(QPainter *p, const QRect &rect) const;
1839 * Paints the drag caret.
1841 void paintDragCaret(QPainter *p, const QRect &rect) const;
1844 * Returns selectedText without any leading or trailing whitespace,
1845 * and with non-breaking-spaces turned into normal spaces.
1847 * Note that hasSelection can return true and yet simplifiedSelectedText can be empty,
1848 * e.g. when selecting a single space.
1850 QString simplifiedSelectedText() const;
1852 bool handleMouseMoveEventDrag(khtml::MouseMoveEvent *event);
1853 bool handleMouseMoveEventOver(khtml::MouseMoveEvent *event);
1854 void handleMouseMoveEventSelection(khtml::MouseMoveEvent *event);
1856 void handleMousePressEventSingleClick(khtml::MousePressEvent *event);
1857 void handleMousePressEventDoubleClick(khtml::MouseDoubleClickEvent *event);
1858 void handleMousePressEventTripleClick(khtml::MouseDoubleClickEvent *event);
1860 KHTMLPartPrivate *d;
1861 friend class KHTMLPartPrivate;
1865 #endif