• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 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
27using namespace DOM;
28
29HTMLElement::HTMLElement() : Element()
30{
31}
32
33HTMLElement::HTMLElement(const HTMLElement &other) : Element(other)
34{
35}
36
37HTMLElement::HTMLElement(HTMLElementImpl *impl) : Element(impl)
38{
39}
40
41HTMLElement &HTMLElement::operator = (const HTMLElement &other)
42{
43 Element::operator = (other);
44 return *this;
45}
46
47HTMLElement &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
59HTMLElement::~HTMLElement()
60{
61}
62
63DOMString HTMLElement::id() const
64{
65 if(!impl) return DOMString();
66 return ((ElementImpl *)impl)->getAttribute(ATTR_ID);
67}
68
69void HTMLElement::setId( const DOMString &value )
70{
71 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ID, value);
72}
73
74DOMString HTMLElement::title() const
75{
76 if(!impl) return DOMString();
77 return ((ElementImpl *)impl)->getAttribute(ATTR_TITLE);
78}
79
80void HTMLElement::setTitle( const DOMString &value )
81{
82 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TITLE, value);
83}
84
85DOMString HTMLElement::lang() const
86{
87 if(!impl) return DOMString();
88 return ((ElementImpl *)impl)->getAttribute(ATTR_LANG);
89}
90
91void HTMLElement::setLang( const DOMString &value )
92{
93 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_LANG, value);
94}
95
96DOMString HTMLElement::dir() const
97{
98 if(!impl) return DOMString();
99 return ((ElementImpl *)impl)->getAttribute(ATTR_DIR);
100}
101
102void HTMLElement::setDir( const DOMString &value )
103{
104 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_DIR, value);
105}
106
107DOMString HTMLElement::className() const
108{
109 if(!impl) return DOMString();
110 return ((ElementImpl *)impl)->getAttribute(ATTR_CLASS);
111}
112
113void HTMLElement::setClassName( const DOMString &value )
114{
115 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CLASS, value);
116}
117
118void 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
125void 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
132DOMString HTMLElement::innerHTML() const
133{
134 if ( !impl ) return DOMString();
135 return ((HTMLElementImpl *)impl)->innerHTML();
136}
137
138void 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
148DOMString HTMLElement::innerText() const
149{
150 if ( !impl ) return DOMString();
151 return ((HTMLElementImpl *)impl)->innerText();
152}
153
154void 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
164HTMLCollection HTMLElement::children() const
165{
166 if(!impl) return HTMLCollection();
167 return HTMLCollection(impl, HTMLCollectionImpl::NODE_CHILDREN);
168}
169
170HTMLCollection 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
176void 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
186bool HTMLElement::isContentEditable() const
187{
188 if(!impl) return false;
189 return static_cast<HTMLElementImpl *>(impl)->isContentEditable();
190}
191
192DOMString HTMLElement::contentEditable() const {
193 if(!impl) return "inherit";
194 return static_cast<HTMLElementImpl *>(impl)->contentEditable();
195}
196
197void HTMLElement::setContentEditable(const DOMString &enabled) {
198 if(!impl)
199 throw DOMException(DOMException::INVALID_STATE_ERR);
200 static_cast<HTMLElementImpl *>(impl)->setContentEditable(enabled);
201}
DOM::DOMException
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:59
DOM::DOMException::INVALID_STATE_ERR
@ INVALID_STATE_ERR
Definition: dom_exception.h:83
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
DOM::DOMString::length
uint length() const
Definition: dom_string.cpp:185
DOM::DOMString::string
QString string() const
Definition: dom_string.cpp:236
DOM::Element
By far the vast majority of objects (apart from text) that authors encounter when traversing a docume...
Definition: dom_element.h:210
DOM::Element::operator=
Element & operator=(const Node &other)
Definition: dom_element.cpp:117
DOM::HTMLCollection
An HTMLCollection is a list of nodes.
Definition: html_misc.h:131
DOM::HTMLElement
All HTML element interfaces derive from this class.
Definition: html_element.h:70
DOM::HTMLElement::isContentEditable
bool isContentEditable() const
Returns whether this element is editable.
Definition: html_element.cpp:186
DOM::HTMLElement::setLang
void setLang(const DOMString &)
see lang
Definition: html_element.cpp:91
DOM::HTMLElement::id
DOMString id() const
The element's identifier.
Definition: html_element.cpp:63
DOM::HTMLElement::innerText
DOMString innerText() const
The text contained in this element.
Definition: html_element.cpp:148
DOM::HTMLElement::~HTMLElement
~HTMLElement()
Definition: html_element.cpp:59
DOM::HTMLElement::setId
void setId(const DOMString &)
see id
Definition: html_element.cpp:69
DOM::HTMLElement::setInnerHTML
void setInnerHTML(const DOMString &html)
Set the HTML content of this node.
Definition: html_element.cpp:138
DOM::HTMLElement::addCSSProperty
void addCSSProperty(const DOMString &property, const DOMString &value)
Definition: html_element.cpp:125
DOM::HTMLElement::assignOther
void assignOther(const Node &other, int elementId)
Definition: html_element.cpp:176
DOM::HTMLElement::className
DOMString className() const
The class attribute of the element.
Definition: html_element.cpp:107
DOM::HTMLElement::operator=
HTMLElement & operator=(const HTMLElement &other)
Definition: html_element.cpp:41
DOM::HTMLElement::setClassName
void setClassName(const DOMString &)
see className
Definition: html_element.cpp:113
DOM::HTMLElement::contentEditable
DOMString contentEditable() const
Returns the kind of editability that applies to this element.
Definition: html_element.cpp:192
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::HTMLElement::setContentEditable
void setContentEditable(const DOMString &enabled)
Sets the editability of this element.
Definition: html_element.cpp:197
DOM::HTMLElement::lang
DOMString lang() const
Language code defined in RFC 1766.
Definition: html_element.cpp:85
DOM::HTMLElement::removeCSSProperty
void removeCSSProperty(const DOMString &property)
Definition: html_element.cpp:118
DOM::HTMLElement::all
HTMLCollection all() const
Retrieves a collection of all nodes that descend from this node.
Definition: html_element.cpp:170
DOM::HTMLElement::HTMLElement
HTMLElement()
Definition: html_element.cpp:29
DOM::HTMLElement::setInnerText
void setInnerText(const DOMString &text)
Set the text content of this node.
Definition: html_element.cpp:154
DOM::HTMLElement::title
DOMString title() const
The element's advisory title.
Definition: html_element.cpp:74
DOM::HTMLElement::setTitle
void setTitle(const DOMString &)
see title
Definition: html_element.cpp:80
DOM::HTMLElement::setDir
void setDir(const DOMString &)
see dir
Definition: html_element.cpp:102
DOM::HTMLElement::children
HTMLCollection children() const
Retrieves a collection of nodes that are direct descendants of this node.
Definition: html_element.cpp:164
DOM::HTMLElement::innerHTML
DOMString innerHTML() const
The HTML code contained in this element.
Definition: html_element.cpp:132
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:271
DOM::Node::handle
NodeImpl * handle() const
Definition: dom_node.h:925
DOM::Node::operator=
Node & operator=(const Node &other)
Definition: dom_node.cpp:145
DOM::Node::impl
NodeImpl * impl
Definition: dom_node.h:948
DOM::Node::elementId
quint32 elementId() const
Definition: dom_node.cpp:400
dom_exception.h
html_misc.h
DOM
This library provides a full-featured HTML parser and widget.
Definition: design.h:55
DOM::enabled
static bool enabled(KHTMLPart *)
Definition: jsediting.cpp:383
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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.14.38 API Reference

Skip menu "kdelibs-4.14.38 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