File indexing completed on 2024-04-21 14:58:55

0001 /* This file is part of the KDE project
0002  *
0003  * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
0004  *                     1999-2001 Lars Knoll <knoll@kde.org>
0005  *                     1999-2001 Antti Koivisto <koivisto@kde.org>
0006  *                     2000-2001 Simon Hausmann <hausmann@kde.org>
0007  *                     2000-2001 Dirk Mueller <mueller@kde.org>
0008  *                     2000 Stefan Schimanski <1Stein@gmx.de>
0009  *
0010  * This library is free software; you can redistribute it and/or
0011  * modify it under the terms of the GNU Library General Public
0012  * License as published by the Free Software Foundation; either
0013  * version 2 of the License, or (at your option) any later version.
0014  *
0015  * This library is distributed in the hope that it will be useful,
0016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0018  * Library General Public License for more details.
0019  *
0020  * You should have received a copy of the GNU Library General Public License
0021  * along with this library; see the file COPYING.LIB.  If not, write to
0022  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0023  * Boston, MA 02110-1301, USA.
0024  */
0025 #ifndef __khtml_part_h__
0026 #define __khtml_part_h__
0027 
0028 #include "dom/dom_doc.h"
0029 #include "dom/dom2_range.h"
0030 
0031 #include <kparts/readonlypart.h>
0032 #include <kparts/browserextension.h>
0033 #include <kparts/browserhostextension.h>
0034 #include <kfind.h>
0035 #include <kfinddialog.h>
0036 #include <klocalizedstring.h>
0037 #include <kencodingdetector.h>
0038 #include <kencodingprober.h>
0039 #include <QRegExp>
0040 #include <QUrl>
0041 
0042 class KHTMLPartPrivate;
0043 class KHTMLPartBrowserExtension;
0044 class KJSProxy;
0045 class KHTMLView;
0046 class KHTMLViewBar;
0047 class KHTMLFindBar;
0048 class KHTMLSettings;
0049 class KJavaAppletContext;
0050 class KJSErrorDlg;
0051 
0052 namespace DOM
0053 {
0054 class HTMLDocument;
0055 class HTMLDocumentImpl;
0056 class DocumentImpl;
0057 class Document;
0058 class XMLDocumentImpl;
0059 class HTMLTitleElementImpl;
0060 class HTMLFrameElementImpl;
0061 class HTMLIFrameElementImpl;
0062 class HTMLObjectElementImpl;
0063 class HTMLFormElementImpl;
0064 class HTMLAnchorElementImpl;
0065 class HTMLMetaElementImpl;
0066 class NodeImpl;
0067 class ElementImpl;
0068 class Node;
0069 class HTMLEventListener;
0070 class EventListener;
0071 class HTMLPartContainerElementImpl;
0072 class HTMLObjectBaseElementImpl;
0073 class Position;
0074 class Selection;
0075 class Range;
0076 class Editor;
0077 }
0078 
0079 namespace WebCore
0080 {
0081 class SVGDocumentExtensions;
0082 }
0083 
0084 namespace KJS
0085 {
0086 class Interpreter;
0087 class HTMLElement;
0088 }
0089 
0090 namespace khtml
0091 {
0092 class DocLoader;
0093 class RenderPart;
0094 class ChildFrame;
0095 class MousePressEvent;
0096 class MouseDoubleClickEvent;
0097 class MouseMoveEvent;
0098 class MouseReleaseEvent;
0099 class DrawContentsEvent;
0100 class CachedObject;
0101 class RenderWidget;
0102 class RenderBlock;
0103 class CSSStyleSelector;
0104 class HTMLTokenizer;
0105 class XMLTokenizer;
0106 struct EditorContext;
0107 class EditCommandImpl;
0108 class KHTMLPartAccessor;
0109 }
0110 
0111 namespace KJS
0112 {
0113 class Window;
0114 class WindowFunc;
0115 class ExternalFunc;
0116 class JSEventListener;
0117 class JSLazyEventListener;
0118 class JSNodeFilter;
0119 class DOMDocument;
0120 class SourceFile;
0121 class ScheduledAction;
0122 class DOMSelection;
0123 class DOMSelectionProtoFunc;
0124 class KHTMLPartScriptable;
0125 }
0126 
0127 namespace KParts
0128 {
0129 class PartManager;
0130 class ScriptableExtension;
0131 }
0132 
0133 namespace KWallet
0134 {
0135 class Wallet;
0136 }
0137 
0138 /**
0139  * This class is khtml's main class. It features an almost complete
0140  * web browser, and html renderer.
0141  *
0142  * The easiest way to use this class (if you just want to display an HTML
0143  * page at some URL) is the following:
0144  *
0145  * \code
0146  * QUrl url = "https://www.kde.org";
0147  * KHTMLPart *w = new KHTMLPart();
0148  * w->openUrl(url);
0149  * w->view()->resize(500, 400);
0150  * w->show();
0151  * \endcode
0152  *
0153  * Java and JavaScript are enabled by default depending on the user's
0154  * settings. If you do not need them, and especially if you display
0155  * unfiltered data from untrusted sources, it is strongly recommended to
0156  * turn them off. In that case, you should also turn off the automatic
0157  * redirect and plugins:
0158  *
0159  * \code
0160  * w->setJScriptEnabled(false);
0161  * w->setJavaEnabled(false);
0162  * w->setMetaRefreshEnabled(false);
0163  * w->setPluginsEnabled(false);
0164  * \endcode
0165  *
0166  * You may also wish to disable external references.  This will prevent KHTML
0167  * from loading images, frames, etc,  or redirecting to external sites.
0168  *
0169  * \code
0170  * w->setOnlyLocalReferences(true);
0171  * \endcode
0172  *
0173  * Some apps want to write their HTML code directly into the widget instead of
0174  * opening an url. You can do this in the following way:
0175  *
0176  * \code
0177  * QString myHTMLCode = ...;
0178  * KHTMLPart *w = new KHTMLPart();
0179  * w->begin();
0180  * w->write(myHTMLCode);
0181  * ...
0182  * w->end();
0183  * \endcode
0184  *
0185  * You can do as many calls to write() as you wish.  There are two
0186  * write() methods, one accepting a QString and one accepting a
0187  * @p char @p * argument. You should use one or the other
0188  * (but not both) since the method using
0189  * the @p char @p * argument does an additional decoding step to convert the
0190  * written data to Unicode.
0191  *
0192  * It is also possible to write content to the HTML part using the
0193  * standard streaming API from KParts::ReadOnlyPart. The usage of
0194  * the API is similar to that of the begin(), write(), end() process
0195  * described above as the following example shows:
0196  *
0197  * \code
0198  * KHTMLPart *doc = new KHTMLPart();
0199  * doc->openStream( "text/html", QUrl() );
0200  * doc->writeStream( QCString( "<html><body><p>KHTML Rocks!</p></body></html>" ) );
0201  * doc->closeStream();
0202  * \endcode
0203  *
0204  * @short HTML Browser Widget
0205  * @author Lars Knoll (knoll@kde.org)
0206  *
0207  */
0208 class KHTML_EXPORT KHTMLPart : public KParts::ReadOnlyPart
0209 {
0210     Q_OBJECT
0211     friend class KHTMLView;
0212     friend class DOM::HTMLTitleElementImpl;
0213     friend class DOM::HTMLFrameElementImpl;
0214     friend class DOM::HTMLIFrameElementImpl;
0215     friend class DOM::HTMLObjectBaseElementImpl;
0216     friend class DOM::HTMLObjectElementImpl;
0217     friend class DOM::HTMLAnchorElementImpl;
0218     friend class DOM::HTMLMetaElementImpl;
0219     friend class DOM::NodeImpl;
0220     friend class DOM::ElementImpl;
0221     friend class KHTMLRun;
0222     friend class DOM::HTMLFormElementImpl;
0223     friend class KJS::Window;
0224     friend class KJS::ScheduledAction;
0225     friend class KJS::JSNodeFilter;
0226     friend class KJS::WindowFunc;
0227     friend class KJS::ExternalFunc;
0228     friend class KJS::JSEventListener;
0229     friend class KJS::JSLazyEventListener;
0230     friend class KJS::DOMDocument;
0231     friend class KJS::HTMLElement;
0232     friend class KJS::SourceFile;
0233     friend class KJS::DOMSelection;
0234     friend class KJS::DOMSelectionProtoFunc;
0235     friend class KJS::KHTMLPartScriptable;
0236     friend class KJSProxy;
0237     friend class KHTMLPartBrowserExtension;
0238     friend class DOM::DocumentImpl;
0239     friend class DOM::HTMLDocumentImpl;
0240     friend class DOM::Selection;
0241     friend class DOM::Editor;
0242     friend class KHTMLPartBrowserHostExtension;
0243     friend class khtml::HTMLTokenizer;
0244     friend class khtml::XMLTokenizer;
0245     friend class khtml::RenderWidget;
0246     friend class khtml::RenderBlock;
0247     friend class khtml::CSSStyleSelector;
0248     friend class khtml::EditCommandImpl;
0249     friend class khtml::KHTMLPartAccessor;
0250     friend class KHTMLPartIface;
0251     friend class KHTMLPartFunction;
0252     friend class KHTMLPopupGUIClient;
0253     friend class KHTMLFind;
0254     friend class StorePass;
0255     friend class WebCore::SVGDocumentExtensions;
0256 
0257     Q_PROPERTY(bool javaScriptEnabled READ jScriptEnabled WRITE setJScriptEnabled)
0258     Q_PROPERTY(bool javaEnabled READ javaEnabled WRITE setJavaEnabled)
0259     Q_PROPERTY(bool dndEnabled READ dndEnabled WRITE setDNDEnabled)
0260     Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled)
0261     Q_PROPERTY(DNSPrefetch dnsPrefetch READ dnsPrefetch WRITE setDNSPrefetch)
0262 
0263     /*
0264      *
0265      * Don't add setOnlyLocalReferences here. It shouldn't be accessible via DBus.
0266      *
0267      **/
0268     Q_PROPERTY(bool modified READ isModified)
0269     Q_PROPERTY(QString encoding READ encoding WRITE setEncoding)
0270     Q_PROPERTY(QString lastModified READ lastModified)
0271     Q_PROPERTY(bool metaRefreshEnabled READ metaRefreshEnabled WRITE setMetaRefreshEnabled)
0272 
0273 public:
0274     enum GUIProfile { DefaultGUI, BrowserViewGUI /* ... */ };
0275 
0276     /**
0277     * DNS Prefetching Mode enumeration
0278     * @li DNSPrefetchDisabled do not prefetch hostnames
0279     * @li DNSPrefetchEnabled always prefetch hostnames
0280     * @li DNSPrefetchOnlyWWWAndSLD only do DNS prefetching for bare SLD and www sub-domain
0281     */
0282 
0283     enum DNSPrefetch {
0284         DNSPrefetchDisabled = 0,
0285         DNSPrefetchEnabled,
0286         DNSPrefetchOnlyWWWAndSLD
0287     };
0288 
0289     /**
0290      * Constructs a new KHTMLPart.
0291      *
0292      * KHTML basically consists of two objects: The KHTMLPart itself,
0293      * holding the document data (DOM document), and the KHTMLView,
0294      * derived from QScrollArea, in which the document content is
0295      * rendered in. You can specify two different parent objects for a
0296      * KHTMLPart, one parent for the KHTMLPart document and one parent
0297      * for the KHTMLView. If the second @p parent argument is 0L, then
0298      * @p parentWidget is used as parent for both objects, the part and
0299      * the view.
0300      */
0301     KHTMLPart(QWidget *parentWidget = nullptr,
0302               QObject *parent = nullptr, GUIProfile prof = DefaultGUI);
0303     /**
0304      * Constructs a new KHTMLPart.
0305      *
0306      * This constructor is useful if you wish to subclass KHTMLView.
0307      * If the @p view passed  as first argument to the constructor was built with a
0308      * null KHTMLPart pointer, then the newly created KHTMLPart will be assigned as the view's part.
0309      *
0310      * Therefore, you might either initialize the view as part of the initialization list of
0311      * your derived KHTMLPart class constructor:
0312      * \code
0313      *   MyKHTMLPart() : KHTMLPart( new MyKHTMLView( this ), ...
0314      * \endcode
0315      * Or separately build the KHTMLView beforehand:
0316      * \code
0317      *   KHTMLView * v = KHTMLView( 0L, parentWidget());
0318      *   KHTMLPart * p = KHTMLPart( v ); // p will be assigned to v, so that v->part() == p
0319      * \endcode
0320      */
0321     KHTMLPart(KHTMLView *view, QObject *parent = nullptr, GUIProfile prof = DefaultGUI);
0322 
0323     /**
0324      * Destructor.
0325      */
0326     virtual ~KHTMLPart();
0327 
0328     /**
0329      * Opens the specified URL @p url.
0330      *
0331      * Reimplemented from KParts::ReadOnlyPart::openUrl .
0332      */
0333     bool openUrl(const QUrl &url) override;
0334 
0335     /**
0336      * Stops loading the document and kills all data requests (for images, etc.)
0337      */
0338     bool closeUrl() override;
0339 
0340     /**
0341      * Called when a certain error situation (i.e. connection timed out) occurred.
0342      * The default implementation either shows a KIO error dialog or loads a more
0343      * verbose error description a as page, depending on the users configuration.
0344      * @p job is the job that signaled the error situation
0345      */
0346     virtual void showError(KJob *job);
0347 
0348     /**
0349      * Returns a reference to the DOM HTML document (for non-HTML documents, returns null)
0350      */
0351     DOM::HTMLDocument htmlDocument() const;
0352 
0353     /**
0354      * Returns a reference to the DOM document.
0355      */
0356     DOM::Document document() const;
0357 
0358     /**
0359      * Returns the content of the source document.
0360      */
0361     QString documentSource() const;
0362 
0363     /**
0364      * Returns the node that has the keyboard focus.
0365      */
0366     DOM::Node activeNode() const;
0367 
0368     /**
0369      * Returns a pointer to the KParts::BrowserExtension.
0370      */
0371     KParts::BrowserExtension *browserExtension() const;
0372     KParts::BrowserHostExtension *browserHostExtension() const;
0373 
0374     /**
0375      * Returns a pointer to the HTML document's view.
0376      */
0377     KHTMLView *view() const;
0378 
0379     /**
0380      * Enable/disable Javascript support. Note that this will
0381      * in either case permanently override the default usersetting.
0382      * If you want to have the default UserSettings, don't call this
0383      * method.
0384      */
0385     void setJScriptEnabled(bool enable);
0386 
0387     /**
0388      * Returns @p true if Javascript support is enabled or @p false
0389      * otherwise.
0390      */
0391     bool jScriptEnabled() const;
0392 
0393     /**
0394      * Returns the JavaScript interpreter the part is using. This method is
0395      * mainly intended for applications which embed and extend the part and
0396      * provides a mechanism for adding additional native objects to the
0397      * interpreter (or removing the built-ins).
0398      *
0399      * One thing people using this method to add things to the interpreter must
0400      * consider, is that when you start writing new content to the part, the
0401      * interpreter is cleared. This includes both use of the
0402      * begin( const QUrl &, int, int ) method, and the openUrl( const QUrl & )
0403      * method. If you want your objects to have a longer lifespan, then you must
0404      * retain a KJS::Object yourself to ensure that the reference count of your
0405      * custom objects never reaches 0. You will also need to re-add your
0406      * bindings every time this happens - one way to detect the need for this is
0407      * to connect to the docCreated() signal, another is to reimplement the
0408      * begin() method.
0409      */
0410     KJS::Interpreter *jScriptInterpreter();
0411 
0412     /**
0413      * Enable/disable statusbar messages.
0414      * When this class wants to set the statusbar text, it emits
0415      * setStatusBarText(const QString & text)
0416      * If you want to catch this for your own statusbar, note that it returns
0417      * back a rich text string, starting with "<qt>".  This you need to
0418      * either pass this into your own QLabel or to strip out the tags
0419      * before passing it to QStatusBar::message(const QString & message)
0420      *
0421      * @see KParts::Part::setStatusBarText( const QString & text )
0422      */
0423     void setStatusMessagesEnabled(bool enable);
0424 
0425     /**
0426      * Returns @p true if status messages are enabled.
0427      */
0428     bool statusMessagesEnabled() const;
0429 
0430     /**
0431      * Enable/disable automatic forwarding by &lt;meta http-equiv="refresh" ....&gt;
0432      */
0433     void setMetaRefreshEnabled(bool enable);
0434 
0435     /**
0436      * Returns @p true if automatic forwarding is enabled.
0437      */
0438     bool metaRefreshEnabled() const;
0439 
0440     /**
0441      * Same as executeScript( const QString & ) except with the Node parameter
0442      * specifying the 'this' value.
0443      */
0444     QVariant executeScript(const DOM::Node &n, const QString &script);
0445 
0446     /**
0447      * Enables or disables Drag'n'Drop support. A drag operation is started if
0448      * the users drags a link.
0449      */
0450     void setDNDEnabled(bool b);
0451 
0452     /**
0453      * Returns whether Dragn'n'Drop support is enabled or not.
0454      */
0455     bool dndEnabled() const;
0456 
0457     /**
0458      * Enables/disables Java applet support. Note that calling this function
0459      * will permanently override the User settings about Java applet support.
0460      * Not calling this function is the only way to let the default settings
0461      * apply.
0462      */
0463     void setJavaEnabled(bool enable);
0464 
0465     /**
0466      * Return @p true if Java applet support is enabled, @p false if disabled
0467      */
0468     bool javaEnabled() const;
0469 
0470     /**
0471      * Enables or disables plugins, default is enabled
0472      */
0473     void setPluginsEnabled(bool enable);
0474 
0475     /**
0476      * Returns @p true if plugins are enabled, @p false if disabled.
0477      */
0478     bool pluginsEnabled() const;
0479 
0480     /**
0481      * Specifies whether images contained in the document should be loaded
0482      * automatically or not.
0483      *
0484      * @note Request will be ignored if called before begin().
0485      */
0486     void setAutoloadImages(bool enable);
0487     /**
0488      * Returns whether images contained in the document are loaded automatically
0489      * or not.
0490      * @note that the returned information is unrelieable as long as no begin()
0491      * was called.
0492      */
0493     bool autoloadImages() const;
0494 
0495     /**
0496      * Security option.
0497      *
0498      * Specify whether only file:/ or data:/ urls are allowed to be loaded without
0499      * user confirmation by KHTML.
0500      * ( for example referenced by stylesheets, images, scripts, subdocuments, embedded elements ).
0501      *
0502      * This option is mainly intended for enabling the "mail reader mode", where you load untrusted
0503      * content with a file:/ url.
0504      *
0505      * Please note that enabling this option currently automatically disables Javascript,
0506      * Java and Plugins support. This might change in the future if the security model
0507      * is becoming more sophisticated, so don't rely on this behaviour.
0508      *
0509      * ( default @p false - everything is loaded unless forbidden by KApplication::authorizeURLAction).
0510      */
0511     void setOnlyLocalReferences(bool enable);
0512 
0513     /**
0514      * Security option. If this is set to true, content loaded from external URLs
0515      * will be permitted to access images on disk regardless of of the Kiosk policy.
0516      * You should be careful in enabling this, as it may make it easier to fake
0517      * any HTML-based chrome or to perform other such user-confusion attack.
0518      * @p false by default.
0519      *
0520      * @since 4.6
0521      */
0522     void setForcePermitLocalImages(bool enable);
0523 
0524     /**
0525      * Sets whether DNS Names found in loaded documents'anchors should be pre-fetched (pre-resolved).
0526      * Note that calling this function will permanently override the User settings about
0527      * DNS prefetch support.
0528      * Not calling this function is the only way to let the default settings apply.
0529      *
0530      * @note This setting has no effect if @ref setOnlyLocalReferences() mode is enabled.
0531      *
0532      * @param pmode the mode to set. See @ref DNSPrefetch enum for explanation of values.
0533      *
0534      * @since 4.2
0535      */
0536     void setDNSPrefetch(DNSPrefetch pmode);
0537 
0538     /**
0539      * Returns currently set DNS prefetching mode.
0540      * See @p DNSPrefetch enum for explanation of values.
0541      *
0542      * @note Always returns  @p DNSPrefetchDisabled if @ref setOnlyLocalReferences() mode is enabled.
0543      *
0544      * @since 4.2
0545      */
0546     DNSPrefetch dnsPrefetch() const;
0547 
0548     /**
0549      * Returns whether only file:/ or data:/ references are allowed
0550      * to be loaded ( default @p false ).  See setOnlyLocalReferences.
0551      **/
0552     bool onlyLocalReferences() const;
0553 
0554     /**
0555      * If true, local image files will be loaded even when forbidden by the
0556      * Kiosk/KAuthorized policies ( default @p false ). See @ref setForcePermitLocalImages.
0557      *
0558      * @since 4.6
0559      **/
0560     bool forcePermitLocalImages() const;
0561 
0562     /** Returns whether caret mode is on/off.
0563      */
0564     bool isCaretMode() const;
0565 
0566     /**
0567      * Returns @p true if the document is editable, @p false otherwise.
0568      */
0569     bool isEditable() const;
0570 
0571     /**
0572      * Sets the caret to the given position.
0573      *
0574      * If the given location is invalid, it will snap to the nearest valid
0575      * location. Immediately afterwards a @p caretPositionChanged signal
0576      * containing the effective position is emitted
0577      * @param node node to set to
0578      * @param offset zero-based offset within the node
0579      * @param extendSelection If @p true, a selection will be spanned from the
0580      *    last caret position to the given one. Otherwise, any existing selection
0581      *    will be deselected.
0582      */
0583     void setCaretPosition(DOM::Node node, long offset, bool extendSelection = false);
0584 
0585     /**
0586      * Enumeration for displaying the caret.
0587      */
0588     enum CaretDisplayPolicy {
0589         CaretVisible, /**< caret is displayed */
0590         CaretInvisible, /**<  caret is not displayed */
0591         CaretBlink /**< caret toggles between visible and invisible */
0592     };
0593 
0594     /**
0595      * Returns the current caret policy when the view is not focused.
0596      */
0597     CaretDisplayPolicy caretDisplayPolicyNonFocused() const;
0598 
0599     /**
0600      * Sets the caret display policy when the view is not focused.
0601      *
0602      * Whenever the caret is in use, this property determines how the
0603      * caret should be displayed when the document view is not focused.
0604      *
0605      * The default policy is CaretInvisible.
0606      * @param policy new display policy
0607      */
0608     void setCaretDisplayPolicyNonFocused(CaretDisplayPolicy policy);
0609 
0610 #ifndef KDE_NO_COMPAT
0611     QUrl baseURL() const;
0612 #endif
0613 
0614     /**
0615      * Returns the URL for the background Image (used by save background)
0616      */
0617     QUrl backgroundURL() const;
0618 
0619     /**
0620      * Schedules a redirection after @p delay seconds.
0621      */
0622     void scheduleRedirection(int delay, const QString &url, bool lockHistory = true);
0623 
0624     /**
0625      * Clears the widget and prepares it for new content.
0626      *
0627      * If you want url() to return
0628      * for example "file:/tmp/test.html", you can use the following code:
0629      * \code
0630      * view->begin( QUrl("file:/tmp/test.html" ) );
0631      * \endcode
0632      *
0633      * @param url is the url of the document to be displayed.  Even if you
0634      * are generating the HTML on the fly, it may be useful to specify
0635      * a directory so that any pixmaps are found.
0636      *
0637      * @param xOffset is the initial horizontal scrollbar value. Usually
0638      * you don't want to use this.
0639      *
0640      * @param yOffset is the initial vertical scrollbar value. Usually
0641      * you don't want to use this.
0642      *
0643      * All child frames and the old document are removed if you call
0644      * this method.
0645      */
0646     virtual void begin(const QUrl &url = QUrl(), int xOffset = 0, int yOffset = 0);
0647 
0648     /**
0649      * Writes another part of the HTML code to the widget.
0650      *
0651      * You may call
0652      * this function many times in sequence. But remember: The fewer calls
0653      * you make, the faster the widget will be.
0654      *
0655      * The HTML code is send through a decoder which decodes the stream to
0656      * Unicode.
0657      *
0658      * The @p len parameter is needed for streams encoded in utf-16,
0659      * since these can have \\0 chars in them. In case the encoding
0660      * you're using isn't utf-16, you can safely leave out the length
0661      * parameter.
0662      *
0663      * Attention: Don't mix calls to write( const char *) with calls
0664      * to write( const QString & ).
0665      *
0666      * The result might not be what you want.
0667      */
0668     virtual void write(const char *str, int len = -1);
0669 
0670     /**
0671      * Writes another part of the HTML code to the widget.
0672      *
0673      * You may call
0674      * this function many times in sequence. But remember: The fewer calls
0675      * you make, the faster the widget will be.
0676      *
0677      * For historic and backward compatibility reasons, this method will force
0678      * the use of strict mode for the document, unless setAlwaysHonourDoctype()
0679      * has been called previously.
0680      */
0681     // FIXME KDE5: always honour doctype, remove setAlwaysHonourDoctype()
0682     virtual void write(const QString &str);
0683 
0684     /**
0685      * Call this after your last call to write().
0686      */
0687     virtual void end();
0688 
0689     /*
0690      * Prints the current HTML page laid out for the printer.
0691      *
0692      * (not implemented at the moment)
0693      */
0694     //    void print(QPainter *, int pageHeight, int pageWidth);
0695 
0696     /**
0697      * Paints the HTML page to a QPainter. See KHTMLView::paint for details
0698      */
0699     void paint(QPainter *, const QRect &, int = 0, bool * = nullptr);
0700 
0701     /**
0702      * Sets the encoding the page uses.
0703      *
0704      * This can be different from the charset. The widget will try to reload the current page in the new
0705      * encoding, if url() is not empty.
0706      */
0707     bool setEncoding(const QString &name, bool override = false);
0708 
0709     /**
0710      * Returns the encoding the page currently uses.
0711      *
0712      * Note that the encoding might be different from the charset.
0713      */
0714     QString encoding() const;
0715 
0716     /**
0717      * Sets a user defined style sheet to be used on top of the HTML 4
0718      * default style sheet.
0719      *
0720      * This gives a wide range of possibilities to
0721      * change the layout of the page.
0722      *
0723      * To have an effect this function has to be called after calling begin().
0724      */
0725     void setUserStyleSheet(const QUrl &url);
0726 
0727     /**
0728      * Sets a user defined style sheet to be used on top of the HTML 4
0729      * default style sheet.
0730      *
0731      * This gives a wide range of possibilities to
0732      * change the layout of the page.
0733      *
0734      * To have an effect this function has to be called after calling begin().
0735      */
0736     void setUserStyleSheet(const QString &styleSheet);
0737 
0738 public:
0739 
0740     /**
0741      * Sets the standard font style.
0742      *
0743      * @param name The font name to use for standard text.
0744      */
0745     void setStandardFont(const QString &name);
0746 
0747     /**
0748      * Sets the fixed font style.
0749      *
0750      * @param name The font name to use for fixed text, e.g.
0751      * the <tt>&lt;pre&gt;</tt> tag.
0752      */
0753     void setFixedFont(const QString &name);
0754 
0755     /**
0756      * Finds the anchor named @p name.
0757      *
0758      * If the anchor is found, the widget
0759      * scrolls to the closest position. Returns @p if the anchor has
0760      * been found.
0761      */
0762     bool gotoAnchor(const QString &name);
0763 
0764     /**
0765      * Go to the next anchor
0766      *
0767      * This is useful to navigate from outside the navigator
0768      */
0769     bool nextAnchor();
0770 
0771     /**
0772      * Go to previous anchor
0773      */
0774     bool prevAnchor();
0775 
0776     /**
0777      * Sets the cursor to use when the cursor is on a link.
0778      */
0779     void setURLCursor(const QCursor &c);
0780 
0781     /**
0782      * Returns the cursor which is used when the cursor is on a link.
0783      */
0784     QCursor urlCursor() const;
0785 
0786     /**
0787      * Extra Find options that can be used when calling the extended findText().
0788      */
0789     enum FindOptions {
0790         FindLinksOnly   = 1 * KFind::MinimumUserOption,
0791         FindNoPopups    = 2 * KFind::MinimumUserOption
0792                           //FindIncremental = 4 * KFind::MinimumUserOption
0793     };
0794 
0795     /**
0796      * Starts a new search by popping up a dialog asking the user what he wants to
0797      * search for.
0798      */
0799     void findText();
0800 
0801     /**
0802      * Starts a new search, but bypasses the user dialog.
0803      * @param str The string to search for.
0804      * @param options Find options.
0805      * @param parent Parent used for centering popups like "string not found".
0806      * @param findDialog Optionally, you can supply your own dialog.
0807      */
0808     void findText(const QString &str, long options, QWidget *parent = nullptr,
0809                   KFindDialog *findDialog = nullptr);
0810 
0811     /**
0812      * Initiates a text search.
0813      */
0814     void findTextBegin();
0815 
0816     /**
0817      * Finds the next occurrence of a string set by @ref findText()
0818      * @param reverse if @p true, revert seach direction (only if no find dialog is used)
0819      * @return @p true if a new match was found.
0820      */
0821     bool findTextNext(bool reverse = false);
0822 
0823     /**
0824      * Sets the Zoom factor. The value is given in percent, larger values mean a
0825      * generally larger font and larger page contents.
0826      *
0827      * The given value should be in the range of 20..300, values outside that
0828      * range are not guaranteed to work. A value of 100 will disable all zooming
0829      * and show the page with the sizes determined via the given lengths in the
0830      * stylesheets.
0831      */
0832     void setZoomFactor(int percent);
0833 
0834     /**
0835      * Returns the current zoom factor.
0836      */
0837     int zoomFactor() const;
0838 
0839     /**
0840      * Sets the scale factor to be applied to fonts. The value is given in percent,
0841      * larger values mean generally larger fonts.
0842      *
0843      * The given value should be in the range of 20..300, values outside that
0844      * range are not guaranteed to work. A value of 100 will disable all scaling of font sizes
0845      * and show the page with the sizes determined via the given lengths in the
0846      * stylesheets.
0847      */
0848     void setFontScaleFactor(int percent);
0849 
0850     /**
0851      * Returns the current font scale factor.
0852      */
0853     int fontScaleFactor() const;
0854 
0855     /**
0856      * Returns the text the user has marked.
0857      */
0858     virtual QString selectedText() const;
0859 
0860     /**
0861      * Return the text the user has marked.  This is guaranteed to be valid xml,
0862      * and to contain the \<html> and \<body> tags.
0863      *
0864      * FIXME probably should make virtual for 4.0 ?
0865      */
0866     QString selectedTextAsHTML() const;
0867 
0868     /**
0869      * Returns the selected part of the HTML.
0870      */
0871     DOM::Range selection() const;
0872 
0873     /**
0874      * Returns the selected part of the HTML by returning the starting and end
0875      * position.
0876      *
0877      * If there is no selection, both nodes and offsets are equal.
0878      * @param startNode returns node selection starts in
0879      * @param startOffset returns offset within starting node
0880      * @param endNode returns node selection ends in
0881      * @param endOffset returns offset within end node.
0882      */
0883     void selection(DOM::Node &startNode, long &startOffset,
0884                    DOM::Node &endNode, long &endOffset) const;
0885 
0886     /**
0887      * Sets the current selection.
0888      */
0889     void setSelection(const DOM::Range &);
0890 
0891     /**
0892      * Has the user selected anything?
0893      *
0894      *  Call selectedText() to
0895      * retrieve the selected text.
0896      *
0897      * @return @p true if there is text selected.
0898      */
0899     bool hasSelection() const;
0900 
0901     /**
0902      * Returns the instance of the attached html editor interface.
0903      *
0904      */
0905     DOM::Editor *editor() const;
0906 
0907     /**
0908      * Marks all text in the document as selected.
0909      */
0910     void selectAll();
0911 
0912     /**
0913      * Convenience method to show the document's view.
0914      *
0915      * Equivalent to widget()->show() or view()->show() .
0916      */
0917     void show();
0918 
0919     /**
0920      * Convenience method to hide the document's view.
0921      *
0922      * Equivalent to widget()->hide() or view()->hide().
0923      */
0924     void hide();
0925 
0926     /**
0927      * Returns a reference to the partmanager instance which
0928      * manages html frame objects.
0929      */
0930     KParts::PartManager *partManager();
0931 
0932     /**
0933      * Saves the KHTMLPart's complete state (including child frame
0934      * objects) to the provided QDataStream.
0935      *
0936      * This is called from the saveState() method of the
0937      * browserExtension().
0938      */
0939     virtual void saveState(QDataStream &stream);
0940     /**
0941      * Restores the KHTMLPart's previously saved state (including
0942      * child frame objects) from the provided QDataStream.
0943      *
0944      * @see saveState()
0945      *
0946      * This is called from the restoreState() method of the
0947      * browserExtension() .
0948      **/
0949     virtual void restoreState(QDataStream &stream);
0950 
0951     /**
0952      * Returns the @p Node currently under the mouse.
0953      *
0954      * The returned node may be a shared node (e. g. an \<area> node if the
0955      * mouse is hovering over an image map).
0956      */
0957     DOM::Node nodeUnderMouse() const;
0958 
0959     /**
0960      * Returns the @p Node currently under the mouse that is not shared.
0961      *
0962      * The returned node is always the node that is physically under the mouse
0963      * pointer (irrespective of logically overlying elements like, e. g.,
0964      * \<area> on image maps).
0965      */
0966     DOM::Node nonSharedNodeUnderMouse() const;
0967 
0968     /**
0969      * @internal
0970      */
0971     const KHTMLSettings *settings() const;
0972 
0973     /**
0974      * Returns a pointer to the parent KHTMLPart if the part is a frame
0975      * in an HTML frameset.
0976      *
0977      *  Returns 0L otherwise.
0978      */
0979     // ### KDE5 make const
0980     KHTMLPart *parentPart();
0981 
0982     /**
0983      * Returns a list of names of all frame (including iframe) objects of
0984      * the current document. Note that this method is not working recursively
0985      * for sub-frames.
0986      */
0987     QStringList frameNames() const;
0988 
0989     QList<KParts::ReadOnlyPart *> frames() const;
0990 
0991     /**
0992      * Finds a frame by name. Returns 0L if frame can't be found.
0993      */
0994     KHTMLPart *findFrame(const QString &f);
0995 
0996     /**
0997      * Recursively finds the part containing the frame with name @p f
0998      * and checks if it is accessible by @p callingPart
0999      * Returns 0L if no suitable frame can't be found.
1000      * Returns parent part if a suitable frame was found and
1001      * frame info in @p *childFrame
1002      */
1003     KHTMLPart *findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &f, khtml::ChildFrame **childFrame = nullptr);
1004 
1005     /**
1006      * Return the current frame (the one that has focus)
1007      * Not necessarily a direct child of ours, framesets can be nested.
1008      * Returns "this" if this part isn't a frameset.
1009      */
1010     KParts::ReadOnlyPart *currentFrame() const;
1011 
1012     /**
1013      * Returns whether a frame with the specified name is exists or not.
1014      * In contrast to the findFrame method this one also returns @p true
1015      * if the frame is defined but no displaying component has been
1016      * found/loaded, yet.
1017      */
1018     bool frameExists(const QString &frameName);
1019 
1020     /**
1021      * Returns child frame framePart its script interpreter
1022      */
1023     KJSProxy *framejScript(KParts::ReadOnlyPart *framePart);
1024 
1025     /**
1026      * Finds a frame by name. Returns 0L if frame can't be found.
1027      */
1028     KParts::ReadOnlyPart *findFramePart(const QString &f);
1029     /**
1030      * Called by KJS.
1031      * Sets the StatusBarText assigned
1032      * via window.status
1033      */
1034     void setJSStatusBarText(const QString &text);
1035 
1036     /**
1037      * Called by KJS.
1038      * Sets the DefaultStatusBarText assigned
1039      * via window.defaultStatus
1040      */
1041     void setJSDefaultStatusBarText(const QString &text);
1042 
1043     /**
1044      * Called by KJS.
1045      * Returns the StatusBarText assigned
1046      * via window.status
1047      */
1048     QString jsStatusBarText() const;
1049 
1050     /**
1051      * Called by KJS.
1052      * Returns the DefaultStatusBarText assigned
1053      * via window.defaultStatus
1054      */
1055     QString jsDefaultStatusBarText() const;
1056 
1057     /**
1058      * Referrer used for links in this page.
1059      */
1060     QString referrer() const;
1061 
1062     /**
1063      * Referrer used to obtain this page.
1064      */
1065     QString pageReferrer() const;
1066 
1067     /**
1068      * Last-modified date (in raw string format), if received in the [HTTP] headers.
1069      */
1070     QString lastModified() const;
1071 
1072     /**
1073      * Loads a style sheet into the stylesheet cache.
1074      */
1075     void preloadStyleSheet(const QString &url, const QString &stylesheet);
1076 
1077     /**
1078      * Loads a script into the script cache.
1079      */
1080     void preloadScript(const QString &url, const QString &script);
1081 
1082     /**
1083      * Returns whether the given point is inside the current selection.
1084      *
1085      * The coordinates are content-coordinates.
1086      */
1087     bool isPointInsideSelection(int x, int y);
1088 
1089     /**
1090      * @internal
1091      */
1092     bool restored() const;
1093 
1094     /**
1095      * Sets whether the document's Doctype should always be used
1096      * to determine the parsing mode for the document.
1097      *
1098      * Without this, parsing will be forced to
1099      * strict mode when using the write( const QString &str )
1100      * method for backward compatibility reasons.
1101      *
1102      */
1103     // ### KDE5 remove - fix write( const QString &str ) instead
1104     void setAlwaysHonourDoctype(bool b = true);
1105 
1106     // ### KDE5 remove me
1107     enum FormNotification { NoNotification = 0, Before, Only, Unused = 255 };
1108     /**
1109      * Determine if signal should be emitted before, instead or never when a
1110      * submitForm() happens.
1111      * ### KDE5 remove me
1112      */
1113     void setFormNotification(FormNotification fn);
1114 
1115     /**
1116      * Determine if signal should be emitted before, instead or never when a
1117      * submitForm() happens.
1118      * ### KDE5 remove me
1119      */
1120     FormNotification formNotification() const;
1121 
1122     /**
1123      * Returns the toplevel (origin) URL of this document, even if this
1124      * part is a frame or an iframe.
1125      *
1126      * @return the actual original url.
1127      */
1128     QUrl toplevelURL();
1129 
1130     /**
1131      * Checks whether the page contains unsubmitted form changes.
1132      *
1133      * @return @p true if form changes exist
1134      */
1135     bool isModified() const;
1136 
1137     /**
1138      * Shows or hides the suppressed popup indicator
1139      */
1140     void setSuppressedPopupIndicator(bool enable, KHTMLPart *originPart = nullptr);
1141 
1142     /**
1143      * @internal
1144      */
1145     bool inProgress() const;
1146 
1147 Q_SIGNALS:
1148     /**
1149      * Emitted if the cursor is moved over an URL.
1150      */
1151     void onURL(const QString &url);
1152 
1153     /**
1154      * Emitted when the user clicks the right mouse button on the document.
1155      * See KParts::BrowserExtension for two more popupMenu signals emitted by khtml,
1156      * with much more information in the signal.
1157      */
1158     void popupMenu(const QString &url, const QPoint &point);
1159 
1160     /**
1161      * This signal is emitted when the selection changes.
1162      */
1163     void selectionChanged();
1164 
1165     /**
1166      * This signal is emitted when an element retrieves the
1167      * keyboard focus. Note that the signal argument can be
1168      * a null node if no element is active, meaning a node
1169      * has explicitly been deactivated without a new one
1170      * becoming active.
1171      */
1172     void nodeActivated(const DOM::Node &);
1173 
1174     /**
1175      * @internal */
1176     void docCreated();
1177 
1178     /**
1179      * This signal is emitted whenever the caret position has been changed.
1180      *
1181      * The signal transmits the position the DOM::Range way, the node and
1182      * the zero-based offset within this node.
1183      * @param node node which the caret is in. This can be null if the caret
1184      *    has been deactivated.
1185      * @param offset offset within the node. If the node is null, the offset
1186      *    is meaningless.
1187      */
1188     void caretPositionChanged(const DOM::Node &node, long offset);
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      */
1194     // TODO: remove/deprecate?
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 protected:
1205 
1206     /**
1207      * returns a QUrl object for the given url. Use when
1208      * you know what you're doing.
1209      */
1210     QUrl completeURL(const QString &url);
1211 
1212     /**
1213      * presents a detailed error message to the user.
1214      * @p errorCode kio error code, eg KIO::ERR_SERVER_TIMEOUT.
1215      * @p text kio additional information text.
1216      * @p url the url that triggered the error.
1217      */
1218     void htmlError(int errorCode, const QString &text, const QUrl &reqUrl);
1219 
1220     void customEvent(QEvent *event) override;
1221 
1222     /**
1223      * Eventhandler of the khtml::MousePressEvent.
1224      */
1225     virtual void khtmlMousePressEvent(khtml::MousePressEvent *event);
1226     /**
1227      * Eventhandler for the khtml::MouseDoubleClickEvent.
1228      */
1229     virtual void khtmlMouseDoubleClickEvent(khtml::MouseDoubleClickEvent *);
1230     /**
1231      * Eventhandler for the khtml::MouseMouseMoveEvent.
1232      */
1233     virtual void khtmlMouseMoveEvent(khtml::MouseMoveEvent *event);
1234     /**
1235      * Eventhandler for the khtml::MouseMouseReleaseEvent.
1236      */
1237     virtual void khtmlMouseReleaseEvent(khtml::MouseReleaseEvent *event);
1238     /**
1239      * Eventhandler for the khtml::DrawContentsEvent.
1240      */
1241     virtual void khtmlDrawContentsEvent(khtml::DrawContentsEvent *);
1242 
1243     /**
1244      * Internal reimplementation of KParts::Part::guiActivateEvent .
1245      */
1246     void guiActivateEvent(KParts::GUIActivateEvent *event) override;
1247 
1248     /**
1249      * Internal empty reimplementation of KParts::ReadOnlyPart::openFile .
1250      */
1251     bool openFile() override;
1252 
1253     virtual bool urlSelected(const QString &url, int button, int state,
1254                              const QString &_target,
1255                              const KParts::OpenUrlArguments &args = KParts::OpenUrlArguments(),
1256                              const KParts::BrowserArguments &browserArgs = KParts::BrowserArguments());
1257 
1258     /**
1259      * This method is called when a new embedded object (include html frames) is to be created.
1260      * Reimplement it if you want to add support for certain embeddable objects without registering
1261      * them in the KDE wide registry system (KSyCoCa) . Another reason for re-implementing this
1262      * method could be if you want to derive from KTHMLPart and also want all html frame objects
1263      * to be a object of your derived type, in which case you should return a new instance for
1264      * the mimetype 'text/html' .
1265      */
1266     virtual KParts::ReadOnlyPart *createPart(QWidget *parentWidget,
1267             QObject *parent,
1268             const QString &mimetype, QString &serviceName,
1269             QStringList &serviceTypes, const QStringList &params);
1270 
1271     // This is for RenderPartObject. We want to ask the 'download plugin?'
1272     // question only once per mimetype
1273     bool pluginPageQuestionAsked(const QString &mimetype) const;
1274     void setPluginPageQuestionAsked(const QString &mimetype);
1275 
1276     enum PageSecurity { NotCrypted, Encrypted, Mixed };
1277     void setPageSecurity(PageSecurity sec);
1278 
1279     /**
1280      * Implements the streaming API of KParts::ReadOnlyPart.
1281      */
1282     bool doOpenStream(const QString &mimeType) override;
1283 
1284     /**
1285      * Implements the streaming API of KParts::ReadOnlyPart.
1286      */
1287     bool doWriteStream(const QByteArray &data) override;
1288 
1289     /**
1290      * Implements the streaming API of KParts::ReadOnlyPart.
1291      */
1292     bool doCloseStream() override;
1293 
1294     /**
1295      * @internal
1296      */
1297     void timerEvent(QTimerEvent *) override;
1298 
1299     /**
1300      * Will pre-resolve @p name according to dnsPrefetch current settings
1301      * Returns @p true if the name will be pre-resolved.
1302      * Otherwise returns false.
1303      */
1304 
1305     bool mayPrefetchHostname(const QString &name);
1306 
1307     /**
1308      * @internal
1309      */
1310     void updateZoomFactor();
1311 
1312 public Q_SLOTS:
1313 
1314     /**
1315      * Sets the focused node of the document to the specified node. If the node is a form control, the control will
1316      * receive focus in the same way that it would if the user had clicked on it or tabbed to it with the keyboard. For
1317      * most other types of elements, there is no visual indication of whether or not they are focused.
1318      *
1319      * See activeNode
1320      *
1321      * @param node The node to focus
1322      */
1323     void setActiveNode(const DOM::Node &node);
1324 
1325     /**
1326      * Stops all animated images on the current and child pages
1327      */
1328     void stopAnimations();
1329 
1330     /**
1331      * Execute the specified snippet of JavaScript code.
1332      *
1333      * Returns @p true if JavaScript was enabled, no error occurred
1334      * and the code returned @p true itself or @p false otherwise.
1335      * @deprecated, use executeString( DOM::Node(), script)
1336      */
1337     QVariant executeScript(const QString &script);
1338 
1339     /**
1340      * Enables/disables caret mode.
1341      *
1342      * Enabling caret mode displays a caret which can be used to navigate
1343      * the document using the keyboard only. Caret mode is switched off by
1344      * default.
1345      *
1346      * @param enable @p true to enable, @p false to disable caret mode.
1347      */
1348     void setCaretMode(bool enable);
1349 
1350     /**
1351      * Makes the document editable.
1352      *
1353      * Setting this property to @p true makes the document, and its
1354      * subdocuments (such as frames, iframes, objects) editable as a whole.
1355      * FIXME: insert more information about navigation, features etc. as seen fit
1356      *
1357      * @param enable @p true to set document editable, @p false to set it
1358      *    read-only.
1359      */
1360     void setEditable(bool enable);
1361 
1362     /**
1363      * Sets the visibility of the caret.
1364      *
1365      * This methods displays or hides the caret regardless of the current
1366      * caret display policy (see setCaretDisplayNonFocused), and regardless
1367      * of focus.
1368      *
1369      * The caret will be shown/hidden only under at least one of
1370      * the following conditions:
1371      * @li the document is editable
1372      * @li the document is in caret mode
1373      * @li the document's currently focused element is editable
1374      *
1375      * @param show @p true to make visible, @p false to hide.
1376      */
1377     void setCaretVisible(bool show);
1378 
1379     // ### FIXME:
1380     //     Remove this and make the one below protected+virtual slot.
1381     //     Warning: this is effectively "internal".  Be careful.
1382     void submitFormProxy(const char *action, const QString &url,
1383                          const QByteArray &formData,
1384                          const QString &target,
1385                          const QString &contentType = QString(),
1386                          const QString &boundary = QString());
1387 
1388 protected Q_SLOTS:
1389 
1390     /**
1391      * Called when the job downloading the page is finished.
1392      * Can be reimplemented, for instance to get metadata out of the job,
1393      * but make sure to call KHTMLPart::slotFinished() too.
1394      */
1395     virtual void slotFinished(KJob *);
1396 
1397 protected:
1398     /**
1399      * Hook for adding code before a job is started.
1400      * This can be used to add metadata, like job->addMetaData("PropagateHttpHeader", "true")
1401      * to get the HTTP headers.
1402      */
1403     virtual void startingJob(KIO::Job *) {}
1404 
1405 private Q_SLOTS:
1406 
1407     /**
1408      * @internal
1409      */
1410     void reparseConfiguration();
1411 
1412     /**
1413      * @internal
1414      */
1415     void slotData(KIO::Job *, const QByteArray &data);
1416     /**
1417     * @internal
1418     */
1419     void slotInfoMessage(KJob *, const QString &msg);
1420     /**
1421      * @internal
1422      */
1423     void slotRestoreData(const QByteArray &data);
1424     /**
1425      * @internal
1426      */
1427     void slotFinishedParsing();
1428     /**
1429      * @internal
1430      */
1431     void slotRedirect();
1432     /**
1433      * @internal
1434      */
1435     void slotRedirection(KIO::Job *, const QUrl &);
1436     /**
1437      * @internal
1438      */
1439     void slotDebugScript();
1440     /**
1441      * @internal
1442      */
1443     void slotDebugDOMTree();
1444     /**
1445      * @internal
1446      */
1447     void slotDebugRenderTree();
1448 
1449     void slotDebugFrameTree();
1450 
1451     /**
1452      * @internal
1453      */
1454     void slotStopAnimations();
1455     /**
1456      * @internal
1457      */
1458     virtual void slotViewDocumentSource();
1459     /**
1460      * @internal
1461      */
1462     virtual void slotViewFrameSource();
1463     /**
1464      * @internal
1465      */
1466     void slotViewPageInfo();
1467     /**
1468      * @internal
1469      */
1470     virtual void slotSaveBackground();
1471     /**
1472      * @internal
1473      */
1474     virtual void slotSaveDocument();
1475     /**
1476      * @internal
1477      */
1478     virtual void slotSaveFrame();
1479     /**
1480      * @internal
1481      */
1482     virtual void slotSecurity();
1483     /**
1484      * @internal
1485      */
1486     virtual void slotSetEncoding(const QString &);
1487 
1488     /**
1489      * @internal
1490      */
1491     virtual void slotUseStylesheet();
1492 
1493     virtual void slotFind();
1494     virtual void slotFindDone(); // ### remove me
1495     virtual void slotFindDialogDestroyed(); // ### remove me
1496     void slotFindNext();
1497     void slotFindPrev();
1498     void slotFindAheadText();
1499     void slotFindAheadLink();
1500 
1501     void slotIncZoom();
1502     void slotDecZoom();
1503     void slotIncZoomFast();
1504     void slotDecZoomFast();
1505 
1506     void slotIncFontSize();
1507     void slotDecFontSize();
1508     void slotIncFontSizeFast();
1509     void slotDecFontSizeFast();
1510 
1511     void slotLoadImages();
1512     void slotWalletClosed();
1513     void launchWalletManager();
1514     void walletMenu();
1515     void delNonPasswordStorableSite();
1516     void removeStoredPasswordForm(QAction *action);
1517     void addWalletFormKey(const QString &walletFormKey);
1518 
1519     /**
1520      * @internal
1521      */
1522     void submitFormAgain();
1523 
1524     /**
1525      * @internal
1526      */
1527     void updateActions();
1528     /**
1529      * @internal
1530      */
1531     void slotPartRemoved(KParts::Part *part);
1532     /**
1533      * @internal
1534      */
1535     void slotActiveFrameChanged(KParts::Part *part);
1536     /**
1537      * @internal
1538      */
1539     void slotChildStarted(KIO::Job *job);
1540     /**
1541      * @internal
1542      */
1543     void slotChildCompleted();
1544     /**
1545      * @internal
1546      */
1547     void slotChildCompleted(bool);
1548     /**
1549      * @internal
1550      */
1551     void slotParentCompleted();
1552     /**
1553      * @internal
1554      */
1555     void slotChildURLRequest(const QUrl &url, const KParts::OpenUrlArguments &, const KParts::BrowserArguments &args);
1556     /**
1557      * @internal
1558      */
1559     void slotChildDocCreated();
1560     /**
1561      * @internal
1562      */
1563     void slotRequestFocus(KParts::ReadOnlyPart *);
1564     void slotLoaderRequestStarted(khtml::DocLoader *, khtml::CachedObject *obj);
1565     void slotLoaderRequestDone(khtml::DocLoader *, khtml::CachedObject *obj);
1566     void checkCompleted();
1567 
1568     /**
1569      * @internal
1570      */
1571     void slotAutoScroll();
1572 
1573     void slotPrintFrame();
1574 
1575     void slotSelectAll();
1576 
1577     /**
1578      * @internal
1579      */
1580     void slotProgressUpdate();
1581 
1582     /*
1583      * @internal
1584      */
1585     void slotJobPercent(KJob *, unsigned long);
1586 
1587     /*
1588      * @internal
1589      */
1590     void slotJobDone(KJob *);
1591 
1592     /*
1593      * @internal
1594      */
1595     void slotUserSheetStatDone(KJob *);
1596 
1597     /*
1598      * @internal
1599      */
1600     void slotJobSpeed(KJob *, unsigned long);
1601 
1602     /**
1603      * @internal
1604      */
1605     void slotClearSelection();
1606 
1607     /**
1608      * @internal
1609      */
1610     void slotZoomView(int);
1611 
1612     /**
1613      * @internal
1614      */
1615     void slotAutomaticDetectionLanguage(KEncodingProber::ProberType scri);
1616 
1617     /**
1618      * @internal
1619      */
1620     void slotToggleCaretMode();
1621 
1622     /**
1623      * @internal
1624      */
1625     void suppressedPopupMenu();
1626 
1627     /**
1628      * @internal
1629      */
1630     void togglePopupPassivePopup();
1631 
1632     /**
1633      * @internal
1634      */
1635     void showSuppressedPopups();
1636 
1637     /**
1638      * @internal
1639      */
1640     void launchJSConfigDialog();
1641 
1642     /**
1643      * @internal
1644      */
1645     void launchJSErrorDialog();
1646 
1647     /**
1648      * @internal
1649      */
1650     void removeJSErrorExtension();
1651 
1652     /**
1653      * @internal
1654      */
1655     void disableJSErrorExtension();
1656 
1657     /**
1658      * @internal
1659      */
1660     void jsErrorDialogContextMenu();
1661 
1662     /**
1663      * @internal
1664      * used to restore or reset the view's scroll position (including positioning on anchors)
1665      * once a sufficient portion of the document as been laid out.
1666      */
1667     void restoreScrollPosition();
1668 
1669     void walletOpened(KWallet::Wallet *);
1670 
1671 private:
1672 
1673     KJSErrorDlg *jsErrorExtension();
1674 
1675     enum StatusBarPriority { BarDefaultText, BarHoverText, BarOverrideText };
1676     void setStatusBarText(const QString &text, StatusBarPriority p);
1677 
1678     bool restoreURL(const QUrl &url);
1679     void clearCaretRectIfNeeded();
1680     void setFocusNodeIfNeeded(const DOM::Selection &);
1681     void selectionLayoutChanged();
1682     void notifySelectionChanged(bool closeTyping = true);
1683     void resetFromScript();
1684     void emitSelectionChanged();
1685     void onFirstData();
1686     // Returns whether callingHtmlPart may access this part
1687     bool checkFrameAccess(KHTMLPart *callingHtmlPart);
1688     bool openUrlInFrame(const QUrl &url, const KParts::OpenUrlArguments &arguments, const KParts::BrowserArguments &browserArguments);
1689     void startAutoScroll();
1690     void stopAutoScroll();
1691     void overURL(const QString &url, const QString &target, bool shiftPressed = false);
1692     void resetHoverText(); // Undo overURL and reset HoverText
1693 
1694     KParts::ScriptableExtension *scriptableExtension(const DOM::NodeImpl *);
1695 
1696     KWallet::Wallet *wallet();
1697 
1698     void openWallet(DOM::HTMLFormElementImpl *);
1699     void saveToWallet(const QString &key, const QMap<QString, QString> &data);
1700     void dequeueWallet(DOM::HTMLFormElementImpl *);
1701     void saveLoginInformation(const QString &host, const QString &key, const QMap<QString, QString> &walletMap);
1702 
1703     void enableFindAheadActions(bool);
1704 
1705     /**
1706      * Returns a pointer to the top view bar.
1707      */
1708     KHTMLViewBar *pTopViewBar() const;
1709 
1710     /**
1711      * Returns a pointer to the bottom view bar.
1712      */
1713     KHTMLViewBar *pBottomViewBar() const;
1714 
1715     /**
1716      * @internal
1717      */
1718     bool pFindTextNextInThisFrame(bool reverse);
1719 
1720     /**
1721      * @internal
1722      */
1723     // ### FIXME:
1724     //     It is desirable to be able to filter form submissions as well.
1725     //     For instance, forms can have a target and an inheriting class
1726     //     might want to filter based on the target.  Make this protected
1727     //     and virtual, or provide a better solution.
1728     //     See the web_module for the sidebar for an example where this is
1729     //     necessary.
1730     void submitForm(const char *action, const QString &url, const QByteArray &formData,
1731                     const QString &target, const QString &contentType = QString(),
1732                     const QString &boundary = QString());
1733 
1734     void popupMenu(const QString &url);
1735 
1736     void init(KHTMLView *view, GUIProfile prof);
1737 
1738     void clear();
1739 
1740     QVariant crossFrameExecuteScript(const QString &target, const QString &script);
1741 
1742     /**
1743      * @internal returns a name for a frame without a name.
1744      * This function returns a sequence of names.
1745      * All names in a sequence are different but the sequence is
1746      * always the same.
1747      * The sequence is reset in clear().
1748      */
1749     QString requestFrameName();
1750 
1751     // Requests loading of a frame or iframe element
1752     void loadFrameElement(DOM::HTMLPartContainerElementImpl *frame, const QString &url, const QString &frameName,
1753                           const QStringList &args = QStringList(), bool isIFrame = false);
1754 
1755     // Requests loading of an object or embed element. Returns true if
1756     // loading succeeded.
1757     bool loadObjectElement(DOM::HTMLPartContainerElementImpl *frame, const QString &url, const QString &serviceType,
1758                            const QStringList &args = QStringList());
1759 
1760     // Tries an open a URL in given ChildFrame with all known navigation information
1761     // like mimetype and the like in the KParts arguments.
1762     //
1763     // Returns true if it's done -- which excludes the case when it's still resolving
1764     // the mimetype.
1765     // ### refine comment wrt to error case
1766     bool requestObject(khtml::ChildFrame *child, const QUrl &url,
1767                        const KParts::OpenUrlArguments &args = KParts::OpenUrlArguments(),
1768                        const KParts::BrowserArguments &browserArgs = KParts::BrowserArguments());
1769 
1770     // This method does the loading inside a ChildFrame once we know what mimetype to
1771     // load it as
1772     bool processObjectRequest(khtml::ChildFrame *child, const QUrl &url, const QString &mimetype);
1773 
1774     // helper for reporting ChildFrame load failure
1775     void childLoadFailure(khtml::ChildFrame *child);
1776 
1777     // Updates the ChildFrame to use the particular part, hooking up the various
1778     // signals, connections, etc.
1779     void connectToChildPart(khtml::ChildFrame *child, KParts::ReadOnlyPart *part,
1780                             const QString &mimetype);
1781 
1782     // Low-level navigation of the part itself --- this doesn't ask the user
1783     // to save things or such, and assumes that all the ChildFrame info is already
1784     // filed in with things like the mimetype and so on
1785     //
1786     // Returns if successful or not
1787     bool navigateChild(khtml::ChildFrame *child, const QUrl &url);
1788 
1789     // Helper for executing javascript: or about: protocols
1790     bool navigateLocalProtocol(khtml::ChildFrame *child, KParts::ReadOnlyPart *part,
1791                                const QUrl &url);
1792 
1793     DOM::EventListener *createHTMLEventListener(QString code, QString name, DOM::NodeImpl *node, bool svg = false);
1794 
1795     DOM::HTMLDocumentImpl *docImpl() const;
1796     DOM::DocumentImpl *xmlDocImpl() const;
1797     khtml::ChildFrame *frame(const QObject *obj);
1798 
1799     khtml::ChildFrame *recursiveFrameRequest(KHTMLPart *callingHtmlPart, const QUrl &url,
1800             const KParts::OpenUrlArguments &args, const KParts::BrowserArguments &browserArgs,
1801             bool callParent = true);
1802 
1803     bool checkLinkSecurity(const QUrl &linkURL, const KLocalizedString &message = KLocalizedString(), const QString &button = QString());
1804     QVariant executeScript(const QString &filename, int baseLine, const DOM::Node &n, const QString &script);
1805 
1806     KJSProxy *jScript();
1807 
1808     KHTMLPart *opener();
1809     long cacheId() const;
1810     void setOpener(KHTMLPart *_opener);
1811     bool openedByJS();
1812     void setOpenedByJS(bool _openedByJS);
1813 
1814     void checkEmitLoadEvent();
1815     void emitLoadEvent();
1816 
1817     bool initFindNode(bool selection, bool reverse, bool fromCursor);
1818 
1819     /** extends the current selection to the given content-coordinates @p x, @p y
1820      * @param x content x-coordinate
1821      * @param y content y-coordinate
1822      * @param absX absolute x-coordinate of @p innerNode
1823      * @param absY absolute y-coordinate of @p innerNode
1824      * @param innerNode node from which to start extending the selection. The
1825      *    caller has to ensure that the node has a renderer.
1826      * @internal
1827      */
1828     void extendSelectionTo(int x, int y, const DOM::Node &innerNode);
1829     /** checks whether a selection is extended.
1830      * @return @p true if a selection is extended by the mouse.
1831      */
1832     bool isExtendingSelection() const;
1833     KEncodingDetector *createDecoder();
1834     QString defaultEncoding() const;
1835 
1836     /** .html, .xhtml or .xml */
1837     QString defaultExtension() const;
1838 
1839     /** @internal
1840      * generic zoom in
1841      */
1842     void zoomIn(const int stepping[], int count);
1843     /** @internal
1844      * generic zoom out
1845      */
1846     void zoomOut(const int stepping[], int count);
1847 
1848     void incFontSize(const int stepping[], int count);
1849 
1850     void decFontSize(const int stepping[], int count);
1851 
1852     void emitCaretPositionChanged(const DOM::Position &pos);
1853 
1854     void setDebugScript(bool enable);
1855 
1856     void runAdFilter();
1857 
1858     khtml::EditorContext *editorContext() const;
1859 
1860     /**
1861      * initialises the caret if it hasn't been used yet.
1862      * @internal
1863      */
1864     void initCaret();
1865 
1866     /**
1867      * Returns the selected part of the HTML.
1868      */
1869     const DOM::Selection &caret() const;
1870 
1871     /**
1872      * Returns the drag caret of the HTML.
1873      */
1874     const DOM::Selection &dragCaret() const;
1875 
1876     /**
1877      * Sets the current caret to the given selection.
1878      */
1879     void setCaret(const DOM::Selection &, bool closeTyping = true);
1880 
1881     /**
1882      * Sets the current drag caret.
1883      */
1884     void setDragCaret(const DOM::Selection &);
1885 
1886     /**
1887      * Clears the current selection.
1888      */
1889     void clearSelection();
1890 
1891     /**
1892      * Invalidates the current selection.
1893      */
1894     void invalidateSelection();
1895 
1896     /**
1897      * Controls the visibility of the selection.
1898      */
1899     void setSelectionVisible(bool flag = true);
1900 
1901     /**
1902      * Paints the caret.
1903      */
1904     void paintCaret(QPainter *p, const QRect &rect) const;
1905 
1906     /**
1907      * Paints the drag caret.
1908      */
1909     void paintDragCaret(QPainter *p, const QRect &rect) const;
1910 
1911     /**
1912      * Returns selectedText without any leading or trailing whitespace,
1913      * and with non-breaking-spaces turned into normal spaces.
1914      *
1915      * Note that hasSelection can return true and yet simplifiedSelectedText can be empty,
1916      * e.g. when selecting a single space.
1917      */
1918     QString simplifiedSelectedText() const;
1919 
1920     bool handleMouseMoveEventDrag(khtml::MouseMoveEvent *event);
1921     bool handleMouseMoveEventOver(khtml::MouseMoveEvent *event);
1922     void handleMouseMoveEventSelection(khtml::MouseMoveEvent *event);
1923 
1924     void handleMousePressEventSingleClick(khtml::MousePressEvent *event);
1925     void handleMousePressEventDoubleClick(khtml::MouseDoubleClickEvent *event);
1926     void handleMousePressEventTripleClick(khtml::MouseDoubleClickEvent *event);
1927 
1928     KHTMLPartPrivate *d;
1929     friend class KHTMLPartPrivate;
1930 
1931 public: // So we don't end up having to add 50 more friends
1932 
1933     /** @internal Access to internal APIs. Don't use outside */
1934     KHTMLPartPrivate *impl()
1935     {
1936         return d;
1937     }
1938 };
1939 
1940 #endif