Commit 5da890e4 authored by Maks Orlovich's avatar Maks Orlovich

Further work on adjusting to the new API. I also tried to keep

the use of wrapper classes in the minimum, so the ECMA binding does not
have to worry about exceptions much. Some of the classes of ecma/
no longer compile, but most are pretty close; and those that do build
might even work.

svn path=/branches/work/kdelibs-js/khtml/; revision=487756
parent a86c2c87
......@@ -52,6 +52,24 @@ using khtml::FontDef;
using namespace DOM;
static int propertyID(const DOMString &s)
{
char buffer[maxCSSPropertyNameLength];
unsigned len = s.length();
if (len > maxCSSPropertyNameLength)
return 0;
for (unsigned i = 0; i != len; ++i) {
unsigned short c = s[i].unicode();
if (c == 0 || c >= 0x7F)
return 0; // illegal character
buffer[i] = c;
}
return getPropertyID(buffer, len);
}
CSSStyleDeclarationImpl::CSSStyleDeclarationImpl(CSSRuleImpl *parent)
: StyleBaseImpl(parent)
{
......@@ -89,6 +107,47 @@ CSSStyleDeclarationImpl::~CSSStyleDeclarationImpl()
// we don't use refcounting for m_node, to avoid cyclic references (see ElementImpl)
}
CSSValueImpl *CSSStyleDeclarationImpl::getPropertyCSSValue(const DOMString &propertyName) const
{
int propID = propertyID(propertyName);
if (!propID)
return 0;
return getPropertyCSSValue(propID);
}
DOMString CSSStyleDeclarationImpl::getPropertyValue(const DOMString &propertyName) const
{
int propID = propertyID(propertyName);
if (!propID)
return DOMString();
return getPropertyValue(propID);
}
DOMString CSSStyleDeclarationImpl::getPropertyPriority(const DOMString &propertyName) const
{
int propID = propertyID(propertyName);
if (!propID)
return DOMString();
return getPropertyPriority(propID) ? "important" : "";
}
void CSSStyleDeclarationImpl::setProperty(const DOMString &propertyName, const DOMString &value, const DOMString &priority)
{
int propID = propertyID(propertyName);
if (!propID) // set exception?
return;
bool important = priority.string().find("important", 0, false) != -1;
setProperty(propID, value, important);
}
DOMString CSSStyleDeclarationImpl::removeProperty(const DOMString &propertyName)
{
int propID = propertyID(propertyName);
if (!propID)
return DOMString();
return removeProperty(propID);
}
DOMString CSSStyleDeclarationImpl::getPropertyValue( int propertyID ) const
{
if(!m_lstValues) return DOMString();
......
......@@ -64,6 +64,9 @@ public:
// needed for conversion of html attributes
virtual void setLengthProperty(int id, const DOM::DOMString &value, bool important, bool nonCSSHint = true, bool multiLength = false);
void setProperty(const DOMString &propertyName, const DOMString &value, const DOMString &priority);
DOMString removeProperty(const DOMString &propertyName);
// add a whole, unparsed property
virtual void setProperty ( const DOMString &propertyString);
virtual DOM::DOMString item ( unsigned long index ) const;
......@@ -74,6 +77,10 @@ public:
virtual bool isStyleDeclaration() const { return true; }
virtual bool parseString( const DOMString &string, bool = false );
CSSValueImpl *getPropertyCSSValue(const DOMString &propertyName) const;
DOMString getPropertyValue(const DOMString &propertyName) const ;
DOMString getPropertyPriority(const DOMString &propertyName) const;
virtual CSSValueImpl *getPropertyCSSValue( int propertyID ) const;
virtual DOMString getPropertyValue( int propertyID ) const;
virtual bool getPropertyPriority( int propertyID ) const;
......
......@@ -130,8 +130,10 @@ DOM::DOMString getPropertyName(unsigned short id) KDE_NO_EXPORT;
#define CSS_PROP_SCROLLBAR_ARROW_COLOR 120
#define CSS_PROP__KHTML_FLOW_MODE 121
#define CSS_PROP__KHTML_USER_INPUT 122
#define CSS_PROP__KHTML_TEXT_DECORATION_COLOR 123
#define CSS_PROP_MAX CSS_PROP_Z_INDEX
#define CSS_PROP_TOTAL 123
#define CSS_PROP_TOTAL 124
const size_t maxCSSPropertyNameLength = 28;
#endif
......@@ -36,6 +36,8 @@ print ""; \
print "#define CSS_PROP_MAX CSS_PROP_Z_INDEX"; \
print "#define CSS_PROP_TOTAL " i \
}' >> cssproperties.h
perl -e 'my $max = 0; while (<>) { chomp; $max = length if $ ax < length; } print "const size_t maxCSSPropertyNameLength = $max;\n"' < cssproperties.strip >> cssproperties.h
gperf -a -L 'ANSI-C' -E -C -c -o -t -k '*' -NfindProp -Hhash_prop -Wwordlist_prop -D -s 2 cssproperties.gperf > cssproperties.c || exit 1
echo -e '#endif\n' >> cssproperties.h
......
......@@ -72,64 +72,34 @@ void CSSStyleDeclaration::setCssText( const DOMString &value )
impl->setCssText(value);
}
DOMString CSSStyleDeclaration::getPropertyValue( const DOMString &propertyName )
{
return const_cast<const CSSStyleDeclaration*>( this )->getPropertyValue( propertyName );
}
DOMString CSSStyleDeclaration::getPropertyValue( const DOMString &propertyName ) const
{
if(!impl) return DOMString();
int id = getPropertyID(propertyName.string().ascii(), propertyName.length());
if (!id) return DOMString();
return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyValue(id);
}
CSSValue CSSStyleDeclaration::getPropertyCSSValue( const DOMString &propertyName )
{
return const_cast<const CSSStyleDeclaration*>( this )->getPropertyCSSValue( propertyName );
return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyValue(propertyName);
}
CSSValue CSSStyleDeclaration::getPropertyCSSValue( const DOMString &propertyName ) const
CSSValue CSSStyleDeclaration::getPropertyCSSValue( const DOMString &propertyName ) const
{
if(!impl) return 0;
int id = getPropertyID(propertyName.string().ascii(), propertyName.length());
if (!id) return 0;
return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyCSSValue(id);
return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyCSSValue(propertyName);
}
DOMString CSSStyleDeclaration::removeProperty( const DOMString &property )
DOMString CSSStyleDeclaration::removeProperty( const DOMString &propertyName )
{
int id = getPropertyID(property.string().ascii(), property.length());
if(!impl || !id) return DOMString();
return static_cast<CSSStyleDeclarationImpl *>(impl)->removeProperty( id );
}
DOMString CSSStyleDeclaration::getPropertyPriority( const DOMString &propertyName )
{
return const_cast<const CSSStyleDeclaration*>( this )->getPropertyPriority( propertyName );
if(!impl) return DOMString();
return static_cast<CSSStyleDeclarationImpl *>(impl)->removeProperty(propertyName);
}
DOMString CSSStyleDeclaration::getPropertyPriority( const DOMString &propertyName ) const
{
int id = getPropertyID(propertyName.string().ascii(), propertyName.length());
if(!impl || !id) return DOMString();
if (impl->getPropertyPriority(id))
return DOMString("important");
return DOMString();
if(!impl) return DOMString();
return impl->getPropertyPriority(propertyName);
}
void CSSStyleDeclaration::setProperty( const DOMString &propName, const DOMString &value, const DOMString &priority )
{
if(!impl) return;
int id = getPropertyID(propName.string().toLower().ascii(), propName.length());
if (!id) return;
bool important = false;
QString str = priority.string();
if (str.find("important", 0, false) != -1)
important = true;
static_cast<CSSStyleDeclarationImpl *>(impl)->setProperty( id, value, important );
static_cast<CSSStyleDeclarationImpl *>(impl)->setProperty( propName, value, priority );
}
unsigned long CSSStyleDeclaration::length() const
......
......@@ -21,7 +21,7 @@
* This file includes excerpts from the Document Object Model (DOM)
* Level 2 Specification (Style)
* http://www.w3.org/TR/DOM-Level-2-Style/
* Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved.
* Copyright 2000 W3C (MIT, INRIA, Keio), All Rights Reserved.
*
*/
#ifndef _CSS_css_value_h_
......@@ -118,7 +118,6 @@ public:
*
*/
DOM::DOMString getPropertyValue ( const DOM::DOMString &propertyName ) const;
DOM::DOMString getPropertyValue ( const DOM::DOMString &propertyName );
/**
* Used to retrieve the object representation of the value of a
......@@ -140,7 +139,6 @@ public:
*
*/
CSSValue getPropertyCSSValue ( const DOM::DOMString &propertyName ) const;
CSSValue getPropertyCSSValue ( const DOM::DOMString &propertyName );
/**
* Used to remove a CSS property if it has been explicitly set
......@@ -177,7 +175,6 @@ public:
*
*/
DOM::DOMString getPropertyPriority ( const DOM::DOMString &propertyName ) const;
DOM::DOMString getPropertyPriority ( const DOM::DOMString &propertyName );
/**
* Used to set a property value and priority within this
......
......@@ -251,10 +251,7 @@ int UIEvent::keyCode() const
{
if ( !impl ) throw DOMException( DOMException::INVALID_STATE_ERR );
if( impl->isTextEvent() )
return static_cast<TextEventImpl*>( impl )->keyCode();
return 0;
return static_cast<UIEventImpl*>(impl)->keyCode();
}
int UIEvent::charCode() const
......@@ -262,10 +259,7 @@ int UIEvent::charCode() const
if (!impl)
throw DOMException(DOMException::INVALID_STATE_ERR);
if( impl->isTextEvent() )
return static_cast<TextEventImpl*>( impl )->charCode();
return 0;
return static_cast<UIEventImpl*>(impl)->charCode();
}
int UIEvent::pageX() const
......@@ -273,10 +267,7 @@ int UIEvent::pageX() const
if (!impl)
throw DOMException(DOMException::INVALID_STATE_ERR);
if (impl->isMouseEvent() )
return static_cast<MouseEventImpl*>( impl )->pageX();
else
return 0;
return static_cast<UIEventImpl*>(impl)->pageX();
}
int UIEvent::pageY() const
......@@ -284,10 +275,7 @@ int UIEvent::pageY() const
if (!impl)
throw DOMException(DOMException::INVALID_STATE_ERR);
if ( impl->isMouseEvent() )
return static_cast<MouseEventImpl*>( impl )->pageY();
else
return 0;
return static_cast<UIEventImpl*>(impl)->pageY();
}
int UIEvent::layerX() const
......@@ -295,9 +283,7 @@ int UIEvent::layerX() const
if( !impl )
throw DOMException( DOMException::INVALID_STATE_ERR );
if( impl->isMouseEvent() )
return static_cast<MouseEventImpl*>( impl )->layerX();
return 0;
return static_cast<UIEventImpl*>(impl)->layerX();
}
int UIEvent::layerY() const
......@@ -305,21 +291,13 @@ int UIEvent::layerY() const
if( !impl )
throw DOMException( DOMException::INVALID_STATE_ERR );
if( impl->isMouseEvent() )
return static_cast<MouseEventImpl*>( impl )->layerY();
return 0;
return static_cast<UIEventImpl*>(impl)->layerY();
}
int UIEvent::which() const
{
if( !impl ) throw DOMException( DOMException::INVALID_STATE_ERR );
if( impl->isMouseEvent() )
return static_cast<MouseEventImpl*>( impl )->button() + 1;
else if( impl->isTextEvent() )
return static_cast<TextEventImpl*>( impl )->keyCode();
return 0;
return static_cast<UIEventImpl*>(impl)->which();
}
void UIEvent::initUIEvent(const DOMString &typeArg,
......@@ -332,7 +310,7 @@ void UIEvent::initUIEvent(const DOMString &typeArg,
throw DOMException(DOMException::INVALID_STATE_ERR);
static_cast<UIEventImpl*>(impl)->initUIEvent(typeArg,canBubbleArg,cancelableArg,
viewArg,detailArg);
viewArg.handle(),detailArg);
}
// -----------------------------------------------------------------------------
......@@ -476,7 +454,7 @@ void MouseEvent::initMouseEvent(const DOMString &typeArg,
throw DOMException(DOMException::INVALID_STATE_ERR);
static_cast<MouseEventImpl*>(impl)->initMouseEvent(typeArg,canBubbleArg,
cancelableArg,viewArg,detailArg,screenXArg,screenYArg,clientXArg,
cancelableArg,viewArg.handle(),detailArg,screenXArg,screenYArg,clientXArg,
clientYArg,ctrlKeyArg,altKeyArg,shiftKeyArg,metaKeyArg,buttonArg,
relatedTargetArg);
}
......@@ -536,7 +514,7 @@ void TextEvent::initTextEvent(const DOMString &typeArg,
if (!impl)
throw DOMException(DOMException::INVALID_STATE_ERR);
return static_cast<TextEventImpl*>(impl)->initTextEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg, outputStringArg, keyValArg, virtKeyValArg, inputGeneratedArg, numPadArg);
return static_cast<TextEventImpl*>(impl)->initTextEvent(typeArg, canBubbleArg, cancelableArg, viewArg.handle(), detailArg, outputStringArg, keyValArg, virtKeyValArg, inputGeneratedArg, numPadArg);
}
unsigned long TextEvent::keyVal() const
......
......@@ -98,7 +98,8 @@ Document DOMImplementation::createDocument ( const DOMString &namespaceURI,
throw DOMException(DOMException::NOT_FOUND_ERR);
int exceptioncode = 0;
DocumentImpl *r = impl->createDocument(namespaceURI, qualifiedName, doctype, exceptioncode );
DocumentImpl *r = impl->createDocument(namespaceURI, qualifiedName,
(DocumentTypeImpl*)doctype.handle(), exceptioncode );
if ( exceptioncode )
throw DOMException( exceptioncode );
return r;
......@@ -317,18 +318,13 @@ Element Document::getElementById( const DOMString &elementId ) const
NodeList Document::getElementsByTagName( const DOMString &tagName )
{
if (!impl) return 0;
NodeImpl::Id id;
if ( tagName == "*" )
id = 0;
else
id = impl->getDocument()->getId(NodeImpl::ElementId, tagName.implementation(), false, true);
return new TagNodeListImpl( impl, id );
return impl->getElementsByTagName( tagName );
}
NodeList Document::getElementsByTagNameNS( const DOMString &namespaceURI, const DOMString &localName )
{
if (!impl) return 0;
return new TagNodeListImpl( impl, namespaceURI, localName );
return impl->getElementsByTagNameNS( namespaceURI, localName );
}
Node Document::importNode( const Node & importedNode, bool deep )
......
......@@ -152,21 +152,14 @@ DOMString Element::getAttribute( const DOMString &name )
if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
if (!name.implementation()) throw DOMException(DOMException::NOT_FOUND_ERR);
NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId,name.implementation(),true,true);
if (!id) return DOMString();
ElementImpl* e = static_cast<ElementImpl*>(impl);
return e->getAttribute(id, false, name);
return static_cast<ElementImpl*>(impl)->getAttribute(name);
}
void Element::setAttribute( const DOMString &name, const DOMString &value )
{
if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
int exceptioncode = 0;
NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, name.implementation(), false /* allocate */,
true, &exceptioncode);
static_cast<ElementImpl*>(impl)->setAttribute(id, value, name, exceptioncode);
static_cast<ElementImpl*>(impl)->setAttribute(name, value, exceptioncode);
if ( exceptioncode )
throw DOMException( exceptioncode );
}
......@@ -174,12 +167,9 @@ void Element::setAttribute( const DOMString &name, const DOMString &value )
void Element::removeAttribute( const DOMString &name )
{
if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, name.implementation(), true, true);
if (!id) return;
int exceptioncode = 0;
NamedNodeMapImpl *attributes = static_cast<ElementImpl*>(impl)->attributes(false);
attributes->removeNamedItem(id, false, name.implementation(), exceptioncode);
static_cast<ElementImpl*>(impl)->removeAttribute(name, exceptioncode);
// it's allowed to remove attributes that don't exist.
if ( exceptioncode && exceptioncode != DOMException::NOT_FOUND_ERR )
throw DOMException( exceptioncode );
......@@ -189,13 +179,8 @@ Attr Element::getAttributeNode( const DOMString &name )
{
if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
if (!name.implementation()) throw DOMException(DOMException::NOT_FOUND_ERR);
NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, name.implementation(), true, true);
if (!id) return 0;
ElementImpl* e = static_cast<ElementImpl*>(impl);
if (!e->attributes()) return 0;
return static_cast<AttrImpl*>(e->attributes()->getNamedItem(id, false, name.implementation()));
return static_cast<ElementImpl*>(impl)->getAttributeNode(name);
}
Attr Element::setAttributeNode( const Attr &newAttr )
......@@ -205,55 +190,50 @@ Attr Element::setAttributeNode( const Attr &newAttr )
// WRONG_DOCUMENT_ERR and INUSE_ATTRIBUTE_ERR are already tested & thrown by setNamedItem
int exceptioncode = 0;
Attr r = static_cast<ElementImpl*>(impl)->attributes(false)->setNamedItem(newAttr.handle(), false,
newAttr.handle()->nodeName().implementation(), exceptioncode);
Attr r = static_cast<ElementImpl*>(impl)->setAttributeNode(
static_cast<AttrImpl*>(newAttr.handle()), exceptioncode);
if ( exceptioncode )
throw DOMException( exceptioncode );
static_cast<AttrImpl *>(newAttr.handle())->setOwnerElement( static_cast<ElementImpl*>(impl) );
return r;
}
Attr Element::removeAttributeNode( const Attr &oldAttr )
{
if (!impl || oldAttr.isNull() || oldAttr.ownerElement().handle() != impl)
int exceptioncode = 0;
if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
if (impl->isReadOnly())
throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);
if (!static_cast<ElementImpl*>(impl)->attributes(true))
throw DOMException(DOMException::NOT_FOUND_ERR);
Attr ret = static_cast<ElementImpl*>(impl)->removeAttributeNode(
static_cast<AttrImpl*>(oldAttr.handle()), exceptioncode);
if (exceptioncode)
throw DOMException(exceptioncode);
NamedAttrMapImpl *attributes = static_cast<ElementImpl*>(impl)->attributes(false);
return attributes->removeAttr(static_cast<AttrImpl*>(static_cast<AttrImpl*>(oldAttr.handle())));
return ret;
}
NodeList Element::getElementsByTagName( const DOMString &tagName )
{
if (!impl) return 0;
NodeImpl::Id id;
if ( tagName == "*" )
id = 0;
else
id = impl->getDocument()->getId(NodeImpl::ElementId, tagName.implementation(), false, true);
return new TagNodeListImpl( impl, id );
return static_cast<ElementImpl*>(impl)->getElementsByTagName( tagName );
}
NodeList Element::getElementsByTagNameNS( const DOMString &namespaceURI,
const DOMString &localName )
{
if (!impl) return 0;
return new TagNodeListImpl( impl, namespaceURI, localName );
return static_cast<ElementImpl*>(impl)->getElementsByTagNameNS( namespaceURI, localName );
}
DOMString Element::getAttributeNS( const DOMString &namespaceURI,
const DOMString &localName)
{
if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
if (!localName.implementation()) throw DOMException(DOMException::NOT_FOUND_ERR);
NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, namespaceURI.implementation(), 0/*prefix*/, localName.implementation(), true, true);
ElementImpl* e = static_cast<ElementImpl*>(impl);
return e->getAttribute(id, true);
int exceptioncode = 0;
DOMString ret = e->getAttributeNS(namespaceURI, localName, exceptioncode);
if (exceptioncode)
throw DOMException(exceptioncode);
return ret;
}
void Element::setAttributeNS( const DOMString &namespaceURI,
......@@ -274,9 +254,7 @@ void Element::removeAttributeNS( const DOMString &namespaceURI,
if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
int exceptioncode = 0;
NamedNodeMapImpl *attributes = static_cast<ElementImpl*>(impl)->attributes(false);
NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, namespaceURI.implementation(), 0/*prefix*/, localName.implementation(), false, true);
attributes->removeNamedItem(id, true, 0, exceptioncode);
static_cast<ElementImpl*>(impl)->removeAttributeNS(namespaceURI, localName, exceptioncode);
if ( exceptioncode )
throw DOMException( exceptioncode );
}
......@@ -285,48 +263,36 @@ Attr Element::getAttributeNodeNS( const DOMString &namespaceURI,
const DOMString &localName )
{
if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
if (!localName.implementation()) throw DOMException(DOMException::NOT_FOUND_ERR);
NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, namespaceURI.implementation(),
0/*prefix*/, localName.implementation(), true, true);
ElementImpl* e = static_cast<ElementImpl*>(impl);
if (!e->attributes()) return 0;
return static_cast<AttrImpl*>(e->attributes()->getNamedItem(id, true));
int exceptioncode = 0;
Attr r = static_cast<ElementImpl*>(impl)->getAttributeNodeNS(namespaceURI, localName, exceptioncode);
if (exceptioncode)
throw DOMException( exceptioncode );
return r;
}
Attr Element::setAttributeNodeNS( const Attr &newAttr )
{
if (!impl || newAttr.isNull())
if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
// WRONG_DOCUMENT_ERR and INUSE_ATTRIBUTE_ERR are already tested & thrown by setNamedItem
int exceptioncode = 0;
Attr r = static_cast<ElementImpl*>(impl)->attributes(false)->setNamedItem(newAttr.handle(), true, 0, exceptioncode);
if ( exceptioncode )
throw DOMException( exceptioncode );
static_cast<AttrImpl *>(newAttr.handle())->setOwnerElement( static_cast<ElementImpl*>(impl) );
Attr r = static_cast<ElementImpl*>(impl)->setAttributeNodeNS(
static_cast<AttrImpl*>(newAttr.handle()), exceptioncode);
return r;
}
bool Element::hasAttribute( const DOMString& name )
{
if (!impl || !static_cast<ElementImpl*>(impl)->attributes()) return false; // ### throw ?
NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId, name.implementation(), true, true);
if (!id) return false;
if (!static_cast<ElementImpl*>(impl)->attributes(true /*readonly*/)) return false;
return static_cast<ElementImpl*>(impl)->attributes(true)->getValue(id, false, name.implementation()) != 0;
if (!impl) return false; // ### throw ?
return static_cast<ElementImpl*>(impl)->hasAttribute(name);
}
bool Element::hasAttributeNS( const DOMString &namespaceURI,
const DOMString &localName )
{
if (!impl || !static_cast<ElementImpl*>(impl)->attributes()) return false; // ### throw ?
if (!static_cast<ElementImpl*>(impl)->attributes(true /*readonly*/)) return false;
NodeImpl::Id id = impl->getDocument()->getId(NodeImpl::AttributeId,namespaceURI.implementation(),
0/*prefix*/, localName.implementation(), true, true);
return static_cast<ElementImpl*>(impl)->attributes(true)->getValue(id, true) != 0;
if (!impl) return false;
return static_cast<ElementImpl*>(impl)->hasAttributeNS(namespaceURI, localName);
}
bool Element::isHTMLElement() const
......
......@@ -246,13 +246,9 @@ NamedNodeMap Node::attributes() const
Document Node::ownerDocument() const
{
// braindead DOM spec says that ownerDocument
// should return null if called on the document node
// we don't do that in the *impl tree to avoid excessive if()'s
// so we simply hack it here in one central place.
if (!impl || impl->getDocument() == impl) return Document(false);
return impl->getDocument();
if (!impl || !impl->ownerDocument())
return Document(false);
return impl->ownerDocument();
}
Node Node::insertBefore( const Node &newChild, const Node &refChild )
......@@ -301,9 +297,7 @@ Node Node::appendChild( const Node &newChild )
bool Node::hasAttributes()
{
if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
if (!impl->isElementNode()) return false;
ElementImpl* e = static_cast<ElementImpl*>(impl);
return e->attributes(true) && e->attributes(true)->length();
return impl->hasAttributes();
}
bool Node::hasChildNodes( )
......@@ -325,12 +319,9 @@ void Node::normalize ( )
}
bool Node::isSupported( const DOMString &feature,
const DOMString & /*version*/ ) const
const DOMString &version ) const
{
DOMString upFeature = feature.upper();
return (upFeature == "HTML" ||
upFeature == "XML" ||
upFeature == "CORE");
return NodeImpl::isSupported(feature, version);
}
DOMString Node::namespaceURI( ) const
......
......@@ -58,12 +58,12 @@ HTMLBodyElement::~HTMLBodyElement()
DOMString HTMLBodyElement::aLink() const
{