• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.10.3 API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • khtml
  • dom
html_element.cpp
Go to the documentation of this file.
1 
22 #include "dom/dom_exception.h"
23 #include "dom/html_misc.h"
24 #include "css/css_base.h"
25 #include "html/html_miscimpl.h" // HTMLCollectionImpl
26 
27 using namespace DOM;
28 
29 HTMLElement::HTMLElement() : Element()
30 {
31 }
32 
33 HTMLElement::HTMLElement(const HTMLElement &other) : Element(other)
34 {
35 }
36 
37 HTMLElement::HTMLElement(HTMLElementImpl *impl) : Element(impl)
38 {
39 }
40 
41 HTMLElement &HTMLElement::operator = (const HTMLElement &other)
42 {
43  Element::operator = (other);
44  return *this;
45 }
46 
47 HTMLElement &HTMLElement::operator = (const Node &other)
48 {
49  NodeImpl* ohandle = other.handle();
50  if (!ohandle || !ohandle->isHTMLElement()) {
51  if (impl) impl->deref();
52  impl = 0;
53  return *this;
54  }
55  Node::operator = (other);
56  return *this;
57 }
58 
59 HTMLElement::~HTMLElement()
60 {
61 }
62 
63 DOMString HTMLElement::id() const
64 {
65  if(!impl) return DOMString();
66  return ((ElementImpl *)impl)->getAttribute(ATTR_ID);
67 }
68 
69 void HTMLElement::setId( const DOMString &value )
70 {
71  if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ID, value);
72 }
73 
74 DOMString HTMLElement::title() const
75 {
76  if(!impl) return DOMString();
77  return ((ElementImpl *)impl)->getAttribute(ATTR_TITLE);
78 }
79 
80 void HTMLElement::setTitle( const DOMString &value )
81 {
82  if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TITLE, value);
83 }
84 
85 DOMString HTMLElement::lang() const
86 {
87  if(!impl) return DOMString();
88  return ((ElementImpl *)impl)->getAttribute(ATTR_LANG);
89 }
90 
91 void HTMLElement::setLang( const DOMString &value )
92 {
93  if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_LANG, value);
94 }
95 
96 DOMString HTMLElement::dir() const
97 {
98  if(!impl) return DOMString();
99  return ((ElementImpl *)impl)->getAttribute(ATTR_DIR);
100 }
101 
102 void HTMLElement::setDir( const DOMString &value )
103 {
104  if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_DIR, value);
105 }
106 
107 DOMString HTMLElement::className() const
108 {
109  if(!impl) return DOMString();
110  return ((ElementImpl *)impl)->getAttribute(ATTR_CLASS);
111 }
112 
113 void HTMLElement::setClassName( const DOMString &value )
114 {
115  if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CLASS, value);
116 }
117 
118 void HTMLElement::removeCSSProperty( const DOMString &property )
119 {
120  int id = getPropertyID(property.string().toLower().toLatin1().constData(), property.length());
121  if(id && impl)
122  static_cast<HTMLElementImpl*>(impl)->removeCSSProperty(id);
123 }
124 
125 void HTMLElement::addCSSProperty( const DOMString &property, const DOMString &value )
126 {
127  int id = getPropertyID(property.string().toLower().toLatin1().constData(), property.length());
128  if(id && impl)
129  static_cast<HTMLElementImpl*>(impl)->addCSSProperty(id, value);
130 }
131 
132 DOMString HTMLElement::innerHTML() const
133 {
134  if ( !impl ) return DOMString();
135  return ((HTMLElementImpl *)impl)->innerHTML();
136 }
137 
138 void HTMLElement::setInnerHTML( const DOMString &html )
139 {
140  if( !impl )
141  return;
142  int exceptioncode = 0;
143  ((HTMLElementImpl *)impl)->setInnerHTML( html, exceptioncode );
144  if ( exceptioncode )
145  throw DOMException( exceptioncode );
146 }
147 
148 DOMString HTMLElement::innerText() const
149 {
150  if ( !impl ) return DOMString();
151  return ((HTMLElementImpl *)impl)->innerText();
152 }
153 
154 void HTMLElement::setInnerText( const DOMString &text )
155 {
156  if( !impl )
157  return;
158  int exceptioncode = 0;
159  ((HTMLElementImpl *)impl)->setInnerText( text, exceptioncode );
160  if ( exceptioncode )
161  throw DOMException( exceptioncode );
162 }
163 
164 HTMLCollection HTMLElement::children() const
165 {
166  if(!impl) return HTMLCollection();
167  return HTMLCollection(impl, HTMLCollectionImpl::NODE_CHILDREN);
168 }
169 
170 HTMLCollection HTMLElement::all() const
171 {
172  if(!impl) return HTMLCollection();
173  return HTMLCollection(impl, HTMLCollectionImpl::DOC_ALL /*it's called "doc" but it works from any node */);
174 }
175 
176 void HTMLElement::assignOther( const Node &other, int elementId )
177 {
178  if (other.elementId() != static_cast<quint32>(elementId)) {
179  if ( impl ) impl->deref();
180  impl = 0;
181  } else {
182  Node::operator = (other);
183  }
184 }
185 
186 bool HTMLElement::isContentEditable() const
187 {
188  if(!impl) return false;
189  return static_cast<HTMLElementImpl *>(impl)->isContentEditable();
190 }
191 
192 DOMString HTMLElement::contentEditable() const {
193  if(!impl) return "inherit";
194  return static_cast<HTMLElementImpl *>(impl)->contentEditable();
195 }
196 
197 void HTMLElement::setContentEditable(const DOMString &enabled) {
198  if(!impl)
199  throw DOMException(DOMException::INVALID_STATE_ERR);
200  static_cast<HTMLElementImpl *>(impl)->setContentEditable(enabled);
201 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat May 18 2013 11:43:19 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.10.3 API Reference

Skip menu "kdelibs-4.10.3 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal