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

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • 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 }
DOM::HTMLElement::setContentEditable
void setContentEditable(const DOMString &enabled)
Sets the editability of this element.
Definition: html_element.cpp:197
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:270
DOM::HTMLElement::lang
DOMString lang() const
Language code defined in RFC 1766.
Definition: html_element.cpp:85
DOM::HTMLElement::setTitle
void setTitle(const DOMString &)
see title
Definition: html_element.cpp:80
DOM::HTMLElement::setClassName
void setClassName(const DOMString &)
see className
Definition: html_element.cpp:113
DOM::DOMString::string
QString string() const
Definition: dom_string.cpp:236
quint32
DOM::HTMLElement::dir
DOMString dir() const
Specifies the base direction of directionally neutral text and the directionality of tables...
Definition: html_element.cpp:96
DOM::Node::operator=
Node & operator=(const Node &other)
Definition: dom_node.cpp:145
DOM::HTMLElement::innerText
DOMString innerText() const
The text contained in this element.
Definition: html_element.cpp:148
DOM::HTMLElement::setInnerText
void setInnerText(const DOMString &text)
Set the text content of this node.
Definition: html_element.cpp:154
DOM::HTMLElement::innerHTML
DOMString innerHTML() const
The HTML code contained in this element.
Definition: html_element.cpp:132
DOM::DOMException
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:58
DOM::HTMLElement::setId
void setId(const DOMString &)
see id
Definition: html_element.cpp:69
DOM::HTMLElement::setDir
void setDir(const DOMString &)
see dir
Definition: html_element.cpp:102
DOM::HTMLCollection
An HTMLCollection is a list of nodes.
Definition: html_misc.h:130
DOM::Element
By far the vast majority of objects (apart from text) that authors encounter when traversing a docume...
Definition: dom_element.h:209
DOM::HTMLElement::addCSSProperty
void addCSSProperty(const DOMString &property, const DOMString &value)
Definition: html_element.cpp:125
DOM::Element::operator=
Element & operator=(const Node &other)
Definition: dom_element.cpp:117
DOM::HTMLElement::setInnerHTML
void setInnerHTML(const DOMString &html)
Set the HTML content of this node.
Definition: html_element.cpp:138
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:43
dom_exception.h
DOM::HTMLElement::all
HTMLCollection all() const
Retrieves a collection of all nodes that descend from this node.
Definition: html_element.cpp:170
DOM::HTMLElement::id
DOMString id() const
The element's identifier.
Definition: html_element.cpp:63
DOM::Node::impl
NodeImpl * impl
Definition: dom_node.h:948
DOM::HTMLElement::operator=
HTMLElement & operator=(const HTMLElement &other)
Definition: html_element.cpp:41
DOM::HTMLElement::~HTMLElement
~HTMLElement()
Definition: html_element.cpp:59
DOM::HTMLElement::contentEditable
DOMString contentEditable() const
Returns the kind of editability that applies to this element.
Definition: html_element.cpp:192
html_misc.h
DOM::Node::HTMLCollection
friend class HTMLCollection
Definition: dom_node.h:274
DOM::HTMLElement::assignOther
void assignOther(const Node &other, int elementId)
Definition: html_element.cpp:176
DOM::Node::elementId
quint32 elementId() const
Definition: dom_node.cpp:400
DOM::DOMException::INVALID_STATE_ERR
Definition: dom_exception.h:83
DOM::Node::handle
NodeImpl * handle() const
Definition: dom_node.h:925
DOM::HTMLElement::removeCSSProperty
void removeCSSProperty(const DOMString &property)
Definition: html_element.cpp:118
DOM::HTMLElement::setLang
void setLang(const DOMString &)
see lang
Definition: html_element.cpp:91
DOM::enabled
static bool enabled(KHTMLPart *)
Definition: jsediting.cpp:383
DOM::HTMLElement::HTMLElement
HTMLElement()
Definition: html_element.cpp:29
DOM::HTMLElement::className
DOMString className() const
The class attribute of the element.
Definition: html_element.cpp:107
DOM::HTMLElement
All HTML element interfaces derive from this class.
Definition: html_element.h:69
DOM::HTMLElement::title
DOMString title() const
The element's advisory title.
Definition: html_element.cpp:74
DOM::HTMLElement::isContentEditable
bool isContentEditable() const
Returns whether this element is editable.
Definition: html_element.cpp:186
DOM::HTMLElement::children
HTMLCollection children() const
Retrieves a collection of nodes that are direct descendants of this node.
Definition: html_element.cpp:164
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:20 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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