html_element.cpp
#include "dom/dom_exception.h"
#include "dom/html_misc.h"
#include "css/css_base.h"
#include "html/html_miscimpl.h" // HTMLCollectionImpl
#include "misc/htmlhashes.h"
using namespace DOM;
HTMLElement::HTMLElement() : Element()
{
}
HTMLElement::HTMLElement(const HTMLElement &other) : Element(other)
{
}
HTMLElement::HTMLElement(HTMLElementImpl *impl) : Element(impl)
{
}
HTMLElement &HTMLElement::operator = (const HTMLElement &other)
{
Element::operator = (other);
return *this;
}
HTMLElement &HTMLElement::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
if (!ohandle || !ohandle->isHTMLElement()) {
if (impl) impl->deref();
impl = 0;
return *this;
}
Node::operator = (other);
return *this;
}
HTMLElement::~HTMLElement()
{
}
DOMString HTMLElement::id() const
{
if(!impl) return DOMString();
return ((ElementImpl *)impl)->getAttribute(ATTR_ID);
}
void HTMLElement::setId( const DOMString &value )
{
if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ID, value);
}
DOMString HTMLElement::title() const
{
if(!impl) return DOMString();
return ((ElementImpl *)impl)->getAttribute(ATTR_TITLE);
}
void HTMLElement::setTitle( const DOMString &value )
{
if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TITLE, value);
}
DOMString HTMLElement::lang() const
{
if(!impl) return DOMString();
return ((ElementImpl *)impl)->getAttribute(ATTR_LANG);
}
void HTMLElement::setLang( const DOMString &value )
{
if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_LANG, value);
}
DOMString HTMLElement::dir() const
{
if(!impl) return DOMString();
return ((ElementImpl *)impl)->getAttribute(ATTR_DIR);
}
void HTMLElement::setDir( const DOMString &value )
{
if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_DIR, value);
}
DOMString HTMLElement::className() const
{
if(!impl) return DOMString();
return ((ElementImpl *)impl)->getAttribute(ATTR_CLASS);
}
void HTMLElement::setClassName( const DOMString &value )
{
if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CLASS, value);
}
void HTMLElement::removeCSSProperty( const DOMString &property )
{
int id = getPropertyID(property.string().lower().ascii(), property.length());
if(id && impl)
static_cast<HTMLElementImpl*>(impl)->removeCSSProperty(id);
}
void HTMLElement::addCSSProperty( const DOMString &property, const DOMString &value )
{
int id = getPropertyID(property.string().lower().ascii(), property.length());
if(id && impl)
static_cast<HTMLElementImpl*>(impl)->addCSSProperty(id, value);
}
DOMString HTMLElement::innerHTML() const
{
if ( !impl ) return DOMString();
return ((HTMLElementImpl *)impl)->innerHTML();
}
void HTMLElement::setInnerHTML( const DOMString &html )
{
if( !impl )
return;
int exceptioncode = 0;
((HTMLElementImpl *)impl)->setInnerHTML( html, exceptioncode );
if ( exceptioncode )
throw DOMException( exceptioncode );
}
DOMString HTMLElement::innerText() const
{
if ( !impl ) return DOMString();
return ((HTMLElementImpl *)impl)->innerText();
}
void HTMLElement::setInnerText( const DOMString &text )
{
if( !impl )
return;
int exceptioncode = 0;
((HTMLElementImpl *)impl)->setInnerText( text, exceptioncode );
if ( exceptioncode )
throw DOMException( exceptioncode );
}
HTMLCollection HTMLElement::children() const
{
if(!impl) return HTMLCollection();
return HTMLCollection(impl, HTMLCollectionImpl::NODE_CHILDREN);
}
HTMLCollection HTMLElement::all() const
{
if(!impl) return HTMLCollection();
return HTMLCollection(impl, HTMLCollectionImpl::DOC_ALL /*it's called "doc" but it works from any node */);
}
void HTMLElement::assignOther( const Node &other, int elementId )
{
if (other.elementId() != static_cast<Q_UINT32>(elementId)) {
if ( impl ) impl->deref();
impl = 0;
} else {
Node::operator = (other);
}
}
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:274
DOM::HTMLElement::lang
DOMString lang() const
Language code defined in RFC 1766.
Definition: html_element.cpp:87
DOM::HTMLElement::setTitle
void setTitle(const DOMString &)
see title
Definition: html_element.cpp:82
DOM::HTMLElement::setClassName
void setClassName(const DOMString &)
see className
Definition: html_element.cpp:115
DOM::HTMLElement::dir
DOMString dir() const
Specifies the base direction of directionally neutral text and the directionality of tables...
Definition: html_element.cpp:98
DOM::HTMLElement::innerText
DOMString innerText() const
The text contained in this element.
Definition: html_element.cpp:150
DOM::HTMLElement::setInnerText
void setInnerText(const DOMString &text)
Set the text content of this node.
Definition: html_element.cpp:156
DOM::HTMLElement::innerHTML
DOMString innerHTML() const
The HTML code contained in this element.
Definition: html_element.cpp:134
DOM::DOMException
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:57
DOM::HTMLElement::setId
void setId(const DOMString &)
see id
Definition: html_element.cpp:71
DOM::HTMLElement::setDir
void setDir(const DOMString &)
see dir
Definition: html_element.cpp:104
DOM::HTMLCollection
An HTMLCollection is a list of nodes.
Definition: html_misc.h:126
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::HTMLElement::setInnerHTML
void setInnerHTML(const DOMString &html)
Set the HTML content of this node.
Definition: html_element.cpp:140
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:43
DOM::HTMLElement::all
HTMLCollection all() const
Retrieves a collection of all nodes that descend from this node.
Definition: html_element.cpp:172
DOM::HTMLElement::id
DOMString id() const
The element's identifier.
Definition: html_element.cpp:65
DOM::HTMLElement::setLang
void setLang(const DOMString &)
see lang
Definition: html_element.cpp:93
DOM::HTMLElement::className
DOMString className() const
The class attribute of the element.
Definition: html_element.cpp:109
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:76
DOM::HTMLElement::children
HTMLCollection children() const
Retrieves a collection of nodes that are direct descendants of this node.
Definition: html_element.cpp:166

KDE Home | KDE Accessibility Home | Description of Access Keys