KHtml

html_objectimpl.h
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright (C) 1999 Lars Knoll ([email protected])
5  * (C) 1999 Antti Koivisto ([email protected])
6  * (C) 2007, 2008 Maks Orlovich ([email protected])
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB. If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  */
24 #ifndef HTML_OBJECTIMPL_H
25 #define HTML_OBJECTIMPL_H
26 
27 #include "html_elementimpl.h"
28 #include "xml/dom_stringimpl.h"
29 #include <QObject>
30 #include <QPointer>
31 #include <QStringList>
32 #include <QWidget>
33 
34 // -------------------------------------------------------------------------
35 class KHTMLPart;
36 
37 namespace DOM
38 {
39 
40 class HTMLFormElementImpl;
41 class HTMLEmbedElementImpl;
42 
43 // Base class of all objects that are displayed as KParts:
44 // frames, objects, applets, etc.
45 class HTMLPartContainerElementImpl : public QObject, public HTMLElementImpl
46 {
47  Q_OBJECT
48 public:
49 
50  enum DOMChildFrameEvents { DOMCFResizeEvent = 0x3030 };
51 
52  HTMLPartContainerElementImpl(DocumentImpl *doc);
53  ~HTMLPartContainerElementImpl();
54 
55  void computeContentIfNeeded();
56  void setNeedComputeContent();
57 
58  void recalcStyle(StyleChange ch) override;
59  void close() override;
60 
61  // These methods will be called to notify the element of
62  // any progress in loading of the document: setWidgetNotify if the
63  // KPart was created, and partLoadingErrorNotify when
64  // there was a problem with creating the part or loading the data
65  // (hence setWidgetNotify may be followed by partLoadingErrorNotify).
66  // This class take care of all the memory management, and during
67  // the setWidgetNotify call, both old (if any) and new widget are alive
68  // Note: setWidgetNotify may be called with 0...
69  virtual void setWidgetNotify(QWidget *widget) = 0;
70  virtual void partLoadingErrorNotify();
71 
72  // This is called when a mimetype is discovered, and should return true
73  // if KHTMLPart should not make a kpart for it, but rather let it be handled directly.
74  virtual bool mimetypeHandledInternally(const QString &mime);
75 
76  bool event(QEvent *e) override;
77 
78  // IMPORTANT: you should call this when requesting a URL, to make sure
79  // that we don't get stale references to iframes or such.
80  void clearChildWidget();
81  QWidget *childWidget() const
82  {
83  return m_childWidget;
84  }
85 
86  void postResizeEvent();
87  static void sendPostedResizeEvents();
88 public Q_SLOTS:
89  void slotEmitLoadEvent();
90 private:
91  friend class ::KHTMLPart;
92  // This is called by KHTMLPart to notify us of the new widget.
93  void setWidget(QWidget *widget);
94 private:
95  virtual void computeContent() = 0;
96  bool m_needToComputeContent; // This flag is set to true when
97  // we may have to load a new KPart, due to
98  // source changing, etc.
99  QPointer<QWidget> m_childWidget; // may be deleted by global child widget cleanup on us..
100 };
101 
102 class HTMLObjectBaseElementImpl : public HTMLPartContainerElementImpl
103 {
104  Q_OBJECT
105 public:
106  HTMLObjectBaseElementImpl(DocumentImpl *doc);
107 
108  void parseAttribute(AttributeImpl *attr) override;
109  void attach() override;
110  void defaultEventHandler(EventImpl *e) override;
111 
112  void setServiceType(const QString &);
113 
114  QString url;
115  QString classId;
116  QString serviceType;
117 
118  bool m_rerender; // This is set to true if a reattach is pending,
119  // due to a change in how we need to display this...
120 
121  bool m_renderAlternative;
122  bool m_imageLike;
123 
124  void insertedIntoDocument() override;
125  void removedFromDocument() override;
126  void addId(const DOMString &id) override;
127  void removeId(const DOMString &id) override;
128 
129  HTMLEmbedElementImpl *relevantEmbed();
130 
131  void setWidgetNotify(QWidget *widget) override;
132  void partLoadingErrorNotify() override;
133  bool mimetypeHandledInternally(const QString &mime) override;
134 
135  // This method figures out what to render -- perhaps KPart, perhaps an image, perhaps
136  // alternative content, and forces a reattach if need be.
137  void computeContent() override;
138 
139  // Ask for a reattach, since we may need a different renderer..
140  void requestRerender();
141 
142  void renderAlternative();
143 protected Q_SLOTS:
144  void slotRerender();
145  void slotPartLoadingErrorNotify();
146 protected:
147  DOMString m_name;
148 };
149 
150 // -------------------------------------------------------------------------
151 
152 class HTMLAppletElementImpl : public HTMLObjectBaseElementImpl
153 {
154 public:
155  HTMLAppletElementImpl(DocumentImpl *doc);
156 
157  ~HTMLAppletElementImpl();
158 
159  Id id() const override;
160 
161  void parseAttribute(AttributeImpl *token) override;
162  void computeContent() override;
163 protected:
164  khtml::VAlign valign;
165 };
166 
167 // -------------------------------------------------------------------------
168 
169 class HTMLEmbedElementImpl : public HTMLObjectBaseElementImpl
170 {
171 public:
172  HTMLEmbedElementImpl(DocumentImpl *doc);
173  ~HTMLEmbedElementImpl();
174 
175  Id id() const override;
176 
177  void parseAttribute(AttributeImpl *attr) override;
178  void attach() override;
179  void computeContent() override;
180 
181  virtual HTMLEmbedElementImpl *relevantEmbed();
182 
183  QString pluginPage;
184  bool hidden;
185 };
186 
187 // -------------------------------------------------------------------------
188 
189 class HTMLObjectElementImpl : public HTMLObjectBaseElementImpl
190 {
191 public:
192  HTMLObjectElementImpl(DocumentImpl *doc);
193 
194  ~HTMLObjectElementImpl();
195 
196  Id id() const override;
197 
198  HTMLFormElementImpl *form() const;
199 
200  void parseAttribute(AttributeImpl *token) override;
201 
202  void attach() override;
203 
204  DocumentImpl *contentDocument() const;
205 };
206 
207 // -------------------------------------------------------------------------
208 
209 class HTMLParamElementImpl : public HTMLElementImpl
210 {
211  friend class HTMLAppletElementImpl;
212 public:
213  HTMLParamElementImpl(DocumentImpl *_doc) : HTMLElementImpl(_doc) {}
214 
215  Id id() const override;
216 
217  void parseAttribute(AttributeImpl *token) override;
218 
219  QString name() const
220  {
221  return m_name;
222  }
223  QString value() const
224  {
225  return m_value;
226  }
227 
228 protected:
229  QString m_name;
230  QString m_value;
231 };
232 
233 } // namespace
234 #endif
QString name(const QVariant &location)
This class is khtml&#39;s main class.
Definition: khtml_part.h:208
const QList< QKeySequence > & close()
Q_OBJECTQ_OBJECT
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
int64_t Id
This library provides a full-featured HTML parser and widget.
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.