23#include "dom/dom_exception.h"
24#include "xml/dom_docimpl.h"
25#include "xml/dom_elementimpl.h"
26#include "html/html_formimpl.h"
34Attr::Attr(
const Attr &other) :
Node(other)
38Attr::Attr( AttrImpl *_impl )
41 if (impl) impl->ref();
44Attr &Attr::operator = (
const Node &other)
46 NodeImpl* ohandle = other.handle();
47 if ( impl != ohandle ) {
48 if (!ohandle || !ohandle->isAttributeNode()) {
49 if (impl) impl->deref();
52 Node::operator =(other);
58Attr &Attr::operator = (
const Attr &other)
60 Node::operator =(other);
70 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
71 return ((AttrImpl *)impl)->name();
76 if (impl)
return ((AttrImpl *)impl)->specified();
88 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
89 return impl->nodeValue();
97 int exceptioncode = 0;
98 ((AttrImpl *)impl)->setValue(newValue,exceptioncode);
105Element::Element() :
Node()
109Element::Element(
const Element &other) :
Node(other)
113Element::Element(ElementImpl *impl) :
Node(impl)
119 NodeImpl* ohandle = other.handle();
120 if ( impl != ohandle ) {
121 if (!ohandle || !ohandle->isElementNode()) {
122 if (impl) impl->deref();
125 Node::operator =(other);
133 Node::operator =(other);
143 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
144 return static_cast<ElementImpl*
>(impl)->
tagName();
152 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
153 if (!name.implementation())
throw DOMException(DOMException::NOT_FOUND_ERR);
155 NodeImpl::Id
id = impl->getDocument()->getId(NodeImpl::AttributeId,name.implementation(),
true,
true);
158 ElementImpl* e =
static_cast<ElementImpl*
>(impl);
159 return e->getAttribute(
id,
false, name);
164 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
165 int exceptioncode = 0;
166 NodeImpl::Id
id = impl->getDocument()->getId(NodeImpl::AttributeId, name.implementation(),
false ,
167 true, &exceptioncode);
169 static_cast<ElementImpl*
>(impl)->
setAttribute(
id, value, name, exceptioncode);
176 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
177 NodeImpl::Id
id = impl->getDocument()->getId(NodeImpl::AttributeId, name.implementation(),
true,
true);
180 int exceptioncode = 0;
182 attributes->removeNamedItem(
id,
false, name.implementation(), exceptioncode);
184 if ( exceptioncode && exceptioncode != DOMException::NOT_FOUND_ERR )
190 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
191 if (!name.implementation())
throw DOMException(DOMException::NOT_FOUND_ERR);
192 NodeImpl::Id
id = impl->getDocument()->getId(NodeImpl::AttributeId, name.implementation(),
true,
true);
195 ElementImpl* e =
static_cast<ElementImpl*
>(impl);
196 if (!e->attributes())
return 0;
198 return static_cast<AttrImpl*
>(e->attributes()->getNamedItem(
id,
false, name.implementation()));
203 if (!impl || newAttr.
isNull())
207 int exceptioncode = 0;
209 newAttr.handle()->nodeName().implementation(), exceptioncode);
212 static_cast<AttrImpl *
>(newAttr.handle())->setOwnerElement(
static_cast<ElementImpl*
>(impl) );
221 if (impl->isReadOnly())
222 throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);
224 if (!
static_cast<ElementImpl*
>(impl)->
attributes(
true))
228 return attributes->removeAttr(
static_cast<AttrImpl*
>(
static_cast<AttrImpl*
>(oldAttr.handle())));
238 id = impl->getDocument()->getId(NodeImpl::ElementId,
tagName.implementation(),
false,
true);
239 return new TagNodeListImpl( impl,
id );
252 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
254 NodeImpl::Id
id = impl->getDocument()->getId(NodeImpl::AttributeId,
namespaceURI.implementation(), 0,
localName.implementation(),
true,
true);
255 ElementImpl* e =
static_cast<ElementImpl*
>(impl);
256 return e->getAttribute(
id,
true);
263 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
265 int exceptioncode = 0;
274 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
276 int exceptioncode = 0;
278 NodeImpl::Id
id = impl->getDocument()->getId(NodeImpl::AttributeId,
namespaceURI.implementation(), 0,
localName.implementation(),
false,
true);
279 attributes->removeNamedItem(
id,
true, 0, exceptioncode);
287 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
289 NodeImpl::Id
id = impl->getDocument()->getId(NodeImpl::AttributeId,
namespaceURI.implementation(),
290 0,
localName.implementation(),
true,
true);
291 ElementImpl* e =
static_cast<ElementImpl*
>(impl);
292 if (!e->attributes())
return 0;
294 return static_cast<AttrImpl*
>(e->attributes()->getNamedItem(
id,
true));
299 if (!impl || newAttr.
isNull())
303 int exceptioncode = 0;
304 Attr r =
static_cast<ElementImpl*
>(impl)->
attributes(
false)->
setNamedItem(newAttr.handle(),
true, 0, exceptioncode);
307 static_cast<AttrImpl *
>(newAttr.handle())->setOwnerElement(
static_cast<ElementImpl*
>(impl) );
314 if (!impl || !
static_cast<ElementImpl*
>(impl)->
attributes())
return false;
315 NodeImpl::Id
id = impl->getDocument()->getId(NodeImpl::AttributeId, name.implementation(),
true,
true);
316 if (!
id)
return false;
318 if (!
static_cast<ElementImpl*
>(impl)->
attributes(
true ))
return false;
319 return static_cast<ElementImpl*
>(impl)->
attributes(
true)->getValue(
id,
false, name.implementation()) != 0;
325 if (!impl || !
static_cast<ElementImpl*
>(impl)->
attributes())
return false;
326 if (!
static_cast<ElementImpl*
>(impl)->
attributes(
true ))
return false;
327 NodeImpl::Id
id = impl->getDocument()->getId(NodeImpl::AttributeId,
namespaceURI.implementation(),
328 0,
localName.implementation(),
true,
true);
329 return static_cast<ElementImpl*
>(impl)->
attributes(
true)->getValue(
id,
true) != 0;
332bool Element::isHTMLElement()
const
334 if(!impl)
return false;
335 return ((ElementImpl *)impl)->isHTMLElement();
340 if (!impl || !impl->isGenericFormElement())
return 0;
341 return static_cast<HTMLGenericFormElementImpl*
>(impl)->
form();
342 ElementImpl* f =
static_cast<HTMLGenericFormElementImpl*
>( impl )->
form();
344 if( f && f->implicitNode() )
351 if (impl)
return ((ElementImpl *)impl)->styleRules();
356 if(!impl)
return false;
367bool Element::tdehtmlValidAttrName(
const DOMString &name)
371 DOMStringImpl* _name = name.implementation();
372 TQChar ch = _name->s[0];
373 if ( !ch.isLetter() && ch !=
'_' && ch !=
':' )
375 for ( uint i = 0; i < _name->l; ++i )
378 if ( !ch.isLetter() && !ch.isDigit() && ch !=
'.'
379 && ch !=
'-' && ch !=
'_' && ch !=
':'
380 && ch.category() != TQChar::Mark_SpacingCombining
387bool Element::tdehtmlValidPrefix(
const DOMString &name)
390 return !
name.implementation() || tdehtmlValidAttrName(name);
393bool Element::tdehtmlValidQualifiedName(
const DOMString &name)
395 return tdehtmlValidAttrName(name);
398bool Element::tdehtmlMalformedQualifiedName(
const DOMString &name)
402 return name.isNull();
405bool Element::tdehtmlMalformedPrefix(
const DOMString &)
The Attr interface represents an attribute in an Element object.
DOMString name() const
Returns the name of this attribute.
Element ownerElement() const
Introduced in DOM Level 2.
bool specified() const
If this attribute was explicitly given a value in the original document, this is true ; otherwise,...
DOMString value() const
On retrieval, the value of the attribute is returned as a string.
void setValue(const DOMString &)
see value
The CSSStyleDeclaration interface represents a single CSS declaration block .
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
This class implements the basic string we use in the DOM.
By far the vast majority of objects (apart from text) that authors encounter when traversing a docume...
DOMString tagName() const
The name of the element.
DOMString getAttributeNS(const DOMString &namespaceURI, const DOMString &localName)
Introduced in DOM Level 2.
Attr setAttributeNode(const Attr &newAttr)
Adds a new attribute.
bool hasAttribute(const DOMString &name)
Returns true when an attribute with a given name is specified on this element or has a default value,...
DOMString getAttribute(const DOMString &name)
Retrieves an attribute value by name.
void removeAttribute(const DOMString &name)
Removes an attribute by name.
Attr setAttributeNodeNS(const Attr &newAttr)
Introduced in DOM Level 2.
NodeList getElementsByTagName(const DOMString &name)
Returns a NodeList of all descendant elements with a given tag name, in the order in which they would...
Attr getAttributeNode(const DOMString &name)
Retrieves an Attr node by name.
CSSStyleDeclaration style()
Introduced in DOM Level 2 This method is from the CSSStyleDeclaration interface.
bool hasAttributeNS(const DOMString &namespaceURI, const DOMString &localName)
Introduced in DOM Level 2.
bool contentEditable() const
not part of the official DOM
void setAttribute(const DOMString &name, const DOMString &value)
Adds a new attribute.
Attr getAttributeNodeNS(const DOMString &namespaceURI, const DOMString &localName)
Introduced in DOM Level 2.
NodeList getElementsByTagNameNS(const DOMString &namespaceURI, const DOMString &localName)
Introduced in DOM Level 2 Returns a NodeList of all the descendant Elements with a given local name a...
void removeAttributeNS(const DOMString &namespaceURI, const DOMString &localName)
Introduced in DOM Level 2.
void setAttributeNS(const DOMString &namespaceURI, const DOMString &qualifiedName, const DOMString &value)
Introduced in DOM Level 2.
void setContentEditable(bool enabled)
not part of the official DOM
Attr removeAttributeNode(const Attr &oldAttr)
Removes the specified attribute.
Element form() const
TDEHTML extension to DOM This method returns the associated form element.
Node setNamedItem(const Node &arg)
Adds a node using its nodeName attribute.
The Node interface is the primary datatype for the entire Document Object Model.
DOMString localName() const
Introduced in DOM Level 2.
bool isNull() const
tests if this Node is 0.
DOMString namespaceURI() const
Introduced in DOM Level 2.
NamedNodeMap attributes() const
A NamedNodeMap containing the attributes of this node (if it is an Element ) or null otherwise.
The Document Object Model (DOM) is divided into two parts, the COREDOM core DOM, specifying some core...
TQString name(StdAccel id)