html_element.cpp Source File (khtml Library)

| # khtml Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# html_element.cpp

    00001
    00023 #include "dom/dom_exception.h"
    00024 #include "dom/html_misc.h"
    00025 #include "css/cssparser.h"
    00026 #include "html/html_miscimpl.h" // HTMLCollectionImpl
    00027
    00028 #include "misc/htmlhashes.h"
    00029
    00030 using namespace DOM;
    00031
    00032 HTMLElement::HTMLElement() : Element()
    00033 {
    00034 }
    00035
    00036 HTMLElement::HTMLElement(const HTMLElement &other) : Element(other)
    00037 {
    00038 }
    00039
    00040 HTMLElement::HTMLElement(HTMLElementImpl *impl) : Element(impl)
    00041 {
    00042 }
    00043
    00044 HTMLElement &HTMLElement::operator = (const HTMLElement &other)
    00045 {
    00046     Element::operator = (other);
    00047     return *this;
    00048 }
    00049
    00050 HTMLElement &HTMLElement::operator = (const Node &other)
    00051 {
    00052     NodeImpl* ohandle = other.handle();
    00053     if (!ohandle || !ohandle->isHTMLElement()) {
    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 kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:33:50 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001