KHtml

html_headimpl.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) 2002-2003 Apple Computer, Inc.
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_HEADIMPL_H
25 #define HTML_HEADIMPL_H
26 
27 #include "html/html_elementimpl.h"
28 #include "misc/loader_client.h"
29 #include "css/css_stylesheetimpl.h"
30 
31 namespace khtml
32 {
33 class CachedCSSStyleSheet;
34 class CachedObject;
35 }
36 
37 namespace DOM
38 {
39 
40 class DOMString;
41 class StyleSheetImpl;
42 class CSSStyleSheetImpl;
43 
44 class HTMLBaseElementImpl : public HTMLElementImpl
45 {
46 public:
47  HTMLBaseElementImpl(DocumentImpl *doc)
48  : HTMLElementImpl(doc) {}
49 
50  DOMString href() const
51  {
52  return DOMString(m_href);
53  }
54  DOMString target() const
55  {
56  return m_target;
57  }
58 
59  Id id() const override;
60  void parseAttribute(AttributeImpl *attr) override;
61  void insertedIntoDocument() override;
62  void removedFromDocument() override;
63 
64  void process();
65 
66 protected:
67  QString m_href;
68  DOMString m_target;
69 };
70 
71 // -------------------------------------------------------------------------
72 
73 class HTMLLinkElementImpl : public khtml::CachedObjectClient, public HTMLElementImpl
74 {
75 public:
76  HTMLLinkElementImpl(DocumentImpl *doc)
77  : HTMLElementImpl(doc), m_cachedSheet(nullptr), m_sheet(nullptr), m_isDisabled(false),
78  m_loading(false), m_alternate(false), m_isCSSSheet(false) {}
79 
80  ~HTMLLinkElementImpl();
81 
82  Id id() const override;
83 
84  const StyleSheetImpl *sheet() const
85  {
86  return m_sheet;
87  }
88  StyleSheetImpl *sheet()
89  {
90  return m_sheet;
91  }
92 
93  // overload from HTMLElementImpl
94  void parseAttribute(AttributeImpl *attr) override;
95 
96  void process();
97 
98  void insertedIntoDocument() override;
99  void removedFromDocument() override;
100 
101  // from CachedObjectClient
102  void setStyleSheet(const DOM::DOMString &url, const DOM::DOMString &sheet, const DOM::DOMString &charset, const DOM::DOMString &mimetype) override;
103  void error(int err, const QString &text) override;
104  bool isLoading() const;
105  bool checkAddPendingSheet() override;
106  bool checkRemovePendingSheet() override;
107 
108  bool isAlternate() const
109  {
110  return m_alternate;
111  }
112  bool isCSSStyleSheet() const
113  {
114  return m_isCSSSheet;
115  }
116  bool isDisabled() const
117  {
118  return m_isDisabled;
119  }
120  void setDisabled(bool disabled)
121  {
122  m_isDisabled = disabled;
123  }
124 
125 protected:
126  void finished();
127 
128  khtml::CachedCSSStyleSheet *m_cachedSheet;
129  CSSStyleSheetImpl *m_sheet;
130  DOMString m_url;
131  QString m_media;
132  bool m_isDisabled : 1;
133  bool m_loading : 1;
134  bool m_alternate : 1;
135  bool m_isCSSSheet : 1;
136 };
137 
138 // -------------------------------------------------------------------------
139 
140 class HTMLMetaElementImpl : public HTMLElementImpl
141 {
142 public:
143  HTMLMetaElementImpl(DocumentImpl *doc)
144  : HTMLElementImpl(doc) {}
145 
146  Id id() const override;
147  void parseAttribute(AttributeImpl *attr) override;
148  void insertedIntoDocument() override;
149 
150  void process();
151 
152 protected:
153  DOMString m_equiv;
154  DOMString m_content;
155 };
156 
157 // -------------------------------------------------------------------------
158 
159 class HTMLScriptElementImpl : public HTMLElementImpl, public khtml::CachedObjectClient
160 {
161 public:
162  HTMLScriptElementImpl(DocumentImpl *doc);
163  ~HTMLScriptElementImpl();
164 
165  void parseAttribute(AttributeImpl *attr) override;
166  void insertedIntoDocument() override;
167  void removedFromDocument() override;
168  void notifyFinished(khtml::CachedObject *finishedObj) override;
169  void childrenChanged() override;
170 
171  Id id() const override;
172  virtual bool isURLAttribute(AttributeImpl *attr) const;
173 
174  void setCreatedByParser(bool createdByParser)
175  {
176  m_createdByParser = createdByParser;
177  }
178 
179  bool isValidScript() const;
180  void evaluateScript(const QString &, const DOMString &);
181 
182  DOMString text() const;
183  void setText(const DOMString &str);
184 
185  DOMString htmlFor() const;
186  void setHtmlFor(const DOMString &);
187 
188  DOMString event() const;
189  void setEvent(const DOMString &);
190 
191  DOMString charset() const;
192  void setCharset(const DOMString &);
193 
194  bool defer() const;
195  void setDefer(bool);
196 
197  DOMString src() const;
198  void setSrc(const DOMString &);
199 
200  DOMString type() const;
201  void setType(const DOMString &);
202 
203 private:
204  void loadFromUrl(const DOMString &url);
205  khtml::CachedScript *m_cachedScript;
206  bool m_createdByParser;
207  bool m_evaluated;
208  bool m_hasNonEmptyForAttribute;
209 };
210 
211 // -------------------------------------------------------------------------
212 
213 class HTMLStyleElementImpl : public HTMLElementImpl
214 {
215 public:
216  HTMLStyleElementImpl(DocumentImpl *doc)
217  : HTMLElementImpl(doc), m_sheet(nullptr), m_loading(false) {}
218  ~HTMLStyleElementImpl();
219 
220  Id id() const override;
221 
222  CSSStyleSheetImpl *sheet()
223  {
224  return m_sheet;
225  }
226 
227  // overload from HTMLElementImpl
228  void parseAttribute(AttributeImpl *attr) override;
229  void insertedIntoDocument() override;
230  void removedFromDocument() override;
231  void childrenChanged() override;
232 
233  bool isLoading() const;
234  bool checkAddPendingSheet() override;
235  bool checkRemovePendingSheet() override;
236 
237 protected:
238  void parseText();
239 
240  CSSStyleSheetImpl *m_sheet;
241  DOMString m_type;
242  QString m_media;
243  bool m_loading;
244 };
245 
246 // -------------------------------------------------------------------------
247 
248 class HTMLTitleElementImpl : public HTMLElementImpl
249 {
250 public:
251  HTMLTitleElementImpl(DocumentImpl *doc)
252  : HTMLElementImpl(doc) {}
253 
254  DOMString text();
255  void setText(const DOMString &str);
256 
257  Id id() const override;
258 
259  void childrenChanged() override;
260 
261 protected:
262  DOMString m_title;
263 };
264 
265 } //namespace
266 
267 #endif
This file is part of the HTML rendering engine for KDE.
a cached style sheet.
Definition: loader.h:282
Type type(const QSqlDatabase &db)
void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
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.
a cached script
Definition: loader.h:322
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.