# khtml Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# html_element.cpp

    00001
    00022 #include "dom/dom_exception.h"
    00023 #include "dom/html_misc.h"
    00024 #include "css/css_base.h"
    00025 #include "html/html_miscimpl.h" // HTMLCollectionImpl
    00026
    00027 #include "misc/htmlhashes.h"
    00028
    00029 using namespace DOM;
    00030
    00031 HTMLElement::HTMLElement() : Element()
    00032 {
    00033 }
    00034
    00035 HTMLElement::HTMLElement(const HTMLElement &other) : Element(other)
    00036 {
    00037 }
    00038
    00039 HTMLElement::HTMLElement(HTMLElementImpl *impl) : Element(impl)
    00040 {
    00041 }
    00042
    00043 HTMLElement &HTMLElement::operator = (const HTMLElement &other)
    00044 {
    00045     Element::operator = (other);
    00046     return *this;
    00047 }
    00048
    00049 HTMLElement &HTMLElement::operator = (const Node &other)
    00050 {
    00051     NodeImpl* ohandle = other.handle();
    00052     if (!ohandle || !ohandle->isHTMLElement()) {
    00053         if (impl) impl->deref();
    00054     impl = 0;
    00055     return *this;
    00056     }
    00057     Node::operator = (other);
    00058     return *this;
    00059 }
    00060
    00061 HTMLElement::~HTMLElement()
    00062 {
    00063 }
    00064
    00065 DOMString HTMLElement::id() const
    00066 {
    00067     if(!impl) return DOMString();
    00068     return ((ElementImpl *)impl)->getAttribute(ATTR_ID);
    00069 }
    00070
    00071 void HTMLElement::setId( const DOMString &value )
    00072 {
    00073     if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ID, value);
    00074 }
    00075
    00076 DOMString HTMLElement::title() const
    00077 {
    00078     if(!impl) return DOMString();
    00079     return ((ElementImpl *)impl)->getAttribute(ATTR_TITLE);
    00080 }
    00081
    00082 void HTMLElement::setTitle( const DOMString &value )
    00083 {
    00084     if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TITLE, value);
    00085 }
    00086
    00087 DOMString HTMLElement::lang() const
    00088 {
    00089     if(!impl) return DOMString();
    00090     return ((ElementImpl *)impl)->getAttribute(ATTR_LANG);
    00091 }
    00092
    00093 void HTMLElement::setLang( const DOMString &value )
    00094 {
    00095     if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_LANG, value);
    00096 }
    00097
    00098 DOMString HTMLElement::dir() const
    00099 {
    00100     if(!impl) return DOMString();
    00101     return ((ElementImpl *)impl)->getAttribute(ATTR_DIR);
    00102 }
    00103
    00104 void HTMLElement::setDir( const DOMString &value )
    00105 {
    00106     if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_DIR, value);
    00107 }
    00108
    00109 DOMString HTMLElement::className() const
    00110 {
    00111     if(!impl) return DOMString();
    00112     return ((ElementImpl *)impl)->getAttribute(ATTR_CLASS);
    00113 }
    00114
    00115 void HTMLElement::setClassName( const DOMString &value )
    00116 {
    00117     if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CLASS, value);
    00118 }
    00119
    00120 void HTMLElement::removeCSSProperty( const DOMString &property )
    00121 {
    00122     int id = getPropertyID(property.string().lower().ascii(), property.length());
    00123     if(id && impl)
    00124         static_cast<HTMLElementImpl*>(impl)->removeCSSProperty(id);
    00125 }
    00126
    00127 void HTMLElement::addCSSProperty( const DOMString &property, const DOMString &value )
    00128 {
    00129     int id = getPropertyID(property.string().lower().ascii(), property.length());
    00130     if(id && impl)
    00131         static_cast<HTMLElementImpl*>(impl)->addCSSProperty(id, value);
    00132 }
    00133
    00134 DOMString HTMLElement::innerHTML() const
    00135 {
    00136     if ( !impl ) return DOMString();
    00137     return ((HTMLElementImpl *)impl)->innerHTML();
    00138 }
    00139
    00140 void HTMLElement::setInnerHTML( const DOMString &html )
    00141 {
    00142     bool ok = false;
    00143     if( impl )
    00144     ok = ((HTMLElementImpl *)impl)->setInnerHTML( html );
    00145     if ( !ok )
    00146     throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);
    00147 }
    00148
    00149 DOMString HTMLElement::innerText() const
    00150 {
    00151     if ( !impl ) return DOMString();
    00152     return ((HTMLElementImpl *)impl)->innerText();
    00153 }
    00154
    00155 void HTMLElement::setInnerText( const DOMString &text )
    00156 {
    00157     bool ok = false;
    00158     if( impl )
    00159     ok = ((HTMLElementImpl *)impl)->setInnerText( text );
    00160     if ( !ok )
    00161     throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);
    00162 }
    00163
    00164 HTMLCollection HTMLElement::children() const
    00165 {
    00166     if(!impl) return HTMLCollection();
    00167     return HTMLCollection(impl, HTMLCollectionImpl::NODE_CHILDREN);
    00168 }
    00169
    00170 HTMLCollection HTMLElement::all() const
    00171 {
    00172     if(!impl) return HTMLCollection();
    00173     return HTMLCollection(impl, HTMLCollectionImpl::DOC_ALL /*it's called "doc" but it works from any node */);
    00174 }
    00175
    00176 void HTMLElement::assignOther( const Node &other, int elementId )
    00177 {
    00178     if (other.elementId() != static_cast<Q_UINT32>(elementId)) {
    00179     if ( impl ) impl->deref();
    00180     impl = 0;
    00181     } else {
    00182     Node::operator = (other);
    00183     }
    00184 }

This file is part of the documentation for khtml Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:33:10 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003