diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 398239d3f8fc3d3b4027e60dd09368a3b757ef9f..b613a58abe4b1a8e1fc5741a3585fa8e4bfb34a3 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,31 @@ +2006-01-03 Anders Carlsson + + Reviewed by Darin. + + - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5177 + Javascript cloneNode(deep) does not clone form elements correctly + + * khtml/html/html_elementimpl.cpp: + (HTMLElementImpl::cloneNode): + Call copyNonAttributeProperties on the new node. + + * khtml/html/html_formimpl.cpp: + (DOM::HTMLInputElementImpl::copyNonAttributeProperties): + * khtml/html/html_formimpl.h: + Copy m_value, m_checked and m_indeterminate here. + + * khtml/xml/dom_docimpl.cpp: + (DocumentImpl::importNode): + Call copyNonAttributeProperties on the new node. + + * khtml/xml/dom_elementimpl.cpp: + (ElementImpl::cloneNode): + Call copyNonAttributeProperties on the new node. + + * khtml/xml/dom_elementimpl.h: + (DOM::ElementImpl::copyNonAttributeProperties): + Add function declaration. + 2006-01-02 Maciej Stachowiak Rubber stamped by Eric. diff --git a/WebCore/khtml/html/html_elementimpl.cpp b/WebCore/khtml/html/html_elementimpl.cpp index 050277377b4156c823c73f1ffd38d0d9f4799872..1fd4f58a027d50dc56fdee46cf26b41bfef39f78 100644 --- a/WebCore/khtml/html/html_elementimpl.cpp +++ b/WebCore/khtml/html/html_elementimpl.cpp @@ -114,6 +114,8 @@ NodeImpl *HTMLElementImpl::cloneNode(bool deep) if (m_inlineStyleDecl) *clone->getInlineStyleDecl() = *m_inlineStyleDecl; + clone->copyNonAttributeProperties(this); + if (deep) cloneChildNodes(clone); diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp index 00913212df131d95208300cc790b3a172ab3f4a3..dc26dcfd77c099cb0b37d2cc5b9b9cc5a19e4df6 100644 --- a/WebCore/khtml/html/html_formimpl.cpp +++ b/WebCore/khtml/html/html_formimpl.cpp @@ -1917,6 +1917,15 @@ void HTMLInputElementImpl::setIndeterminate(bool _indeterminate) theme()->stateChanged(renderer(), CheckedState); } +void HTMLInputElementImpl::copyNonAttributeProperties(const ElementImpl *source) +{ + const HTMLInputElementImpl *sourceElem = static_cast(source); + + m_value = sourceElem->m_value; + m_checked = sourceElem->m_checked; + m_indeterminate = sourceElem->m_indeterminate; +} + DOMString HTMLInputElementImpl::value() const { DOMString value = m_value; diff --git a/WebCore/khtml/html/html_formimpl.h b/WebCore/khtml/html/html_formimpl.h index a1453667fbf2d5bc791775712a6da4dffd20c1ae..2d83d60ee3c0612900726b0fa14bbe14d6963fbd 100644 --- a/WebCore/khtml/html/html_formimpl.h +++ b/WebCore/khtml/html/html_formimpl.h @@ -376,6 +376,8 @@ public: virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const; virtual void parseMappedAttribute(MappedAttributeImpl *attr); + virtual void copyNonAttributeProperties(const ElementImpl *source); + virtual void attach(); virtual bool rendererIsNeeded(khtml::RenderStyle *); virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *); diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp index 6ed19f2f7370f125b47db35ba377ba70056cef89..b7f75c4d26c2d57dc9a193a211af528ecb40bcbc 100644 --- a/WebCore/khtml/xml/dom_docimpl.cpp +++ b/WebCore/khtml/xml/dom_docimpl.cpp @@ -696,6 +696,8 @@ NodeImpl *DocumentImpl::importNode(NodeImpl *importedNode, bool deep, int &excep } } + newElement->copyNonAttributeProperties(oldElement); + if (deep) { for (NodeImpl *oldChild = oldElement->firstChild(); oldChild; oldChild = oldChild->nextSibling()) { NodeImpl *newChild = importNode(oldChild, true, exceptioncode); diff --git a/WebCore/khtml/xml/dom_elementimpl.cpp b/WebCore/khtml/xml/dom_elementimpl.cpp index ffed6aab01feac7b2d4dca649d0939a54b5d9d2f..c1fea0372f449ed4ca724424f3becd2cfee52309 100644 --- a/WebCore/khtml/xml/dom_elementimpl.cpp +++ b/WebCore/khtml/xml/dom_elementimpl.cpp @@ -283,6 +283,8 @@ NodeImpl *ElementImpl::cloneNode(bool deep) if (namedAttrMap) *clone->attributes() = *namedAttrMap; + clone->copyNonAttributeProperties(this); + if (deep) cloneChildNodes(clone); diff --git a/WebCore/khtml/xml/dom_elementimpl.h b/WebCore/khtml/xml/dom_elementimpl.h index abd6ffcff6318eb22d5a99afe09ad414d7f44d74..8bea70900d11b744e85459d1d64d62058af50468 100644 --- a/WebCore/khtml/xml/dom_elementimpl.h +++ b/WebCore/khtml/xml/dom_elementimpl.h @@ -237,6 +237,8 @@ public: // not part of the DOM void setAttributeMap(NamedAttrMapImpl*); + virtual void copyNonAttributeProperties(const ElementImpl *source) {} + // State of the element. virtual QString state() { return QString::null; }