1// -*- c-basic-offset: 2 -*-
2/* This file is part of the KDE project
3 *
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 *
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.
15 *
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.
20 *
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.
25 */
26#ifndef __khtml_part_h__
27#define __khtml_part_h__
28
29#include "dom/dom_doc.h"
30#include "dom/dom2_range.h"
31
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>
40
41class KHTMLPartPrivate;
42class KHTMLPartBrowserExtension;
43class KJSProxy;
44class KHTMLView;
45class KHTMLViewBar;
46class KHTMLFindBar;
47class KHTMLSettings;
48class KJavaAppletContext;
49class KJSErrorDlg;
50
51namespace DOM
52{
53 class HTMLDocument;
54 class HTMLDocumentImpl;
55 class DocumentImpl;
56 class Document;
57 class XMLDocumentImpl;
58 class HTMLTitleElementImpl;
59 class HTMLFrameElementImpl;
60 class HTMLIFrameElementImpl;
61 class HTMLObjectElementImpl;
62 class HTMLFormElementImpl;
63 class HTMLAnchorElementImpl;
64 class HTMLMetaElementImpl;
65 class NodeImpl;
66 class ElementImpl;
67 class Node;
68 class HTMLEventListener;
69 class EventListener;
70 class HTMLPartContainerElementImpl;
71 class HTMLObjectBaseElementImpl;
72 class Position;
73 class Selection;
74 class Range;
75 class Editor;
76}
77
78namespace WebCore
79{
80 class SVGDocumentExtensions;
81}
82
83namespace KJS
84{
85 class Interpreter;
86 class HTMLElement;
87}
88
89namespace khtml
90{
91 class DocLoader;
92 class RenderPart;
93 class ChildFrame;
94 class MousePressEvent;
95 class MouseDoubleClickEvent;
96 class MouseMoveEvent;
97 class MouseReleaseEvent;
98 class DrawContentsEvent;
99 class CachedObject;
100 class RenderWidget;
101 class RenderBlock;
102 class CSSStyleSelector;
103 class HTMLTokenizer;
104 class XMLTokenizer;
105 struct EditorContext;
106 class EditCommandImpl;
107 class KHTMLPartAccessor;
108}
109
110namespace KJS {
111 class Window;
112 class WindowFunc;
113 class ExternalFunc;
114 class JSEventListener;
115 class JSLazyEventListener;
116 class JSNodeFilter;
117 class DOMDocument;
118 class SourceFile;
119 class ScheduledAction;
120 class DOMSelection;
121 class DOMSelectionProtoFunc;
122 class KHTMLPartScriptable;
123}
124
125namespace KParts
126{
127 class PartManager;
128 class ScriptableExtension;
129}
130
131namespace KWallet
132{
133 class Wallet;
134}
135
136/**
137 * This class is khtml's main class. It features an almost complete
138 * web browser, and html renderer.
139 *
140 * The easiest way to use this class (if you just want to display an HTML
141 * page at some URL) is the following:
142 *
143 * \code
144 * KUrl url = "http://www.kde.org";
145 * KHTMLPart *w = new KHTMLPart();
146 * w->openUrl(url);
147 * w->view()->resize(500, 400);
148 * w->show();
149 * \endcode
150 *
151 * Java and JavaScript are enabled by default depending on the user's
152 * settings. If you do not need them, and especially if you display
153 * unfiltered data from untrusted sources, it is strongly recommended to
154 * turn them off. In that case, you should also turn off the automatic
155 * redirect and plugins:
156 *
157 * \code
158 * w->setJScriptEnabled(false);
159 * w->setJavaEnabled(false);
160 * w->setMetaRefreshEnabled(false);
161 * w->setPluginsEnabled(false);
162 * \endcode
163 *
164 * You may also wish to disable external references. This will prevent KHTML
165 * from loading images, frames, etc, or redirecting to external sites.
166 *
167 * \code
168 * w->setOnlyLocalReferences(true);
169 * \endcode
170 *
171 * Some apps want to write their HTML code directly into the widget instead of
172 * opening an url. You can do this in the following way:
173 *
174 * \code
175 * QString myHTMLCode = ...;
176 * KHTMLPart *w = new KHTMLPart();
177 * w->begin();
178 * w->write(myHTMLCode);
179 * ...
180 * w->end();
181 * \endcode
182 *
183 * You can do as many calls to write() as you wish. There are two
184 * write() methods, one accepting a QString and one accepting a
185 * @p char @p * argument. You should use one or the other
186 * (but not both) since the method using
187 * the @p char @p * argument does an additional decoding step to convert the
188 * written data to Unicode.
189 *
190 * It is also possible to write content to the HTML part using the
191 * standard streaming API from KParts::ReadOnlyPart. The usage of
192 * the API is similar to that of the begin(), write(), end() process
193 * described above as the following example shows:
194 *
195 * \code
196 * KHTMLPart *doc = new KHTMLPart();
197 * doc->openStream( "text/html", KUrl() );
198 * doc->writeStream( QCString( "<html><body><p>KHTML Rocks!</p></body></html>" ) );
199 * doc->closeStream();
200 * \endcode
201 *
202 * @short HTML Browser Widget
203 * @author Lars Knoll (knoll@kde.org)
204 *
205 */
206class KHTML_EXPORT KHTMLPart : public KParts::ReadOnlyPart
207{
208 Q_OBJECT
209 friend class KHTMLView;
210 friend class DOM::HTMLTitleElementImpl;
211 friend class DOM::HTMLFrameElementImpl;
212 friend class DOM::HTMLIFrameElementImpl;
213 friend class DOM::HTMLObjectBaseElementImpl;
214 friend class DOM::HTMLObjectElementImpl;
215 friend class DOM::HTMLAnchorElementImpl;
216 friend class DOM::HTMLMetaElementImpl;
217 friend class DOM::NodeImpl;
218 friend class DOM::ElementImpl;
219 friend class KHTMLRun;
220 friend class DOM::HTMLFormElementImpl;
221 friend class KJS::Window;
222 friend class KJS::ScheduledAction;
223 friend class KJS::JSNodeFilter;
224 friend class KJS::WindowFunc;
225 friend class KJS::ExternalFunc;
226 friend class KJS::JSEventListener;
227 friend class KJS::JSLazyEventListener;
228 friend class KJS::DOMDocument;
229 friend class KJS::HTMLElement;
230 friend class KJS::SourceFile;
231 friend class KJS::DOMSelection;
232 friend class KJS::DOMSelectionProtoFunc;
233 friend class KJS::KHTMLPartScriptable;
234 friend class KJSProxy;
235 friend class KHTMLPartBrowserExtension;
236 friend class DOM::DocumentImpl;
237 friend class DOM::HTMLDocumentImpl;
238 friend class DOM::Selection;
239 friend class DOM::Editor;
240 friend class KHTMLPartBrowserHostExtension;
241 friend class khtml::HTMLTokenizer;
242 friend class khtml::XMLTokenizer;
243 friend class khtml::RenderWidget;
244 friend class khtml::RenderBlock;
245 friend class khtml::CSSStyleSelector;
246 friend class khtml::EditCommandImpl;
247 friend class khtml::KHTMLPartAccessor;
248 friend class KHTMLPartIface;
249 friend class KHTMLPartFunction;
250 friend class KHTMLPopupGUIClient;
251 friend class KHTMLFind;
252 friend class StorePass;
253 friend class WebCore::SVGDocumentExtensions;
254
255 Q_PROPERTY( bool javaScriptEnabled READ jScriptEnabled WRITE setJScriptEnabled )
256 Q_PROPERTY( bool javaEnabled READ javaEnabled WRITE setJavaEnabled )
257 Q_PROPERTY( bool dndEnabled READ dndEnabled WRITE setDNDEnabled )
258 Q_PROPERTY( bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled )
259 Q_PROPERTY( DNSPrefetch dnsPrefetch READ dnsPrefetch WRITE setDNSPrefetch )
260
261 /*
262 *
263 * Don't add setOnlyLocalReferences here. It shouldn't be accessible via DBus.
264 *
265 **/
266 Q_PROPERTY( bool modified READ isModified )
267 Q_PROPERTY( QString encoding READ encoding WRITE setEncoding )
268 Q_PROPERTY( QString lastModified READ lastModified )
269 Q_PROPERTY( bool metaRefreshEnabled READ metaRefreshEnabled WRITE setMetaRefreshEnabled )
270
271public:
272 enum GUIProfile { DefaultGUI, BrowserViewGUI /* ... */ };
273
274 /**
275 * DNS Prefetching Mode enumeration
276 * @li DNSPrefetchDisabled do not prefetch hostnames
277 * @li DNSPrefetchEnabled always prefetch hostnames
278 * @li DNSPrefetchOnlyWWWAndSLD only do DNS prefetching for bare SLD and www sub-domain
279 */
280
281 enum DNSPrefetch {
282 DNSPrefetchDisabled=0,
283 DNSPrefetchEnabled,
284 DNSPrefetchOnlyWWWAndSLD
285 };
286
287 /**
288 * Constructs a new KHTMLPart.
289 *
290 * KHTML basically consists of two objects: The KHTMLPart itself,
291 * holding the document data (DOM document), and the KHTMLView,
292 * derived from QScrollArea, in which the document content is
293 * rendered in. You can specify two different parent objects for a
294 * KHTMLPart, one parent for the KHTMLPart document and one parent
295 * for the KHTMLView. If the second @p parent argument is 0L, then
296 * @p parentWidget is used as parent for both objects, the part and
297 * the view.
298 */
299 KHTMLPart( QWidget *parentWidget = 0,
300 QObject *parent = 0, GUIProfile prof = DefaultGUI );
301 /**
302 * Constructs a new KHTMLPart.
303 *
304 * This constructor is useful if you wish to subclass KHTMLView.
305 * If the @p view passed as first argument to the constructor was built with a
306 * null KHTMLPart pointer, then the newly created KHTMLPart will be assigned as the view's part.
307 *
308 * Therefore, you might either initialize the view as part of the initialization list of
309 * your derived KHTMLPart class constructor:
310 * \code
311 * MyKHTMLPart() : KHTMLPart( new MyKHTMLView( this ), ...
312 * \endcode
313 * Or separately build the KHTMLView beforehand:
314 * \code
315 * KHTMLView * v = KHTMLView( 0L, parentWidget());
316 * KHTMLPart * p = KHTMLPart( v ); // p will be assigned to v, so that v->part() == p
317 * \endcode
318 */
319 KHTMLPart( KHTMLView *view, QObject *parent = 0, GUIProfile prof = DefaultGUI );
320
321 /**
322 * Destructor.
323 */
324 virtual ~KHTMLPart();
325
326 /**
327 * Opens the specified URL @p url.
328 *
329 * Reimplemented from KParts::ReadOnlyPart::openUrl .
330 */
331 virtual bool openUrl( const KUrl &url );
332
333 /**
334 * Stops loading the document and kills all data requests (for images, etc.)
335 */
336 virtual bool closeUrl();
337
338 /**
339 * Called when a certain error situation (i.e. connection timed out) occurred.
340 * The default implementation either shows a KIO error dialog or loads a more
341 * verbose error description a as page, depending on the users configuration.
342 * @p job is the job that signaled the error situation
343 */
344 virtual void showError( KJob* job );
345
346 /**
347 * Returns a reference to the DOM HTML document (for non-HTML documents, returns null)
348 */
349 DOM::HTMLDocument htmlDocument() const;
350
351 /**
352 * Returns a reference to the DOM document.
353 */
354 DOM::Document document() const;
355
356 /**
357 * Returns the content of the source document.
358 */
359 QString documentSource() const;
360
361 /**
362 * Returns the node that has the keyboard focus.
363 */
364 DOM::Node activeNode() const;
365
366 /**
367 * Returns a pointer to the KParts::BrowserExtension.
368 */
369 KParts::BrowserExtension *browserExtension() const;
370 KParts::BrowserHostExtension *browserHostExtension() const;
371
372 /**
373 * Returns a pointer to the HTML document's view.
374 */
375 KHTMLView *view() const;
376
377 /**
378 * Enable/disable Javascript support. Note that this will
379 * in either case permanently override the default usersetting.
380 * If you want to have the default UserSettings, don't call this
381 * method.
382 */
383 void setJScriptEnabled( bool enable );
384
385 /**
386 * Returns @p true if Javascript support is enabled or @p false
387 * otherwise.
388 */
389 bool jScriptEnabled() const;
390
391 /**
392 * Returns the JavaScript interpreter the part is using. This method is
393 * mainly intended for applications which embed and extend the part and
394 * provides a mechanism for adding additional native objects to the
395 * interpreter (or removing the built-ins).
396 *
397 * One thing people using this method to add things to the interpreter must
398 * consider, is that when you start writing new content to the part, the
399 * interpreter is cleared. This includes both use of the
400 * begin( const KUrl &, int, int ) method, and the openUrl( const KUrl & )
401 * method. If you want your objects to have a longer lifespan, then you must
402 * retain a KJS::Object yourself to ensure that the reference count of your
403 * custom objects never reaches 0. You will also need to re-add your
404 * bindings every time this happens - one way to detect the need for this is
405 * to connect to the docCreated() signal, another is to reimplement the
406 * begin() method.
407 */
408 KJS::Interpreter *jScriptInterpreter();
409
410 /**
411 * Enable/disable statusbar messages.
412 * When this class wants to set the statusbar text, it emits
413 * setStatusBarText(const QString & text)
414 * If you want to catch this for your own statusbar, note that it returns
415 * back a rich text string, starting with "<qt>". This you need to
416 * either pass this into your own QLabel or to strip out the tags
417 * before passing it to QStatusBar::message(const QString & message)
418 *
419 * @see KParts::Part::setStatusBarText( const QString & text )
420 */
421 void setStatusMessagesEnabled( bool enable );
422
423 /**
424 * Returns @p true if status messages are enabled.
425 */
426 bool statusMessagesEnabled() const;
427
428 /**
429 * Enable/disable automatic forwarding by &lt;meta http-equiv="refresh" ....&gt;
430 */
431 void setMetaRefreshEnabled( bool enable );
432
433 /**
434 * Returns @p true if automatic forwarding is enabled.
435 */
436 bool metaRefreshEnabled() const;
437
438 /**
439 * Same as executeScript( const QString & ) except with the Node parameter
440 * specifying the 'this' value.
441 */
442 QVariant executeScript( const DOM::Node &n, const QString &script );
443
444 /**
445 * Enables or disables Drag'n'Drop support. A drag operation is started if
446 * the users drags a link.
447 */
448 void setDNDEnabled( bool b );
449
450 /**
451 * Returns whether Dragn'n'Drop support is enabled or not.
452 */
453 bool dndEnabled() const;
454
455 /**
456 * Enables/disables Java applet support. Note that calling this function
457 * will permanently override the User settings about Java applet support.
458 * Not calling this function is the only way to let the default settings
459 * apply.
460 */
461 void setJavaEnabled( bool enable );
462
463 /**
464 * Return @p true if Java applet support is enabled, @p false if disabled
465 */
466 bool javaEnabled() const;
467
468 /**
469 * Enables or disables plugins, default is enabled
470 */
471 void setPluginsEnabled( bool enable );
472
473 /**
474 * Returns @p true if plugins are enabled, @p false if disabled.
475 */
476 bool pluginsEnabled() const;
477
478 /**
479 * Specifies whether images contained in the document should be loaded
480 * automatically or not.
481 *
482 * @note Request will be ignored if called before begin().
483 */
484 void setAutoloadImages( bool enable );
485 /**
486 * Returns whether images contained in the document are loaded automatically
487 * or not.
488 * @note that the returned information is unrelieable as long as no begin()
489 * was called.
490 */
491 bool autoloadImages() const;
492
493 /**
494 * Security option.
495 *
496 * Specify whether only file:/ or data:/ urls are allowed to be loaded without
497 * user confirmation by KHTML.
498 * ( for example referenced by stylesheets, images, scripts, subdocuments, embedded elements ).
499 *
500 * This option is mainly intended for enabling the "mail reader mode", where you load untrusted
501 * content with a file:/ url.
502 *
503 * Please note that enabling this option currently automatically disables Javascript,
504 * Java and Plugins support. This might change in the future if the security model
505 * is becoming more sophisticated, so don't rely on this behaviour.
506 *
507 * ( default @p false - everything is loaded unless forbidden by KApplication::authorizeURLAction).
508 */
509 void setOnlyLocalReferences( bool enable );
510
511 /**
512 * Security option. If this is set to true, content loaded from external URLs
513 * will be permitted to access images on disk regardless of of the Kiosk policy.
514 * You should be careful in enabling this, as it may make it easier to fake
515 * any HTML-based chrome or to perform other such user-confusion attack.
516 * @p false by default.
517 *
518 * @since 4.6
519 */
520 void setForcePermitLocalImages( bool enable );
521
522 /**
523 * Sets whether DNS Names found in loaded documents'anchors should be pre-fetched (pre-resolved).
524 * Note that calling this function will permanently override the User settings about
525 * DNS prefetch support.
526 * Not calling this function is the only way to let the default settings apply.
527 *
528 * @note This setting has no effect if @ref setOnlyLocalReferences() mode is enabled.
529 *
530 * @param pmode the mode to set. See @ref DNSPrefetch enum for explanation of values.
531 *
532 * @since 4.2
533 */
534 void setDNSPrefetch( DNSPrefetch pmode );
535
536 /**
537 * Returns currently set DNS prefetching mode.
538 * See @p DNSPrefetch enum for explanation of values.
539 *
540 * @note Always returns @p DNSPrefetchDisabled if @ref setOnlyLocalReferences() mode is enabled.
541 *
542 * @since 4.2
543 */
544 DNSPrefetch dnsPrefetch() const;
545
546 /**
547 * Returns whether only file:/ or data:/ references are allowed
548 * to be loaded ( default @p false ). See setOnlyLocalReferences.
549 **/
550 bool onlyLocalReferences() const;
551
552 /**
553 * If true, local image files will be loaded even when forbidden by the
554 * Kiosk/KAuthorized policies ( default @p false ). See @ref setForcePermitLocalImages.
555 *
556 * @since 4.6
557 **/
558 bool forcePermitLocalImages() const;
559
560 /** Returns whether caret mode is on/off.
561 */
562 bool isCaretMode() const;
563
564 /**
565 * Returns @p true if the document is editable, @p false otherwise.
566 */
567 bool isEditable() const;
568
569 /**
570 * Sets the caret to the given position.
571 *
572 * If the given location is invalid, it will snap to the nearest valid
573 * location. Immediately afterwards a @p caretPositionChanged signal
574 * containing the effective position is emitted
575 * @param node node to set to
576 * @param offset zero-based offset within the node
577 * @param extendSelection If @p true, a selection will be spanned from the
578 * last caret position to the given one. Otherwise, any existing selection
579 * will be deselected.
580 */
581 void setCaretPosition(DOM::Node node, long offset, bool extendSelection = false);
582
583 /**
584 * Enumeration for displaying the caret.
585 */
586 enum CaretDisplayPolicy {
587 CaretVisible, /**< caret is displayed */
588 CaretInvisible, /**< caret is not displayed */
589 CaretBlink /**< caret toggles between visible and invisible */
590 };
591
592 /**
593 * Returns the current caret policy when the view is not focused.
594 */
595 CaretDisplayPolicy caretDisplayPolicyNonFocused() const;
596
597 /**
598 * Sets the caret display policy when the view is not focused.
599 *
600 * Whenever the caret is in use, this property determines how the
601 * caret should be displayed when the document view is not focused.
602 *
603 * The default policy is CaretInvisible.
604 * @param policy new display policy
605 */
606 void setCaretDisplayPolicyNonFocused(CaretDisplayPolicy policy);
607
608#ifndef KDE_NO_COMPAT
609 KUrl baseURL() const;
610#endif
611
612 /**
613 * Returns the URL for the background Image (used by save background)
614 */
615 KUrl backgroundURL() const;
616
617 /**
618 * Schedules a redirection after @p delay seconds.
619 */
620 void scheduleRedirection( int delay, const QString &url, bool lockHistory = true );
621
622 /**
623 * Clears the widget and prepares it for new content.
624 *
625 * If you want url() to return
626 * for example "file:/tmp/test.html", you can use the following code:
627 * \code
628 * view->begin( KUrl("file:/tmp/test.html" ) );
629 * \endcode
630 *
631 * @param url is the url of the document to be displayed. Even if you
632 * are generating the HTML on the fly, it may be useful to specify
633 * a directory so that any pixmaps are found.
634 *
635 * @param xOffset is the initial horizontal scrollbar value. Usually
636 * you don't want to use this.
637 *
638 * @param yOffset is the initial vertical scrollbar value. Usually
639 * you don't want to use this.
640 *
641 * All child frames and the old document are removed if you call
642 * this method.
643 */
644 virtual void begin( const KUrl &url = KUrl(), int xOffset = 0, int yOffset = 0 );
645
646 /**
647 * Writes another part of the HTML code to the widget.
648 *
649 * You may call
650 * this function many times in sequence. But remember: The fewer calls
651 * you make, the faster the widget will be.
652 *
653 * The HTML code is send through a decoder which decodes the stream to
654 * Unicode.
655 *
656 * The @p len parameter is needed for streams encoded in utf-16,
657 * since these can have \\0 chars in them. In case the encoding
658 * you're using isn't utf-16, you can safely leave out the length
659 * parameter.
660 *
661 * Attention: Don't mix calls to write( const char *) with calls
662 * to write( const QString & ).
663 *
664 * The result might not be what you want.
665 */
666 virtual void write( const char *str, int len = -1 );
667
668 /**
669 * Writes another part of the HTML code to the widget.
670 *
671 * You may call
672 * this function many times in sequence. But remember: The fewer calls
673 * you make, the faster the widget will be.
674 *
675 * For historic and backward compatibility reasons, this method will force
676 * the use of strict mode for the document, unless setAlwaysHonourDoctype()
677 * has been called previously.
678 */
679 // FIXME KDE5: always honour doctype, remove setAlwaysHonourDoctype()
680 virtual void write( const QString &str );
681
682 /**
683 * Call this after your last call to write().
684 */
685 virtual void end();
686
687 /*
688 * Prints the current HTML page laid out for the printer.
689 *
690 * (not implemented at the moment)
691 */
692 // void print(QPainter *, int pageHeight, int pageWidth);
693
694 /**
695 * Paints the HTML page to a QPainter. See KHTMLView::paint for details
696 */
697 void paint( QPainter *, const QRect &, int = 0, bool * = 0 );
698
699 /**
700 * Sets the encoding the page uses.
701 *
702 * This can be different from the charset. The widget will try to reload the current page in the new
703 * encoding, if url() is not empty.
704 */
705 bool setEncoding( const QString &name, bool override = false );
706
707 /**
708 * Returns the encoding the page currently uses.
709 *
710 * Note that the encoding might be different from the charset.
711 */
712 QString encoding() const;
713
714 /**
715 * Sets a user defined style sheet to be used on top of the HTML 4
716 * default style sheet.
717 *
718 * This gives a wide range of possibilities to
719 * change the layout of the page.
720 *
721 * To have an effect this function has to be called after calling begin().
722 */
723 void setUserStyleSheet( const KUrl &url );
724
725 /**
726 * Sets a user defined style sheet to be used on top of the HTML 4
727 * default style sheet.
728 *
729 * This gives a wide range of possibilities to
730 * change the layout of the page.
731 *
732 * To have an effect this function has to be called after calling begin().
733 */
734 void setUserStyleSheet( const QString &styleSheet );
735
736public:
737
738 /**
739 * Sets the standard font style.
740 *
741 * @param name The font name to use for standard text.
742 */
743 void setStandardFont( const QString &name );
744
745 /**
746 * Sets the fixed font style.
747 *
748 * @param name The font name to use for fixed text, e.g.
749 * the <tt>&lt;pre&gt;</tt> tag.
750 */
751 void setFixedFont( const QString &name );
752
753 /**
754 * Finds the anchor named @p name.
755 *
756 * If the anchor is found, the widget
757 * scrolls to the closest position. Returns @p if the anchor has
758 * been found.
759 */
760 bool gotoAnchor( const QString &name );
761
762 /**
763 * Go to the next anchor
764 *
765 * This is useful to navigate from outside the navigator
766 */
767 bool nextAnchor();
768
769 /**
770 * Go to previous anchor
771 */
772 bool prevAnchor();
773
774 /**
775 * Sets the cursor to use when the cursor is on a link.
776 */
777 void setURLCursor( const QCursor &c );
778
779 /**
780 * Returns the cursor which is used when the cursor is on a link.
781 */
782 QCursor urlCursor() const;
783
784 /**
785 * Extra Find options that can be used when calling the extended findText().
786 */
787 enum FindOptions
788 {
789 FindLinksOnly = 1 * KFind::MinimumUserOption,
790 FindNoPopups = 2 * KFind::MinimumUserOption
791 //FindIncremental = 4 * KFind::MinimumUserOption
792 };
793
794 /**
795 * Starts a new search by popping up a dialog asking the user what he wants to
796 * search for.
797 */
798 void findText();
799
800 /**
801 * Starts a new search, but bypasses the user dialog.
802 * @param str The string to search for.
803 * @param options Find options.
804 * @param parent Parent used for centering popups like "string not found".
805 * @param findDialog Optionally, you can supply your own dialog.
806 */
807 void findText( const QString &str, long options, QWidget *parent = 0,
808 KFindDialog *findDialog = 0 );
809
810 /**
811 * Initiates a text search.
812 */
813 void findTextBegin();
814
815 /**
816 * Finds the next occurrence of a string set by @ref findText()
817 * @param reverse if @p true, revert seach direction (only if no find dialog is used)
818 * @return @p true if a new match was found.
819 */
820 bool findTextNext( bool reverse = false );
821
822 /**
823 * Sets the Zoom factor. The value is given in percent, larger values mean a
824 * generally larger font and larger page contents.
825 *
826 * The given value should be in the range of 20..300, values outside that
827 * range are not guaranteed to work. A value of 100 will disable all zooming
828 * and show the page with the sizes determined via the given lengths in the
829 * stylesheets.
830 */
831 void setZoomFactor(int percent);
832
833 /**
834 * Returns the current zoom factor.
835 */
836 int zoomFactor() const;
837
838 /**
839 * Sets the scale factor to be applied to fonts. The value is given in percent,
840 * larger values mean generally larger fonts.
841 *
842 * The given value should be in the range of 20..300, values outside that
843 * range are not guaranteed to work. A value of 100 will disable all scaling of font sizes
844 * and show the page with the sizes determined via the given lengths in the
845 * stylesheets.
846 */
847 void setFontScaleFactor(int percent);
848
849 /**
850 * Returns the current font scale factor.
851 */
852 int fontScaleFactor() const;
853
854 /**
855 * Returns the text the user has marked.
856 */
857 virtual QString selectedText() const;
858
859 /**
860 * Return the text the user has marked. This is guaranteed to be valid xml,
861 * and to contain the \<html> and \<body> tags.
862 *
863 * FIXME probably should make virtual for 4.0 ?
864 */
865 QString selectedTextAsHTML() const;
866
867 /**
868 * Returns the selected part of the HTML.
869 */
870 DOM::Range selection() const;
871
872 /**
873 * Returns the selected part of the HTML by returning the starting and end
874 * position.
875 *
876 * If there is no selection, both nodes and offsets are equal.
877 * @param startNode returns node selection starts in
878 * @param startOffset returns offset within starting node
879 * @param endNode returns node selection ends in
880 * @param endOffset returns offset within end node.
881 */
882 void selection(DOM::Node &startNode, long &startOffset,
883 DOM::Node &endNode, long &endOffset) const;
884
885 /**
886 * Sets the current selection.
887 */
888 void setSelection( const DOM::Range & );
889
890 /**
891 * Has the user selected anything?
892 *
893 * Call selectedText() to
894 * retrieve the selected text.
895 *
896 * @return @p true if there is text selected.
897 */
898 bool hasSelection() const;
899
900 /**
901 * Returns the instance of the attached html editor interface.
902 *
903 */
904 DOM::Editor *editor() const;
905
906 /**
907 * Marks all text in the document as selected.
908 */
909 void selectAll();
910
911 /**
912 * Convenience method to show the document's view.
913 *
914 * Equivalent to widget()->show() or view()->show() .
915 */
916 void show();
917
918 /**
919 * Convenience method to hide the document's view.
920 *
921 * Equivalent to widget()->hide() or view()->hide().
922 */
923 void hide();
924
925 /**
926 * Returns a reference to the partmanager instance which
927 * manages html frame objects.
928 */
929 KParts::PartManager *partManager();
930
931 /**
932 * Saves the KHTMLPart's complete state (including child frame
933 * objects) to the provided QDataStream.
934 *
935 * This is called from the saveState() method of the
936 * browserExtension().
937 */
938 virtual void saveState( QDataStream &stream );
939 /**
940 * Restores the KHTMLPart's previously saved state (including
941 * child frame objects) from the provided QDataStream.
942 *
943 * @see saveState()
944 *
945 * This is called from the restoreState() method of the
946 * browserExtension() .
947 **/
948 virtual void restoreState( QDataStream &stream );
949
950 /**
951 * Returns the @p Node currently under the mouse.
952 *
953 * The returned node may be a shared node (e. g. an \<area> node if the
954 * mouse is hovering over an image map).
955 */
956 DOM::Node nodeUnderMouse() const;
957
958 /**
959 * Returns the @p Node currently under the mouse that is not shared.
960 *
961 * The returned node is always the node that is physically under the mouse
962 * pointer (irrespective of logically overlying elements like, e. g.,
963 * \<area> on image maps).
964 */
965 DOM::Node nonSharedNodeUnderMouse() const;
966
967 /**
968 * @internal
969 */
970 const KHTMLSettings *settings() const;
971
972 /**
973 * Returns a pointer to the parent KHTMLPart if the part is a frame
974 * in an HTML frameset.
975 *
976 * Returns 0L otherwise.
977 */
978 // ### KDE5 make const
979 KHTMLPart *parentPart();
980
981 /**
982 * Returns a list of names of all frame (including iframe) objects of
983 * the current document. Note that this method is not working recursively
984 * for sub-frames.
985 */
986 QStringList frameNames() const;
987
988 QList<KParts::ReadOnlyPart*> frames() const;
989
990 /**
991 * Finds a frame by name. Returns 0L if frame can't be found.
992 */
993 KHTMLPart *findFrame( const QString &f );
994
995 /**
996 * Recursively finds the part containing the frame with name @p f
997 * and checks if it is accessible by @p callingPart
998 * Returns 0L if no suitable frame can't be found.
999 * Returns parent part if a suitable frame was found and
1000 * frame info in @p *childFrame
1001 */
1002 KHTMLPart *findFrameParent( KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame=0 );
1003
1004 /**
1005 * Return the current frame (the one that has focus)
1006 * Not necessarily a direct child of ours, framesets can be nested.
1007 * Returns "this" if this part isn't a frameset.
1008 */
1009 KParts::ReadOnlyPart *currentFrame() const;
1010
1011 /**
1012 * Returns whether a frame with the specified name is exists or not.
1013 * In contrast to the findFrame method this one also returns @p true
1014 * if the frame is defined but no displaying component has been
1015 * found/loaded, yet.
1016 */
1017 bool frameExists( const QString &frameName );
1018
1019 /**
1020 * Returns child frame framePart its script interpreter
1021 */
1022 KJSProxy *framejScript(KParts::ReadOnlyPart *framePart);
1023
1024 /**
1025 * Finds a frame by name. Returns 0L if frame can't be found.
1026 */
1027 KParts::ReadOnlyPart *findFramePart( const QString &f );
1028 /**
1029 * Called by KJS.
1030 * Sets the StatusBarText assigned
1031 * via window.status
1032 */
1033 void setJSStatusBarText( const QString &text );
1034
1035 /**
1036 * Called by KJS.
1037 * Sets the DefaultStatusBarText assigned
1038 * via window.defaultStatus
1039 */
1040 void setJSDefaultStatusBarText( const QString &text );
1041
1042 /**
1043 * Called by KJS.
1044 * Returns the StatusBarText assigned
1045 * via window.status
1046 */
1047 QString jsStatusBarText() const;
1048
1049 /**
1050 * Called by KJS.
1051 * Returns the DefaultStatusBarText assigned
1052 * via window.defaultStatus
1053 */
1054 QString jsDefaultStatusBarText() const;
1055
1056 /**
1057 * Referrer used for links in this page.
1058 */
1059 QString referrer() const;
1060
1061 /**
1062 * Referrer used to obtain this page.
1063 */
1064 QString pageReferrer() const;
1065
1066 /**
1067 * Last-modified date (in raw string format), if received in the [HTTP] headers.
1068 */
1069 QString lastModified() const;
1070
1071 /**
1072 * Loads a style sheet into the stylesheet cache.
1073 */
1074 void preloadStyleSheet( const QString &url, const QString &stylesheet );
1075
1076 /**
1077 * Loads a script into the script cache.
1078 */
1079 void preloadScript( const QString &url, const QString &script );
1080
1081 /**
1082 * Returns whether the given point is inside the current selection.
1083 *
1084 * The coordinates are content-coordinates.
1085 */
1086 bool isPointInsideSelection(int x, int y);
1087
1088 /**
1089 * @internal
1090 */
1091 bool restored() const;
1092
1093 /**
1094 * Sets whether the document's Doctype should always be used
1095 * to determine the parsing mode for the document.
1096 *
1097 * Without this, parsing will be forced to
1098 * strict mode when using the write( const QString &str )
1099 * method for backward compatibility reasons.
1100 *
1101 */
1102 // ### KDE5 remove - fix write( const QString &str ) instead
1103 void setAlwaysHonourDoctype( bool b = true );
1104
1105 // ### KDE5 remove me
1106 enum FormNotification { NoNotification = 0, Before, Only, Unused=255 };
1107 /**
1108 * Determine if signal should be emitted before, instead or never when a
1109 * submitForm() happens.
1110 * ### KDE5 remove me
1111 */
1112 void setFormNotification(FormNotification fn);
1113
1114 /**
1115 * Determine if signal should be emitted before, instead or never when a
1116 * submitForm() happens.
1117 * ### KDE5 remove me
1118 */
1119 FormNotification formNotification() const;
1120
1121 /**
1122 * Returns the toplevel (origin) URL of this document, even if this
1123 * part is a frame or an iframe.
1124 *
1125 * @return the actual original url.
1126 */
1127 KUrl toplevelURL();
1128
1129 /**
1130 * Checks whether the page contains unsubmitted form changes.
1131 *
1132 * @return @p true if form changes exist
1133 */
1134 bool isModified() const;
1135
1136 /**
1137 * Shows or hides the suppressed popup indicator
1138 */
1139 void setSuppressedPopupIndicator( bool enable, KHTMLPart *originPart = 0 );
1140
1141 /**
1142 * @internal
1143 */
1144 bool inProgress() const;
1145
1146Q_SIGNALS:
1147 /**
1148 * Emitted if the cursor is moved over an URL.
1149 */
1150 void onURL( const QString &url );
1151
1152 /**
1153 * Emitted when the user clicks the right mouse button on the document.
1154 * See KParts::BrowserExtension for two more popupMenu signals emitted by khtml,
1155 * with much more information in the signal.
1156 */
1157 void popupMenu( const QString &url, const QPoint &point );
1158
1159 /**
1160 * This signal is emitted when the selection changes.
1161 */
1162 void selectionChanged();
1163
1164 /**
1165 * This signal is emitted when an element retrieves the
1166 * keyboard focus. Note that the signal argument can be
1167 * a null node if no element is active, meaning a node
1168 * has explicitly been deactivated without a new one
1169 * becoming active.
1170 */
1171 void nodeActivated( const DOM::Node & );
1172
1173 /**
1174 * @internal */
1175 void docCreated();
1176
1177 /**
1178 * This signal is emitted whenever the caret position has been changed.
1179 *
1180 * The signal transmits the position the DOM::Range way, the node and
1181 * the zero-based offset within this node.
1182 * @param node node which the caret is in. This can be null if the caret
1183 * has been deactivated.
1184 * @param offset offset within the node. If the node is null, the offset
1185 * is meaningless.
1186 */
1187 void caretPositionChanged(const DOM::Node &node, long offset);
1188
1189
1190 /**
1191 * If form notification is on, this will be emitted either for a form
1192 * submit or before the form submit according to the setting.
1193 * ### KDE4 remove me
1194 */
1195 void formSubmitNotification(const char *action, const QString& url,
1196 const QByteArray& formData, const QString& target,
1197 const QString& contentType, const QString& boundary);
1198
1199 /**
1200 * Emitted whenever the configuration has changed
1201 */
1202 void configurationChanged();
1203
1204
1205protected:
1206
1207 /**
1208 * returns a KUrl object for the given url. Use when
1209 * you know what you're doing.
1210 */
1211 KUrl completeURL( const QString &url );
1212
1213 /**
1214 * presents a detailed error message to the user.
1215 * @p errorCode kio error code, eg KIO::ERR_SERVER_TIMEOUT.
1216 * @p text kio additional information text.
1217 * @p url the url that triggered the error.
1218 */
1219 void htmlError( int errorCode, const QString& text, const KUrl& reqUrl );
1220
1221 virtual void customEvent( QEvent *event );
1222
1223 /**
1224 * Eventhandler of the khtml::MousePressEvent.
1225 */
1226 virtual void khtmlMousePressEvent( khtml::MousePressEvent *event );
1227 /**
1228 * Eventhandler for the khtml::MouseDoubleClickEvent.
1229 */
1230 virtual void khtmlMouseDoubleClickEvent( khtml::MouseDoubleClickEvent * );
1231 /**
1232 * Eventhandler for the khtml::MouseMouseMoveEvent.
1233 */
1234 virtual void khtmlMouseMoveEvent( khtml::MouseMoveEvent *event );
1235 /**
1236 * Eventhandler for the khtml::MouseMouseReleaseEvent.
1237 */
1238 virtual void khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *event );
1239 /**
1240 * Eventhandler for the khtml::DrawContentsEvent.
1241 */
1242 virtual void khtmlDrawContentsEvent( khtml::DrawContentsEvent * );
1243
1244 /**
1245 * Internal reimplementation of KParts::Part::guiActivateEvent .
1246 */
1247 virtual void guiActivateEvent( KParts::GUIActivateEvent *event );
1248
1249 /**
1250 * Internal empty reimplementation of KParts::ReadOnlyPart::openFile .
1251 */
1252 virtual bool openFile();
1253
1254 virtual bool urlSelected( const QString &url, int button, int state,
1255 const QString &_target,
1256 const KParts::OpenUrlArguments& args = KParts::OpenUrlArguments(),
1257 const KParts::BrowserArguments& browserArgs = KParts::BrowserArguments() );
1258
1259 /**
1260 * This method is called when a new embedded object (include html frames) is to be created.
1261 * Reimplement it if you want to add support for certain embeddable objects without registering
1262 * them in the KDE wide registry system (KSyCoCa) . Another reason for re-implementing this
1263 * method could be if you want to derive from KTHMLPart and also want all html frame objects
1264 * to be a object of your derived type, in which case you should return a new instance for
1265 * the mimetype 'text/html' .
1266 */
1267 virtual KParts::ReadOnlyPart *createPart( QWidget *parentWidget,
1268 QObject *parent,
1269 const QString &mimetype, QString &serviceName,
1270 QStringList &serviceTypes, const QStringList &params);
1271
1272 // This is for RenderPartObject. We want to ask the 'download plugin?'
1273 // question only once per mimetype
1274 bool pluginPageQuestionAsked( const QString& mimetype ) const;
1275 void setPluginPageQuestionAsked( const QString& mimetype );
1276
1277 enum PageSecurity { NotCrypted, Encrypted, Mixed };
1278 void setPageSecurity( PageSecurity sec );
1279
1280 /**
1281 * Implements the streaming API of KParts::ReadOnlyPart.
1282 */
1283 virtual bool doOpenStream( const QString& mimeType );
1284
1285 /**
1286 * Implements the streaming API of KParts::ReadOnlyPart.
1287 */
1288 virtual bool doWriteStream( const QByteArray& data );
1289
1290 /**
1291 * Implements the streaming API of KParts::ReadOnlyPart.
1292 */
1293 virtual bool doCloseStream();
1294
1295 /**
1296 * @internal
1297 */
1298 virtual void timerEvent(QTimerEvent *);
1299
1300 /**
1301 * Will pre-resolve @p name according to dnsPrefetch current settings
1302 * Returns @p true if the name will be pre-resolved.
1303 * Otherwise returns false.
1304 */
1305
1306 bool mayPrefetchHostname( const QString& name );
1307
1308 /**
1309 * @internal
1310 */
1311 void updateZoomFactor();
1312
1313public Q_SLOTS:
1314
1315 /**
1316 * Sets the focused node of the document to the specified node. If the node is a form control, the control will
1317 * receive focus in the same way that it would if the user had clicked on it or tabbed to it with the keyboard. For
1318 * most other types of elements, there is no visual indication of whether or not they are focused.
1319 *
1320 * See activeNode
1321 *
1322 * @param node The node to focus
1323 */
1324 void setActiveNode( const DOM::Node &node );
1325
1326 /**
1327 * Stops all animated images on the current and child pages
1328 */
1329 void stopAnimations();
1330
1331 /**
1332 * Execute the specified snippet of JavaScript code.
1333 *
1334 * Returns @p true if JavaScript was enabled, no error occurred
1335 * and the code returned @p true itself or @p false otherwise.
1336 * @deprecated, use executeString( DOM::Node(), script)
1337 */
1338 QVariant executeScript( const QString &script );
1339
1340 /**
1341 * Enables/disables caret mode.
1342 *
1343 * Enabling caret mode displays a caret which can be used to navigate
1344 * the document using the keyboard only. Caret mode is switched off by
1345 * default.
1346 *
1347 * @param enable @p true to enable, @p false to disable caret mode.
1348 */
1349 void setCaretMode(bool enable);
1350
1351 /**
1352 * Makes the document editable.
1353 *
1354 * Setting this property to @p true makes the document, and its
1355 * subdocuments (such as frames, iframes, objects) editable as a whole.
1356 * FIXME: insert more information about navigation, features etc. as seen fit
1357 *
1358 * @param enable @p true to set document editable, @p false to set it
1359 * read-only.
1360 */
1361 void setEditable(bool enable);
1362
1363 /**
1364 * Sets the visibility of the caret.
1365 *
1366 * This methods displays or hides the caret regardless of the current
1367 * caret display policy (see setCaretDisplayNonFocused), and regardless
1368 * of focus.
1369 *
1370 * The caret will be shown/hidden only under at least one of
1371 * the following conditions:
1372 * @li the document is editable
1373 * @li the document is in caret mode
1374 * @li the document's currently focused element is editable
1375 *
1376 * @param show @p true to make visible, @p false to hide.
1377 */
1378 void setCaretVisible(bool show);
1379
1380 // ### KDE4 FIXME:
1381 // Remove this and make the one below protected+virtual slot.
1382 // Warning: this is effectively "internal". Be careful.
1383 void submitFormProxy( const char *action, const QString &url,
1384 const QByteArray &formData,
1385 const QString &target,
1386 const QString& contentType = QString(),
1387 const QString& boundary = QString() );
1388
1389protected Q_SLOTS:
1390
1391 /**
1392 * Called when the job downloading the page is finished.
1393 * Can be reimplemented, for instance to get metadata out of the job,
1394 * but make sure to call KHTMLPart::slotFinished() too.
1395 */
1396 virtual void slotFinished( KJob* );
1397
1398protected:
1399 /**
1400 * Hook for adding code before a job is started.
1401 * This can be used to add metadata, like job->addMetaData("PropagateHttpHeader", "true")
1402 * to get the HTTP headers.
1403 */
1404 virtual void startingJob( KIO::Job * ) {}
1405
1406private Q_SLOTS:
1407
1408 /**
1409 * @internal
1410 */
1411 void reparseConfiguration();
1412
1413 /**
1414 * @internal
1415 */
1416 void slotData( KIO::Job*, const QByteArray &data );
1417 /**
1418 * @internal
1419 */
1420 void slotInfoMessage( KJob*, const QString& msg );
1421 /**
1422 * @internal
1423 */
1424 void slotRestoreData( const QByteArray &data );
1425 /**
1426 * @internal
1427 */
1428 void slotFinishedParsing();
1429 /**
1430 * @internal
1431 */
1432 void slotRedirect();
1433 /**
1434 * @internal
1435 */
1436 void slotRedirection( KIO::Job*, const KUrl& );
1437 /**
1438 * @internal
1439 */
1440 void slotDebugScript();
1441 /**
1442 * @internal
1443 */
1444 void slotDebugDOMTree();
1445 /**
1446 * @internal
1447 */
1448 void slotDebugRenderTree();
1449
1450 void slotDebugFrameTree();
1451
1452 /**
1453 * @internal
1454 */
1455 void slotStopAnimations();
1456 /**
1457 * @internal
1458 */
1459 virtual void slotViewDocumentSource();
1460 /**
1461 * @internal
1462 */
1463 virtual void slotViewFrameSource();
1464 /**
1465 * @internal
1466 */
1467 void slotViewPageInfo();
1468 /**
1469 * @internal
1470 */
1471 virtual void slotSaveBackground();
1472 /**
1473 * @internal
1474 */
1475 virtual void slotSaveDocument();
1476 /**
1477 * @internal
1478 */
1479 virtual void slotSaveFrame();
1480 /**
1481 * @internal
1482 */
1483 virtual void slotSecurity();
1484 /**
1485 * @internal
1486 */
1487 virtual void slotSetEncoding(const QString &);
1488
1489 /**
1490 * @internal
1491 */
1492 virtual void slotUseStylesheet();
1493
1494 virtual void slotFind();
1495 virtual void slotFindDone(); // ### remove me
1496 virtual void slotFindDialogDestroyed(); // ### remove me
1497 void slotFindNext();
1498 void slotFindPrev();
1499 void slotFindAheadText();
1500 void slotFindAheadLink();
1501
1502 void slotIncZoom();
1503 void slotDecZoom();
1504 void slotIncZoomFast();
1505 void slotDecZoomFast();
1506
1507 void slotIncFontSize();
1508 void slotDecFontSize();
1509 void slotIncFontSizeFast();
1510 void slotDecFontSizeFast();
1511
1512 void slotLoadImages();
1513 void slotWalletClosed();
1514 void launchWalletManager();
1515 void walletMenu();
1516 void delNonPasswordStorableSite();
1517 void removeStoredPasswordForm(QAction* action);
1518 void addWalletFormKey(const QString& walletFormKey);
1519
1520 /**
1521 * @internal
1522 */
1523 void submitFormAgain();
1524
1525 /**
1526 * @internal
1527 */
1528 void updateActions();
1529 /**
1530 * @internal
1531 */
1532 void slotPartRemoved( KParts::Part *part );
1533 /**
1534 * @internal
1535 */
1536 void slotActiveFrameChanged( KParts::Part *part );
1537 /**
1538 * @internal
1539 */
1540 void slotChildStarted( KIO::Job *job );
1541 /**
1542 * @internal
1543 */
1544 void slotChildCompleted();
1545 /**
1546 * @internal
1547 */
1548 void slotChildCompleted( bool );
1549 /**
1550 * @internal
1551 */
1552 void slotParentCompleted();
1553 /**
1554 * @internal
1555 */
1556 void slotChildURLRequest( const KUrl &url, const KParts::OpenUrlArguments&, const KParts::BrowserArguments &args );
1557 /**
1558 * @internal
1559 */
1560 void slotChildDocCreated();
1561 /**
1562 * @internal
1563 */
1564 void slotRequestFocus( KParts::ReadOnlyPart * );
1565 void slotLoaderRequestStarted( khtml::DocLoader*, khtml::CachedObject* obj);
1566 void slotLoaderRequestDone( khtml::DocLoader*, khtml::CachedObject *obj );
1567 void checkCompleted();
1568
1569 /**
1570 * @internal
1571 */
1572 void slotAutoScroll();
1573
1574 void slotPrintFrame();
1575
1576 void slotSelectAll();
1577
1578 /**
1579 * @internal
1580 */
1581 void slotProgressUpdate();
1582
1583 /*
1584 * @internal
1585 */
1586 void slotJobPercent( KJob*, unsigned long );
1587
1588 /*
1589 * @internal
1590 */
1591 void slotJobDone( KJob* );
1592
1593 /*
1594 * @internal
1595 */
1596 void slotUserSheetStatDone( KJob* );
1597
1598 /*
1599 * @internal
1600 */
1601 void slotJobSpeed( KJob*, unsigned long );
1602
1603 /**
1604 * @internal
1605 */
1606 void slotClearSelection();
1607
1608 /**
1609 * @internal
1610 */
1611 void slotZoomView( int );
1612
1613 /**
1614 * @internal
1615 */
1616 void slotAutomaticDetectionLanguage(KEncodingDetector::AutoDetectScript scri);
1617
1618 /**
1619 * @internal
1620 */
1621 void slotToggleCaretMode();
1622
1623 /**
1624 * @internal
1625 */
1626 void suppressedPopupMenu();
1627
1628 /**
1629 * @internal
1630 */
1631 void togglePopupPassivePopup();
1632
1633 /**
1634 * @internal
1635 */
1636 void showSuppressedPopups();
1637
1638 /**
1639 * @internal
1640 */
1641 void launchJSConfigDialog();
1642
1643 /**
1644 * @internal
1645 */
1646 void launchJSErrorDialog();
1647
1648 /**
1649 * @internal
1650 */
1651 void removeJSErrorExtension();
1652
1653 /**
1654 * @internal
1655 */
1656 void disableJSErrorExtension();
1657
1658 /**
1659 * @internal
1660 */
1661 void jsErrorDialogContextMenu();
1662
1663 /**
1664 * @internal
1665 * used to restore or reset the view's scroll position (including positioning on anchors)
1666 * once a sufficient portion of the document as been laid out.
1667 */
1668 void restoreScrollPosition();
1669
1670 void walletOpened(KWallet::Wallet*);
1671
1672private:
1673
1674 KJSErrorDlg *jsErrorExtension();
1675
1676 enum StatusBarPriority { BarDefaultText, BarHoverText, BarOverrideText };
1677 void setStatusBarText( const QString& text, StatusBarPriority p);
1678
1679 bool restoreURL( const KUrl &url );
1680 void clearCaretRectIfNeeded();
1681 void setFocusNodeIfNeeded(const DOM::Selection &);
1682 void selectionLayoutChanged();
1683 void notifySelectionChanged(bool closeTyping=true);
1684 void resetFromScript();
1685 void emitSelectionChanged();
1686 void onFirstData();
1687 // Returns whether callingHtmlPart may access this part
1688 bool checkFrameAccess(KHTMLPart *callingHtmlPart);
1689 bool openUrlInFrame(const KUrl &url, const KParts::OpenUrlArguments& arguments, const KParts::BrowserArguments &browserArguments);
1690 void startAutoScroll();
1691 void stopAutoScroll();
1692 void overURL( const QString &url, const QString &target, bool shiftPressed = false );
1693 void resetHoverText(); // Undo overURL and reset HoverText
1694
1695 KParts::ScriptableExtension *scriptableExtension( const DOM::NodeImpl *);
1696
1697 KWallet::Wallet* wallet();
1698
1699 void openWallet(DOM::HTMLFormElementImpl*);
1700 void saveToWallet(const QString& key, const QMap<QString,QString>& data);
1701 void dequeueWallet(DOM::HTMLFormElementImpl*);
1702 void saveLoginInformation(const QString& host, const QString& key, const QMap<QString, QString>& walletMap);
1703
1704 void enableFindAheadActions(bool);
1705
1706 /**
1707 * Returns a pointer to the top view bar.
1708 */
1709 KHTMLViewBar *pTopViewBar() const;
1710
1711 /**
1712 * Returns a pointer to the bottom view bar.
1713 */
1714 KHTMLViewBar *pBottomViewBar() const;
1715
1716 /**
1717 * @internal
1718 */
1719 bool pFindTextNextInThisFrame( bool reverse );
1720
1721 /**
1722 * @internal
1723 */
1724 // ### KDE4 FIXME:
1725 // It is desirable to be able to filter form submissions as well.
1726 // For instance, forms can have a target and an inheriting class
1727 // might want to filter based on the target. Make this protected
1728 // and virtual, or provide a better solution.
1729 // See the web_module for the sidebar for an example where this is
1730 // necessary.
1731 void submitForm( const char *action, const QString &url, const QByteArray &formData,
1732 const QString &target, const QString& contentType = QString(),
1733 const QString& boundary = QString() );
1734
1735 void popupMenu( const QString &url );
1736
1737 void init( KHTMLView *view, GUIProfile prof );
1738
1739
1740 void clear();
1741
1742 QVariant crossFrameExecuteScript(const QString& target, const QString& script);
1743
1744 /**
1745 * @internal returns a name for a frame without a name.
1746 * This function returns a sequence of names.
1747 * All names in a sequence are different but the sequence is
1748 * always the same.
1749 * The sequence is reset in clear().
1750 */
1751 QString requestFrameName();
1752
1753 // Requests loading of a frame or iframe element
1754 void loadFrameElement( DOM::HTMLPartContainerElementImpl *frame, const QString &url, const QString &frameName,
1755 const QStringList &args = QStringList(), bool isIFrame = false );
1756
1757 // Requests loading of an object or embed element. Returns true if
1758 // loading succeeded.
1759 bool loadObjectElement( DOM::HTMLPartContainerElementImpl *frame, const QString &url, const QString &serviceType,
1760 const QStringList &args = QStringList() );
1761
1762 // Tries an open a URL in given ChildFrame with all known navigation information
1763 // like mimetype and the like in the KParts arguments.
1764 //
1765 // Returns true if it's done -- which excludes the case when it's still resolving
1766 // the mimetype.
1767 // ### refine comment wrt to error case
1768 bool requestObject( khtml::ChildFrame *child, const KUrl &url,
1769 const KParts::OpenUrlArguments &args = KParts::OpenUrlArguments(),
1770 const KParts::BrowserArguments& browserArgs = KParts::BrowserArguments() );
1771
1772 // This method does the loading inside a ChildFrame once we know what mimetype to
1773 // load it as
1774 bool processObjectRequest( khtml::ChildFrame *child, const KUrl &url, const QString &mimetype );
1775
1776 // helper for reporting ChildFrame load failure
1777 void childLoadFailure( khtml::ChildFrame *child );
1778
1779 // Updates the ChildFrame to use the particular part, hooking up the various
1780 // signals, connections, etc.
1781 void connectToChildPart( khtml::ChildFrame *child, KParts::ReadOnlyPart *part,
1782 const QString &mimetype );
1783
1784 // Low-level navigation of the part itself --- this doesn't ask the user
1785 // to save things or such, and assumes that all the ChildFrame info is already
1786 // filed in with things like the mimetype and so on
1787 //
1788 // Returns if successful or not
1789 bool navigateChild( khtml::ChildFrame *child, const KUrl& url );
1790
1791 // Helper for executing javascript: or about: protocols
1792 bool navigateLocalProtocol( khtml::ChildFrame *child, KParts::ReadOnlyPart *part,
1793 const KUrl& url );
1794
1795
1796 DOM::EventListener *createHTMLEventListener( QString code, QString name, DOM::NodeImpl *node, bool svg = false );
1797
1798 DOM::HTMLDocumentImpl *docImpl() const;
1799 DOM::DocumentImpl *xmlDocImpl() const;
1800 khtml::ChildFrame *frame( const QObject *obj );
1801
1802 khtml::ChildFrame *recursiveFrameRequest( KHTMLPart *callingHtmlPart, const KUrl &url,
1803 const KParts::OpenUrlArguments& args, const KParts::BrowserArguments &browserArgs,
1804 bool callParent = true );
1805
1806 bool checkLinkSecurity( const KUrl &linkURL,const KLocalizedString &message = KLocalizedString(), const QString &button = QString() );
1807 QVariant executeScript( const QString& filename, int baseLine, const DOM::Node &n, const QString& script );
1808
1809 KJSProxy *jScript();
1810
1811 KHTMLPart *opener();
1812 long cacheId() const;
1813 void setOpener( KHTMLPart *_opener );
1814 bool openedByJS();
1815 void setOpenedByJS( bool _openedByJS );
1816
1817 void checkEmitLoadEvent();
1818 void emitLoadEvent();
1819
1820 bool initFindNode( bool selection, bool reverse, bool fromCursor );
1821
1822 /** extends the current selection to the given content-coordinates @p x, @p y
1823 * @param x content x-coordinate
1824 * @param y content y-coordinate
1825 * @param absX absolute x-coordinate of @p innerNode
1826 * @param absY absolute y-coordinate of @p innerNode
1827 * @param innerNode node from which to start extending the selection. The
1828 * caller has to ensure that the node has a renderer.
1829 * @internal
1830 */
1831 void extendSelectionTo(int x, int y, const DOM::Node &innerNode);
1832 /** checks whether a selection is extended.
1833 * @return @p true if a selection is extended by the mouse.
1834 */
1835 bool isExtendingSelection() const;
1836 KEncodingDetector *createDecoder();
1837 QString defaultEncoding() const;
1838
1839 /** .html, .xhtml or .xml */
1840 QString defaultExtension() const;
1841
1842 /** @internal
1843 * generic zoom in
1844 */
1845 void zoomIn(const int stepping[], int count);
1846 /** @internal
1847 * generic zoom out
1848 */
1849 void zoomOut(const int stepping[], int count);
1850
1851 void incFontSize(const int stepping[], int count);
1852
1853 void decFontSize(const int stepping[], int count);
1854
1855 void emitCaretPositionChanged(const DOM::Position &pos);
1856
1857 void setDebugScript( bool enable );
1858
1859 void runAdFilter();
1860
1861 khtml::EditorContext *editorContext() const;
1862
1863 /**
1864 * initialises the caret if it hasn't been used yet.
1865 * @internal
1866 */
1867 void initCaret();
1868
1869 /**
1870 * Returns the selected part of the HTML.
1871 */
1872 const DOM::Selection &caret() const;
1873
1874 /**
1875 * Returns the drag caret of the HTML.
1876 */
1877 const DOM::Selection &dragCaret() const;
1878
1879 /**
1880 * Sets the current caret to the given selection.
1881 */
1882 void setCaret(const DOM::Selection &, bool closeTyping=true);
1883
1884 /**
1885 * Sets the current drag caret.
1886 */
1887 void setDragCaret(const DOM::Selection &);
1888
1889 /**
1890 * Clears the current selection.
1891 */
1892 void clearSelection();
1893
1894 /**
1895 * Invalidates the current selection.
1896 */
1897 void invalidateSelection();
1898
1899 /**
1900 * Controls the visibility of the selection.
1901 */
1902 void setSelectionVisible(bool flag=true);
1903
1904 /**
1905 * Paints the caret.
1906 */
1907 void paintCaret(QPainter *p, const QRect &rect) const;
1908
1909 /**
1910 * Paints the drag caret.
1911 */
1912 void paintDragCaret(QPainter *p, const QRect &rect) const;
1913
1914 /**
1915 * Returns selectedText without any leading or trailing whitespace,
1916 * and with non-breaking-spaces turned into normal spaces.
1917 *
1918 * Note that hasSelection can return true and yet simplifiedSelectedText can be empty,
1919 * e.g. when selecting a single space.
1920 */
1921 QString simplifiedSelectedText() const;
1922
1923 bool handleMouseMoveEventDrag(khtml::MouseMoveEvent *event);
1924 bool handleMouseMoveEventOver(khtml::MouseMoveEvent *event);
1925 void handleMouseMoveEventSelection(khtml::MouseMoveEvent *event);
1926
1927 void handleMousePressEventSingleClick(khtml::MousePressEvent *event);
1928 void handleMousePressEventDoubleClick(khtml::MouseDoubleClickEvent *event);
1929 void handleMousePressEventTripleClick(khtml::MouseDoubleClickEvent *event);
1930
1931 KHTMLPartPrivate *d;
1932 friend class KHTMLPartPrivate;
1933
1934public: // So we don't end up having to add 50 more friends
1935
1936 /** @internal Access to internal APIs. Don't use outside */
1937 KHTMLPartPrivate* impl() { return d; }
1938};
1939
1940
1941#endif
1942