KHtml

html_document.cpp
1 
22 // --------------------------------------------------------------------------
23 
24 #include "html_document.h"
25 #include "dom/html_misc.h"
26 #include "dom/dom_exception.h"
27 #include "xml/dom_textimpl.h"
28 #include "html/html_documentimpl.h"
29 #include "html/html_miscimpl.h"
30 
31 using namespace DOM;
32 
33 HTMLDocument::HTMLDocument() : Document(false) // create the impl here
34 {
35  impl = DOMImplementationImpl::createHTMLDocument();
36  impl->ref();
37 
38 }
39 
40 HTMLDocument::HTMLDocument(KHTMLView *parent)
41  : Document(false) // create the impl here
42 {
43  impl = DOMImplementationImpl::createHTMLDocument(parent);
44  impl->ref();
45 }
46 
47 HTMLDocument::HTMLDocument(const HTMLDocument &other) : Document(other)
48 {
49 }
50 
51 HTMLDocument::HTMLDocument(HTMLDocumentImpl *impl) : Document(impl)
52 {
53 }
54 
55 HTMLDocument &HTMLDocument::operator = (const Node &other)
56 {
57  if (other.nodeType() != DOCUMENT_NODE) {
58  if (impl) {
59  impl->deref();
60  }
61  impl = nullptr;
62  } else {
63  DocumentImpl *d = static_cast<DocumentImpl *>(other.handle());
64  if (!d->isHTMLDocument()) {
65  if (impl) {
66  impl->deref();
67  }
68  impl = nullptr;
69  } else {
70  Node::operator =(other);
71  }
72  }
73  return *this;
74 }
75 
76 HTMLDocument &HTMLDocument::operator = (const HTMLDocument &other)
77 {
78  Document::operator =(other);
79  return *this;
80 }
81 
82 HTMLDocument::~HTMLDocument()
83 {
84 }
85 
87 {
88  if (!impl) {
89  return DOMString();
90  }
91  return static_cast<HTMLDocumentImpl *>(impl)->title();
92 }
93 
95 {
96  if (impl) {
97  static_cast<HTMLDocumentImpl *>(impl)->setTitle(value);
98  }
99 }
100 
102 {
103  if (!impl) {
104  return DOMString();
105  }
106  return ((HTMLDocumentImpl *)impl)->referrer();
107 }
108 
110 {
111  if (!impl) {
112  return str;
113  }
114  return ((HTMLDocumentImpl *)impl)->completeURL(str.trimSpaces().string());
115 }
116 
118 {
119  if (!impl) {
120  return DOMString();
121  }
122  return ((HTMLDocumentImpl *)impl)->domain();
123 }
124 
126 {
127  if (!impl) {
128  return DOMString();
129  }
130  return ((HTMLDocumentImpl *)impl)->lastModified();
131 }
132 
134 {
135  if (!impl) {
136  return DOMString();
137  }
138  return ((HTMLDocumentImpl *)impl)->URL().url();
139 }
140 
142 {
143  if (!impl) {
144  return nullptr;
145  }
146  return ((HTMLDocumentImpl *)impl)->body();
147 }
148 
150 {
151  if (!impl) {
152  return;
153  }
154  int exceptioncode = 0;
155  ((HTMLDocumentImpl *)impl)->setBody(static_cast<HTMLElementImpl *>(_body.handle()), exceptioncode);
156  if (exceptioncode) {
157  throw DOMException(exceptioncode);
158  }
159  return;
160 }
161 
163 {
164  if (!impl) {
165  return HTMLCollection();
166  }
167  return ((HTMLDocumentImpl *)impl)->images();
168 }
169 
171 {
172  if (!impl) {
173  return HTMLCollection();
174  }
175  return ((HTMLDocumentImpl *)impl)->applets();
176 }
177 
179 {
180  if (!impl) {
181  return HTMLCollection();
182  }
183  return ((HTMLDocumentImpl *)impl)->scripts();
184 }
185 
187 {
188  if (!impl) {
189  return HTMLCollection();
190  }
191  return ((HTMLDocumentImpl *)impl)->links();
192 }
193 
195 {
196  if (!impl) {
197  return HTMLCollection();
198  }
199  return ((HTMLDocumentImpl *)impl)->forms();
200 }
201 
203 {
204  if (!impl) {
205  return HTMLCollection();
206  }
207  return ((HTMLDocumentImpl *)impl)->layers();
208 }
209 
211 {
212  if (!impl) {
213  return HTMLCollection();
214  }
215  return ((HTMLDocumentImpl *)impl)->anchors();
216 }
217 
219 {
220  if (!impl) {
221  return HTMLCollection();
222  }
223  return ((HTMLDocumentImpl *)impl)->all();
224 }
225 
227 {
228  if (!impl) {
229  return DOMString();
230  }
231  return ((HTMLDocumentImpl *)impl)->cookie();
232 }
233 
235 {
236  if (impl) {
237  ((HTMLDocumentImpl *)impl)->setCookie(value);
238  }
239 
240 }
241 
243 {
244  if (impl) {
245  ((HTMLDocumentImpl *)impl)->open();
246  }
247 }
248 
250 {
251  if (impl) {
252  ((HTMLDocumentImpl *)impl)->close();
253  }
254 }
255 
257 {
258  if (impl) {
259  ((HTMLDocumentImpl *)impl)->write(text);
260  }
261 }
262 
264 {
265  if (impl) {
266  ((HTMLDocumentImpl *)impl)->writeln(text);
267  }
268 }
269 
271 {
272  if (!impl) {
273  return nullptr;
274  }
275  return ((HTMLDocumentImpl *)impl)->getElementsByName(elementName);
276 }
277 
HTMLCollection images() const
A collection of all the IMG elements in a document.
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:278
An HTMLDocument is the root of the HTML hierarchy and holds the entire content.
Definition: html_document.h:74
HTMLCollection layers() const
A collection of all the layers of a document.
void write(const DOMString &text)
Write a string of text to a document stream opened by open() .
void setCookie(const DOMString &)
see cookie
Renders and displays HTML in a QScrollArea.
Definition: khtmlview.h:97
DOMString cookie() const
The cookies associated with this document.
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:58
void close()
Closes a document stream opened by open() and forces rendering.
HTMLCollection applets() const
A collection of all the OBJECT elements that include applets and APPLET ( deprecated ) elements in a ...
DOMString completeURL(const DOMString &url) const
not part of the DOM
DOMString title() const
The title of a document as specified by the TITLE element in the head of the document.
An HTMLCollection is a list of nodes.
Definition: html_misc.h:133
void setBody(const HTMLElement &)
see body
void setTitle(const DOMString &)
see title
HTMLCollection scripts() const
A collection of all the scripts in the document.
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
The Document interface represents the entire HTML or XML document.
Definition: dom_doc.h:246
DOMString referrer() const
Returns the URI of the page that linked to this page.
HTMLCollection forms() const
A collection of all the forms of a document.
NodeList getElementsByName(const DOMString &elementName)
Returns the (possibly empty) collection of elements whose name value is given by elementName ...
HTMLCollection links() const
A collection of all AREA elements and anchor ( A ) elements in a document with a value for the href a...
HTMLCollection all() const
Not part of the DOM.
The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented.
Definition: dom_node.h:976
DOMString lastModified() const
Not part of the DOM.
This library provides a full-featured HTML parser and widget.
HTMLCollection anchors() const
A collection of all the anchor ( A ) elements in a document with a value for the name attribute...
void writeln(const DOMString &text)
Write a string of text followed by a newline character to a document stream opened by open() ...
NodeImpl * handle() const
Definition: dom_node.h:936
All HTML element interfaces derive from this class.
Definition: html_element.h:70
DOMString URL() const
The absolute URI of the document.
DOMString domain() const
The domain name of the server that served the document, or a null string if the server cannot be iden...
HTMLElement body() const
The element that contains the content for the document.
DOMString trimSpaces() const
Returns a string with Space Characters removed from the start and the end.
Definition: dom_string.cpp:345
unsigned short nodeType() const
A code representing the type of the underlying object, as defined above.
Definition: dom_node.cpp:242
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jul 10 2020 22:44:29 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.