SVN commit 763553 by porten: Basic cloneNode() implementation for Document and DocumentType. M +24 -8 dom_docimpl.cpp --- branches/KDE/4.0/kdelibs/khtml/xml/dom_docimpl.cpp #763552:763553 @@ -1826,14 +1826,27 @@ return false; } -NodeImpl *DocumentImpl::cloneNode ( bool /*deep*/ ) +NodeImpl *DocumentImpl::cloneNode ( bool deep ) { - // Spec says cloning Document nodes is "implementation dependent" - // so we do not support it... - return 0; +#if 0 + NodeImpl *dtn = m_doctype->cloneNode(deep); + DocumentTypeImpl *dt = static_cast(dtn); +#endif + + int exceptioncode; + DocumentImpl *clone = m_implementation->createDocument("", + "", + 0, exceptioncode); + assert( exceptioncode == 0 ); + + // ### attributes, styles, ... + + if (deep) + cloneChildNodes(clone); + + return clone; } - typedef const char* (*NameLookupFunction)(unsigned short id); typedef int (*IdLookupFunction)(const char *tagStr, int len); @@ -2901,9 +2914,12 @@ NodeImpl *DocumentTypeImpl::cloneNode ( bool /*deep*/ ) { - // Spec says cloning Document nodes is "implementation dependent" - // so we do not support it... - return 0; + DocumentTypeImpl *clone = new DocumentTypeImpl(implementation(), + 0, + name(), publicId(), + systemId()); + // ### copy entities etc. + return clone; } NamedNodeMapImpl * DocumentTypeImpl::entities() const