KHtml

html_inline.cpp
1 /**
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright 1999 Lars Knoll ([email protected])
5  * Copyright 2001 Dirk mueller ([email protected])
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23 // --------------------------------------------------------------------------
24 
25 #include "html_inline.h"
26 #include "dom_doc.h"
27 
28 #include <html/html_inlineimpl.h>
29 #include <html/html_baseimpl.h>
30 #include <xml/dom_docimpl.h>
31 
32 using namespace DOM;
33 
34 HTMLAnchorElement::HTMLAnchorElement() : HTMLElement()
35 {
36 }
37 
38 HTMLAnchorElement::HTMLAnchorElement(const HTMLAnchorElement &other) : HTMLElement(other)
39 {
40 }
41 
42 HTMLAnchorElement::HTMLAnchorElement(HTMLAnchorElementImpl *impl) : HTMLElement(impl)
43 {
44 }
45 
46 HTMLAnchorElement &HTMLAnchorElement::operator = (const Node &other)
47 {
48  assignOther(other, ID_A);
49  return *this;
50 }
51 
52 HTMLAnchorElement &HTMLAnchorElement::operator = (const HTMLAnchorElement &other)
53 {
54  HTMLElement::operator = (other);
55  return *this;
56 }
57 
58 HTMLAnchorElement::~HTMLAnchorElement()
59 {
60 }
61 
63 {
64  if (!impl) {
65  return DOMString();
66  }
67  return ((ElementImpl *)impl)->getAttribute(ATTR_ACCESSKEY);
68 }
69 
71 {
72  if (impl) {
73  ((ElementImpl *)impl)->setAttribute(ATTR_ACCESSKEY, value);
74  }
75 }
76 
78 {
79  if (!impl) {
80  return DOMString();
81  }
82  return ((ElementImpl *)impl)->getAttribute(ATTR_CHARSET);
83 }
84 
86 {
87  if (impl) {
88  ((ElementImpl *)impl)->setAttribute(ATTR_CHARSET, value);
89  }
90 }
91 
93 {
94  if (!impl) {
95  return DOMString();
96  }
97  return ((ElementImpl *)impl)->getAttribute(ATTR_COORDS);
98 }
99 
101 {
102  if (impl) {
103  ((ElementImpl *)impl)->setAttribute(ATTR_COORDS, value);
104  }
105 }
106 
108 {
109  if (!impl) {
110  return DOMString();
111  }
112  const DOMString href = static_cast<ElementImpl *>(impl)->getAttribute(ATTR_HREF).trimSpaces();
113  return !href.isNull() ? impl->document()->completeURL(href.string()) : href;
114 }
115 
117 {
118  if (impl) {
119  ((ElementImpl *)impl)->setAttribute(ATTR_HREF, value);
120  }
121 }
122 
124 {
125  if (!impl) {
126  return DOMString();
127  }
128  return ((ElementImpl *)impl)->getAttribute(ATTR_HREFLANG);
129 }
130 
132 {
133  if (impl) {
134  ((ElementImpl *)impl)->setAttribute(ATTR_HREFLANG, value);
135  }
136 }
137 
139 {
140  if (!impl) {
141  return DOMString();
142  }
143  return ((ElementImpl *)impl)->getAttribute(ATTR_NAME);
144 }
145 
147 {
148  if (impl) {
149  ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value);
150  }
151 }
152 
154 {
155  if (!impl) {
156  return DOMString();
157  }
158  return ((ElementImpl *)impl)->getAttribute(ATTR_REL);
159 }
160 
162 {
163  if (impl) {
164  ((ElementImpl *)impl)->setAttribute(ATTR_REL, value);
165  }
166 }
167 
169 {
170  if (!impl) {
171  return DOMString();
172  }
173  return ((ElementImpl *)impl)->getAttribute(ATTR_REV);
174 }
175 
177 {
178  if (impl) {
179  ((ElementImpl *)impl)->setAttribute(ATTR_REV, value);
180  }
181 }
182 
184 {
185  if (!impl) {
186  return DOMString();
187  }
188  return ((ElementImpl *)impl)->getAttribute(ATTR_SHAPE);
189 }
190 
192 {
193  if (impl) {
194  ((ElementImpl *)impl)->setAttribute(ATTR_SHAPE, value);
195  }
196 }
197 
199 {
200  if (!impl) {
201  return 0;
202  }
203  return ((ElementImpl *)impl)->getAttribute(ATTR_TABINDEX).toInt();
204 }
205 
206 void HTMLAnchorElement::setTabIndex(long _tabIndex)
207 {
208  if (impl) {
209  DOMString value(QString::number(_tabIndex));
210  ((ElementImpl *)impl)->setAttribute(ATTR_TABINDEX, value);
211  }
212 }
213 
215 {
216  if (!impl) {
217  return DOMString();
218  }
219  return ((ElementImpl *)impl)->getAttribute(ATTR_TARGET);
220 }
221 
223 {
224  if (impl) {
225  ((ElementImpl *)impl)->setAttribute(ATTR_TARGET, value);
226  }
227 }
228 
230 {
231  if (!impl) {
232  return DOMString();
233  }
234  return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE);
235 }
236 
238 {
239  if (impl) {
240  ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value);
241  }
242 }
243 
245 {
246  if (impl) {
247  ((HTMLAnchorElementImpl *)impl)->blur();
248  }
249 }
250 
252 {
253  if (impl) {
254  ((HTMLAnchorElementImpl *)impl)->focus();
255  }
256 }
257 
258 // --------------------------------------------------------------------------
259 
260 HTMLBRElement::HTMLBRElement() : HTMLElement()
261 {
262 }
263 
264 HTMLBRElement::HTMLBRElement(const HTMLBRElement &other) : HTMLElement(other)
265 {
266 }
267 
268 HTMLBRElement::HTMLBRElement(HTMLBRElementImpl *impl) : HTMLElement(impl)
269 {
270 }
271 
272 HTMLBRElement &HTMLBRElement::operator = (const Node &other)
273 {
274  assignOther(other, ID_BR);
275  return *this;
276 }
277 
278 HTMLBRElement &HTMLBRElement::operator = (const HTMLBRElement &other)
279 {
280  HTMLElement::operator = (other);
281  return *this;
282 }
283 
284 HTMLBRElement::~HTMLBRElement()
285 {
286 }
287 
289 {
290  if (!impl) {
291  return DOMString();
292  }
293  return ((ElementImpl *)impl)->getAttribute(ATTR_CLEAR);
294 }
295 
297 {
298  if (impl) {
299  ((ElementImpl *)impl)->setAttribute(ATTR_CLEAR, value);
300  }
301 }
302 
303 // --------------------------------------------------------------------------
304 
305 HTMLFontElement::HTMLFontElement() : HTMLElement()
306 {
307 }
308 
309 HTMLFontElement::HTMLFontElement(const HTMLFontElement &other) : HTMLElement(other)
310 {
311 }
312 
313 HTMLFontElement::HTMLFontElement(HTMLFontElementImpl *impl) : HTMLElement(impl)
314 {
315 }
316 
317 HTMLFontElement &HTMLFontElement::operator = (const Node &other)
318 {
319  assignOther(other, ID_FONT);
320  return *this;
321 }
322 
323 HTMLFontElement &HTMLFontElement::operator = (const HTMLFontElement &other)
324 {
325  HTMLElement::operator = (other);
326  return *this;
327 }
328 
329 HTMLFontElement::~HTMLFontElement()
330 {
331 }
332 
334 {
335  if (!impl) {
336  return DOMString();
337  }
338  return ((ElementImpl *)impl)->getAttribute(ATTR_COLOR);
339 }
340 
342 {
343  if (impl) {
344  ((ElementImpl *)impl)->setAttribute(ATTR_COLOR, value);
345  }
346 }
347 
349 {
350  if (!impl) {
351  return DOMString();
352  }
353  return ((ElementImpl *)impl)->getAttribute(ATTR_FACE);
354 }
355 
357 {
358  if (impl) {
359  ((ElementImpl *)impl)->setAttribute(ATTR_FACE, value);
360  }
361 }
362 
364 {
365  if (!impl) {
366  return DOMString();
367  }
368  return ((ElementImpl *)impl)->getAttribute(ATTR_SIZE);
369 }
370 
372 {
373  if (impl) {
374  ((ElementImpl *)impl)->setAttribute(ATTR_SIZE, value);
375  }
376 }
377 
378 // --------------------------------------------------------------------------
379 
380 HTMLModElement::HTMLModElement() : HTMLElement()
381 {
382 }
383 
384 HTMLModElement::HTMLModElement(const HTMLModElement &other) : HTMLElement(other)
385 {
386 }
387 
388 HTMLModElement::HTMLModElement(HTMLElementImpl *_impl)
389  : HTMLElement()
390 {
391  if (_impl && (_impl->id() == ID_INS || _impl->id() == ID_DEL)) {
392  impl = _impl;
393  } else {
394  impl = nullptr;
395  }
396  if (impl) {
397  impl->ref();
398  }
399 }
400 
401 HTMLModElement &HTMLModElement::operator = (const Node &other)
402 {
403  if (other.handle() != handle()) {
404  if (other.elementId() != ID_INS &&
405  other.elementId() != ID_DEL) {
406  if (impl) {
407  impl->deref();
408  }
409  impl = nullptr;
410  } else {
411  Node::operator = (other);
412  }
413  }
414  return *this;
415 }
416 
417 HTMLModElement &HTMLModElement::operator = (const HTMLModElement &other)
418 {
419  HTMLElement::operator = (other);
420  return *this;
421 }
422 
423 HTMLModElement::~HTMLModElement()
424 {
425 }
426 
428 {
429  if (!impl) {
430  return DOMString();
431  }
432  return ((ElementImpl *)impl)->getAttribute(ATTR_CITE);
433 }
434 
436 {
437  if (impl) {
438  ((ElementImpl *)impl)->setAttribute(ATTR_CITE, value);
439  }
440 }
441 
443 {
444  if (!impl) {
445  return DOMString();
446  }
447  return ((ElementImpl *)impl)->getAttribute(ATTR_DATETIME);
448 }
449 
451 {
452  if (impl) {
453  ((ElementImpl *)impl)->setAttribute(ATTR_DATETIME, value);
454  }
455 }
456 
457 // --------------------------------------------------------------------------
458 
459 HTMLQuoteElement::HTMLQuoteElement() : HTMLElement()
460 {
461 }
462 
463 HTMLQuoteElement::HTMLQuoteElement(const HTMLQuoteElement &other) : HTMLElement(other)
464 {
465 }
466 
467 HTMLQuoteElement::HTMLQuoteElement(HTMLGenericElementImpl *_impl)
468  : HTMLElement()
469 {
470  if (_impl && _impl->id() == ID_Q) {
471  impl = _impl;
472  } else {
473  impl = nullptr;
474  }
475  if (impl) {
476  impl->ref();
477  }
478 }
479 
480 HTMLQuoteElement &HTMLQuoteElement::operator = (const Node &other)
481 {
482  assignOther(other, ID_Q);
483  return *this;
484 }
485 
486 HTMLQuoteElement &HTMLQuoteElement::operator = (const HTMLQuoteElement &other)
487 {
488  HTMLElement::operator = (other);
489  return *this;
490 }
491 
492 HTMLQuoteElement::~HTMLQuoteElement()
493 {
494 }
495 
497 {
498  if (!impl) {
499  return DOMString();
500  }
501  return ((ElementImpl *)impl)->getAttribute(ATTR_CITE);
502 }
503 
505 {
506  if (impl) {
507  ((ElementImpl *)impl)->setAttribute(ATTR_CITE, value);
508  }
509 }
510 
Notice of modification to part of a document.
Definition: html_inline.h:369
DOMString rel() const
Forward link type.
void setName(const DOMString &)
see name
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:278
DOMString dateTime() const
The date and time of the change.
void setRel(const DOMString &)
see rel
DOMString target() const
Frame to render the resource in.
void setRev(const DOMString &)
see rev
DOMString rev() const
Reverse link type.
DOMString name() const
Anchor name.
void setType(const DOMString &)
see type
DOMString href() const
The URI of the linked resource.
DOMString cite() const
A URI designating a document that designates a source document or message.
void setHref(const DOMString &)
see href
long tabIndex() const
Index that represents the element&#39;s position in the tabbing order.
void setShape(const DOMString &)
see shape
For the Q and BLOCKQUOTE elements.
Definition: html_inline.h:427
DOMString hreflang() const
Language code of the linked resource.
DOMString face() const
Font face identifier.
DOMString clear() const
Control flow of text around floats.
QString number(int n, int base)
void setTarget(const DOMString &)
see target
void blur()
Removes keyboard focus from this element.
The anchor element.
Definition: html_inline.h:47
DOMString cite() const
A URI designating a document that describes the reason for the change.
DOMString accessKey() const
A single character access key to give access to the form control.
Definition: html_inline.cpp:62
void setCite(const DOMString &)
see cite
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
void setColor(const DOMString &)
see color
void setCite(const DOMString &)
see cite
void setCoords(const DOMString &)
see coords
DOMString size() const
Font size.
void setHreflang(const DOMString &)
see hreflang
DOMString coords() const
Comma-separated list of lengths, defining an active region geometry.
Definition: html_inline.cpp:92
void setSize(const DOMString &)
see size
void setClear(const DOMString &)
see clear
void setFace(const DOMString &)
see face
DOMString shape() const
The shape of the active area.
DOMString charset() const
The character encoding of the linked resource.
Definition: html_inline.cpp:77
This library provides a full-featured HTML parser and widget.
void setDateTime(const DOMString &)
see dateTime
DOMString type() const
Advisory content type.
DOMString getAttribute(const DOMString &name)
Retrieves an attribute value by name.
void setAccessKey(const DOMString &)
see accessKey
Definition: html_inline.cpp:70
void focus()
Gives keyboard focus to this element.
void setTabIndex(long)
see tabIndex
quint32 elementId() const
Definition: dom_node.cpp:509
DOMString color() const
Font color.
Local change to font.
Definition: html_inline.h:298
NodeImpl * handle() const
Definition: dom_node.h:936
void setCharset(const DOMString &)
see charset
Definition: html_inline.cpp:85
All HTML element interfaces derive from this class.
Definition: html_element.h:70
DOMString trimSpaces() const
Returns a string with Space Characters removed from the start and the end.
Definition: dom_string.cpp:345
Force a line break.
Definition: html_inline.h:253
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Oct 24 2021 22:48:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.