Warning, file /frameworks/khtml/src/html/html_objectimpl.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * This file is part of the DOM implementation for KDE.
0003  *
0004  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
0005  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
0006  *           (C) 2007, 2008 Maks Orlovich (maksim@kde.org)
0007  *
0008  * This library is free software; you can redistribute it and/or
0009  * modify it under the terms of the GNU Library General Public
0010  * License as published by the Free Software Foundation; either
0011  * version 2 of the License, or (at your option) any later version.
0012  *
0013  * This library is distributed in the hope that it will be useful,
0014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016  * Library General Public License for more details.
0017  *
0018  * You should have received a copy of the GNU Library General Public License
0019  * along with this library; see the file COPYING.LIB.  If not, write to
0020  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0021  * Boston, MA 02110-1301, USA.
0022  *
0023  */
0024 #ifndef HTML_OBJECTIMPL_H
0025 #define HTML_OBJECTIMPL_H
0026 
0027 #include "html_elementimpl.h"
0028 #include "xml/dom_stringimpl.h"
0029 #include <QObject>
0030 #include <QPointer>
0031 #include <QStringList>
0032 #include <QWidget>
0033 
0034 // -------------------------------------------------------------------------
0035 class KHTMLPart;
0036 
0037 namespace DOM
0038 {
0039 
0040 class HTMLFormElementImpl;
0041 class HTMLEmbedElementImpl;
0042 
0043 // Base class of all objects that are displayed as KParts:
0044 // frames, objects, applets, etc.
0045 class HTMLPartContainerElementImpl : public QObject, public HTMLElementImpl
0046 {
0047     Q_OBJECT
0048 public:
0049 
0050     enum DOMChildFrameEvents { DOMCFResizeEvent = 0x3030 };
0051 
0052     HTMLPartContainerElementImpl(DocumentImpl *doc);
0053     ~HTMLPartContainerElementImpl();
0054 
0055     void computeContentIfNeeded();
0056     void setNeedComputeContent();
0057 
0058     void recalcStyle(StyleChange ch) override;
0059     void close() override;
0060 
0061     // These methods will be called to notify the element of
0062     // any progress in loading of the document: setWidgetNotify if the
0063     // KPart was created, and partLoadingErrorNotify when
0064     // there was a problem with creating the part or loading the data
0065     // (hence setWidgetNotify may be followed by partLoadingErrorNotify).
0066     // This class take care of all the memory management, and during
0067     // the setWidgetNotify call, both old (if any) and new widget are alive
0068     // Note: setWidgetNotify may be called with 0...
0069     virtual void setWidgetNotify(QWidget *widget) = 0;
0070     virtual void partLoadingErrorNotify();
0071 
0072     // This is called when a mimetype is discovered, and should return true
0073     // if KHTMLPart should not make a kpart for it, but rather let it be handled directly.
0074     virtual bool mimetypeHandledInternally(const QString &mime);
0075 
0076     bool event(QEvent *e) override;
0077 
0078     // IMPORTANT: you should call this when requesting a URL, to make sure
0079     // that we don't get stale references to iframes or such.
0080     void clearChildWidget();
0081     QWidget *childWidget() const
0082     {
0083         return m_childWidget;
0084     }
0085 
0086     void postResizeEvent();
0087     static void sendPostedResizeEvents();
0088 public Q_SLOTS:
0089     void slotEmitLoadEvent();
0090 private:
0091     friend class ::KHTMLPart;
0092     // This is called by KHTMLPart to notify us of the new widget.
0093     void setWidget(QWidget *widget);
0094 private:
0095     virtual void computeContent() = 0;
0096     bool m_needToComputeContent; // This flag is set to true when
0097     // we may have to load a new KPart, due to
0098     // source changing, etc.
0099     QPointer<QWidget> m_childWidget; // may be deleted by global child widget cleanup on us..
0100 };
0101 
0102 class HTMLObjectBaseElementImpl : public HTMLPartContainerElementImpl
0103 {
0104     Q_OBJECT
0105 public:
0106     HTMLObjectBaseElementImpl(DocumentImpl *doc);
0107 
0108     void parseAttribute(AttributeImpl *attr) override;
0109     void attach() override;
0110     void defaultEventHandler(EventImpl *e) override;
0111 
0112     void setServiceType(const QString &);
0113 
0114     QString url;
0115     QString classId;
0116     QString serviceType;
0117 
0118     bool m_rerender; // This is set to true if a reattach is pending,
0119     // due to a change in how we need to display this...
0120 
0121     bool m_renderAlternative;
0122     bool m_imageLike;
0123 
0124     void insertedIntoDocument() override;
0125     void removedFromDocument() override;
0126     void addId(const DOMString &id) override;
0127     void removeId(const DOMString &id) override;
0128 
0129     HTMLEmbedElementImpl *relevantEmbed();
0130 
0131     void setWidgetNotify(QWidget *widget) override;
0132     void partLoadingErrorNotify() override;
0133     bool mimetypeHandledInternally(const QString &mime) override;
0134 
0135     // This method figures out what to render -- perhaps KPart, perhaps an image, perhaps
0136     // alternative content, and forces a reattach if need be.
0137     void computeContent() override;
0138 
0139     // Ask for a reattach, since we may need a different renderer..
0140     void requestRerender();
0141 
0142     void renderAlternative();
0143 protected Q_SLOTS:
0144     void slotRerender();
0145     void slotPartLoadingErrorNotify();
0146 protected:
0147     DOMString     m_name;
0148 };
0149 
0150 // -------------------------------------------------------------------------
0151 
0152 class HTMLAppletElementImpl : public HTMLObjectBaseElementImpl
0153 {
0154 public:
0155     HTMLAppletElementImpl(DocumentImpl *doc);
0156 
0157     ~HTMLAppletElementImpl();
0158 
0159     Id id() const override;
0160 
0161     void parseAttribute(AttributeImpl *token) override;
0162     void computeContent() override;
0163 protected:
0164     khtml::VAlign valign;
0165 };
0166 
0167 // -------------------------------------------------------------------------
0168 
0169 class HTMLEmbedElementImpl : public HTMLObjectBaseElementImpl
0170 {
0171 public:
0172     HTMLEmbedElementImpl(DocumentImpl *doc);
0173     ~HTMLEmbedElementImpl();
0174 
0175     Id id() const override;
0176 
0177     void parseAttribute(AttributeImpl *attr) override;
0178     void attach() override;
0179     void computeContent() override;
0180 
0181     virtual HTMLEmbedElementImpl *relevantEmbed();
0182 
0183     QString pluginPage;
0184     bool hidden;
0185 };
0186 
0187 // -------------------------------------------------------------------------
0188 
0189 class HTMLObjectElementImpl : public HTMLObjectBaseElementImpl
0190 {
0191 public:
0192     HTMLObjectElementImpl(DocumentImpl *doc);
0193 
0194     ~HTMLObjectElementImpl();
0195 
0196     Id id() const override;
0197 
0198     HTMLFormElementImpl *form() const;
0199 
0200     void parseAttribute(AttributeImpl *token) override;
0201 
0202     void attach() override;
0203 
0204     DocumentImpl *contentDocument() const;
0205 };
0206 
0207 // -------------------------------------------------------------------------
0208 
0209 class HTMLParamElementImpl : public HTMLElementImpl
0210 {
0211     friend class HTMLAppletElementImpl;
0212 public:
0213     HTMLParamElementImpl(DocumentImpl *_doc) : HTMLElementImpl(_doc) {}
0214 
0215     Id id() const override;
0216 
0217     void parseAttribute(AttributeImpl *token) override;
0218 
0219     QString name() const
0220     {
0221         return m_name;
0222     }
0223     QString value() const
0224     {
0225         return m_value;
0226     }
0227 
0228 protected:
0229     QString m_name;
0230     QString m_value;
0231 };
0232 
0233 } // namespace
0234 #endif