Reviewed by Darin.
authorharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Aug 2005 23:09:20 +0000 (23:09 +0000)
committerharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Aug 2005 23:09:20 +0000 (23:09 +0000)
        Landed by David Harrison.

        Test cases added: None.  Fixes existing tests.

        * khtml/ecma/kjs_dom.cpp:
        Attribute values are writable

        * khtml/xml/dom_docimpl.cpp:
        (DocumentImpl::createAttributeNS):
        Update for new AttrImpl constructor.

        * khtml/xml/dom_elementimpl.cpp:
        (AttributeImpl::allocateImpl):
        Update for new AttrImpl constructor.

        (AttrImpl::AttrImpl):
        Initialize m_ignoreChildCount to 0. If createTextChild.
        is true, create a child text node with the contents
        of the attribute value.

        (AttrImpl::setValue):
        Remove all children and create a new text node with the contents
        of the attribute value.

        (AttrImpl::cloneNode):
        Make sure to clone any children.

        (AttrImpl::childrenChanged):
        If m_ignoreChildrenChanged is 0, update the attribute value.

        * khtml/xml/dom_elementimpl.h:
        Add childrenChanged, update AttrImpl constructor and
        add m_ignoreChildrenChanged to AttrImpl.

        * khtml/xml/dom_nodeimpl.cpp:
        (DOM::NodeImpl::normalize):
        If an element has attributes, make sure to normalize them.

        * layout-tests/dom/html/level1/core/hc_attrappendchild1-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrappendchild3-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrappendchild6-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrchildnodes1-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrchildnodes2-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrclonenode1-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrcreatetextnode-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrfirstchild-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrhaschildnodes-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrinsertbefore1-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrinsertbefore2-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrinsertbefore3-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrinsertbefore4-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrlastchild-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrnormalize-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrremovechild1-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrreplacechild1-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrreplacechild2-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrsetvalue1-expected.txt:
        * layout-tests/dom/html/level1/core/hc_attrsetvalue2-expected.txt:
        * layout-tests/dom/html/level1/core/hc_elementnormalize2-expected.txt:
        These tests pass now.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@10270 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
LayoutTests/dom/html/level1/core/hc_attrappendchild1-expected.txt
LayoutTests/dom/html/level1/core/hc_attrappendchild3-expected.txt
LayoutTests/dom/html/level1/core/hc_attrappendchild6-expected.txt
LayoutTests/dom/html/level1/core/hc_attrchildnodes1-expected.txt
LayoutTests/dom/html/level1/core/hc_attrchildnodes2-expected.txt
LayoutTests/dom/html/level1/core/hc_attrclonenode1-expected.txt
LayoutTests/dom/html/level1/core/hc_attrcreatetextnode-expected.txt
LayoutTests/dom/html/level1/core/hc_attrfirstchild-expected.txt
LayoutTests/dom/html/level1/core/hc_attrhaschildnodes-expected.txt
LayoutTests/dom/html/level1/core/hc_attrinsertbefore1-expected.txt
LayoutTests/dom/html/level1/core/hc_attrinsertbefore2-expected.txt
LayoutTests/dom/html/level1/core/hc_attrinsertbefore3-expected.txt
LayoutTests/dom/html/level1/core/hc_attrinsertbefore4-expected.txt
LayoutTests/dom/html/level1/core/hc_attrlastchild-expected.txt
LayoutTests/dom/html/level1/core/hc_attrnormalize-expected.txt
LayoutTests/dom/html/level1/core/hc_attrremovechild1-expected.txt
LayoutTests/dom/html/level1/core/hc_attrreplacechild1-expected.txt
LayoutTests/dom/html/level1/core/hc_attrreplacechild2-expected.txt
LayoutTests/dom/html/level1/core/hc_attrsetvalue1-expected.txt
LayoutTests/dom/html/level1/core/hc_attrsetvalue2-expected.txt
LayoutTests/dom/html/level1/core/hc_elementnormalize2-expected.txt
WebCore/ChangeLog-2005-08-23
WebCore/khtml/ecma/kjs_dom.cpp
WebCore/khtml/xml/dom_docimpl.cpp
WebCore/khtml/xml/dom_elementimpl.cpp
WebCore/khtml/xml/dom_elementimpl.h
WebCore/khtml/xml/dom_nodeimpl.cpp

index 8bd8a69684a2d320c5e7fdbb2f21ae1457bfb851..dfd0980357d25732da944cb3e5fc419c95afff21 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild1   
-Status:        failure
-Detail:        attrValue: assertEquals failed, actual Yes, expected Yesterday.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild1
+Status:        Success
index bf364a919929adc2dd213ababdc7320a677468d3..514c75c01fc633e0e057cfee816e52177cc5ed6a 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild3   
-Status:        failure
-Detail:        attrValue: assertEquals failed, actual Yes, expected Yesterday.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild3
+Status:        Success
index e0cba02a1a136b7ed47ce5338207148b42f8c4fd..83e105c9f41c15b6dc931b810ba85b5242926161 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild6   
-Status:        failure
-Detail:        attrValue: assertEquals failed, actual , expected Yesterday.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrappendchild6
+Status:        Success
index 6480b1546ae50855e77d5f17853666e54b4a5310..6e7bdc38902eb67103f3c88112e1f8a2780bd492 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrchildnodes1    
-Status:        failure
-Detail:        childNodesSize: assertEquals failed, actual 0, expected 1.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrchildnodes1
+Status:        Success
index 58795abc4ce8a269b99886f0442f870aa4b9c6e9..db9826437161d4ab982d87e3e34ce6c855d4a21e 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrchildnodes2    
-Status:        failure
-Detail:        childNodesSize: assertEquals failed, actual 1, expected 2.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrchildnodes2
+Status:        Success
index 14e0e590608dde26c2540e3f150e53e3472eafa7..c385eac44bbde7b95c725dcbe06e65b91928450e 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrclonenode1     
-Status:        failure
-Detail:        attrValue: assertEquals failed, actual Yes, expected Yesterday.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrclonenode1
+Status:        Success
index 847b7b38f3343ada47d8a484bc0435a0191130ce..e9fc2aff79965567ed0efad3ec73a7135bb37be2 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrcreatetextnode 
-Status:        failure
-Detail:        value: assertEquals failed, actual Yα, expected Y&ent1;.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrcreatetextnode
+Status:        Success
index 8e47f8c6822a618e7ab9fa84becb14669b930c16..a08ebfe0b4b8309a893571ccd6dbdef4ae90c831 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrfirstchild     
-Status:        failure
-Detail:        textNodeNotNull: assertNotNull failed
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrfirstchild
+Status:        Success
index 4c2fabd722561a5e6f59d6264d95c5223d284aa6..fefceadc5d813203cda920646b9c1854bdc388ab 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrhaschildnodes  
-Status:        failure
-Detail:        hasChildrenIsTrue: assertTrue failed
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrhaschildnodes
+Status:        Success
index f8c658a1c4020ee7305ce45211cf42e18cee58ac..631492a2941059d399defeb3d6341213040ff1f2 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore1  
-Status:        failure
-Detail:        attrValue: assertEquals failed, actual Yes, expected Yesterday.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore1
+Status:        Success
index fce3384a127775fb3b64c3c6efe916cb4d53bd40..b2f67e19f8de44ceb62d346fa662a77d358ac3a9 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore2  
-Status:        failure
-Detail:        attrValue: assertEquals failed, actual Yes, expected terdayYes.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore2
+Status:        Success
index 0ff7f41f08318ce91a337693493512c7320d0094..ccdb3e367aa16af52cd8e2b2988eaeb488087710 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore3  
-Status:        failure
-Detail:        attrValue: assertEquals failed, actual Yes, expected Yesterday.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore3
+Status:        Success
index f77f8ec5b5b05e3fcf5b96cc5078d600601f92e8..264d475dd10130da076978d35b9121e16d3ec18c 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore4  
-Status:        failure
-Detail:        attrValue: assertEquals failed, actual Yes, expected terdayYes.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore4
+Status:        Success
index 456021577793aed972ccfb556d4037b2510d6a26..14472ba234558b11f507b14eca4e08535c0e336f 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrlastchild      
-Status:        failure
-Detail:        textNodeNotNull: assertNotNull failed
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrlastchild
+Status:        Success
index a37f724eea523fc11315b324e1672e6214539ff6..b852409e03c87c80c046a0c9d4c407c1a3ae11a0 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrnormalize      
-Status:        failure
-Detail:        attrNodeValue: assertEquals failed, actual Yes, expected Yesterday.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrnormalize
+Status:        Success
index dfc5d2644b236b0bbfe0c04afd748a30da8e72ad..eb15e21d85444b9bad34544bd01a419fe1cc5d56 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrremovechild1   
-Status:        failure
-Detail:        attrChildNotNull: assertNotNull failed
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrremovechild1
+Status:        Success
index 5f8b5e6110db895745afa7f37914651d437a686b..c76d0a593cb2e46eb07cdbeee28ed1dccea4405a 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrreplacechild1  
-Status:        failure
-Detail:        attrChildNotNull: assertNotNull failed
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrreplacechild1
+Status:        Success
index 68b0f831b2497266f562150527d95318c1c1e7f3..798bea32d32e07e1a007ebfcb45d8ac0bd51f9a9 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrreplacechild2  
-Status:        failure
-Detail:        attrChildNotNull: assertNotNull failed
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrreplacechild2
+Status:        Success
index b8017a2c51f7341b91d7b1c1ab73c0e19fc972cb..edfe74bd1c88c43ffd1f5ac8ee8557d3e5cec953 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrsetvalue1      
-Status:        failure
-Detail:        attrChildNotNull: assertNotNull failed
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrsetvalue1
+Status:        Success
index 59e8e067da8c5d72f0251eb1ac642090e237551d..34743da9a1a54efa1d308ff119650720fdda0b3b 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrsetvalue2      
-Status:        failure
-Detail:        attrValue: assertEquals failed, actual Yes, expected Tomorrow.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrsetvalue2
+Status:        Success
index 84641bc22d7784f986600a3623aae775b6c4e317..8c4683914c8e6da7433a86fc3e7a6540960cedae 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementnormalize2  
-Status:        failure
-Detail:        firstChild: assertEquals failed, actual , expected Yes.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementnormalize2
+Status:        Success
index 15be399836fb394085003d503cf9f31c9c97d91f..05b2995af908e96652705bb785f8995b48c470c6 100644 (file)
@@ -1,3 +1,67 @@
+2005-08-19  Anders Carlsson  <andersca@mac.com>
+
+        Reviewed by Darin.
+        Landed by David Harrison.
+
+        Test cases added: None.  Fixes existing tests.
+
+        * khtml/ecma/kjs_dom.cpp:
+        Attribute values are writable
+        
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::createAttributeNS):
+        Update for new AttrImpl constructor.
+        
+        * khtml/xml/dom_elementimpl.cpp:
+        (AttributeImpl::allocateImpl):
+        Update for new AttrImpl constructor.
+        
+        (AttrImpl::AttrImpl):
+        Initialize m_ignoreChildCount to 0. If createTextChild.
+        is true, create a child text node with the contents
+        of the attribute value.
+        
+        (AttrImpl::setValue):
+        Remove all children and create a new text node with the contents
+        of the attribute value.
+        
+        (AttrImpl::cloneNode):
+        Make sure to clone any children.
+        
+        (AttrImpl::childrenChanged):
+        If m_ignoreChildrenChanged is 0, update the attribute value.
+        
+        * khtml/xml/dom_elementimpl.h:
+        Add childrenChanged, update AttrImpl constructor and
+        add m_ignoreChildrenChanged to AttrImpl.
+
+        * khtml/xml/dom_nodeimpl.cpp:
+        (DOM::NodeImpl::normalize):
+        If an element has attributes, make sure to normalize them.
+
+        * layout-tests/dom/html/level1/core/hc_attrappendchild1-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrappendchild3-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrappendchild6-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrchildnodes1-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrchildnodes2-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrclonenode1-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrcreatetextnode-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrfirstchild-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrhaschildnodes-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrinsertbefore1-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrinsertbefore2-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrinsertbefore3-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrinsertbefore4-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrlastchild-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrnormalize-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrremovechild1-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrreplacechild1-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrreplacechild2-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrsetvalue1-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_attrsetvalue2-expected.txt:
+        * layout-tests/dom/html/level1/core/hc_elementnormalize2-expected.txt:
+        These tests pass now.
+
 2005-08-19  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed by Darin.
index b98ddef90bc2d0e93e05434b72a5deaa26fa82c6..8f0594d8e611f5aa77ad904023ace83f39160b3d 100644 (file)
@@ -810,7 +810,7 @@ const ClassInfo DOMAttr::info = { "Attr", &DOMNode::info, &DOMAttrTable, 0 };
 @begin DOMAttrTable 5
   name         DOMAttr::Name           DontDelete|ReadOnly
   specified    DOMAttr::Specified      DontDelete|ReadOnly
-  value                DOMAttr::ValueProperty  DontDelete|ReadOnly
+  value                DOMAttr::ValueProperty  DontDelete
   ownerElement DOMAttr::OwnerElement   DontDelete|ReadOnly
 @end
 */
index 2286543f7fb7ca29fd7fabcc924eb8006fcdff2b..32a80aa0d0daccb555c8d7ec248fa7033e7590e7 100644 (file)
@@ -3030,7 +3030,7 @@ AttrImpl *DocumentImpl::createAttributeNS(const DOMString &namespaceURI, const D
     // documents if we're wrong.
     return new AttrImpl(0, docPtr(), new MappedAttributeImpl(QualifiedName(prefix.implementation(), 
                                                                            localName.implementation(),
-                                                                           namespaceURI.implementation()), DOMString("").implementation()));
+                                                                           namespaceURI.implementation()), DOMString("").implementation()), false);
 }
 
 SharedPtr<HTMLCollectionImpl> DocumentImpl::images()
index a70ff9bf3efcb27f293a5b0c6bb601e92a346374..179b00b07a21cbfc8fe7d6a73a7b2e0960e11d30 100644 (file)
@@ -57,18 +57,26 @@ AttributeImpl* AttributeImpl::clone(bool) const
 }
 
 void AttributeImpl::allocateImpl(ElementImpl* e) {
-    m_impl = new AttrImpl(e, e->docPtr(), this);
+    m_impl = new AttrImpl(e, e->docPtr(), this, true);
 }
 
-AttrImpl::AttrImpl(ElementImpl* element, DocumentPtr* docPtr, AttributeImpl* a)
+AttrImpl::AttrImpl(ElementImpl* element, DocumentPtr* docPtr, AttributeImpl* a, bool createTextChild)
     : ContainerNodeImpl(docPtr),
       m_element(element),
-      m_attribute(a)
+      m_attribute(a),
+      m_ignoreChildrenChanged(0)
 {
     assert(!m_attribute->m_impl);
     m_attribute->m_impl = this;
     m_attribute->ref();
     m_specified = true;
+    
+    if (createTextChild && !m_attribute->value().isEmpty()) {
+        int exceptioncode = 0;
+        m_ignoreChildrenChanged++;
+        appendChild(getDocument()->createTextNode(m_attribute->value().implementation()), exceptioncode);
+        m_ignoreChildrenChanged--;
+    }
 }
 
 AttrImpl::~AttrImpl()
@@ -113,8 +121,6 @@ void AttrImpl::setValue( const DOMString &v, int &exceptioncode )
 {
     exceptioncode = 0;
 
-    // ### according to the DOM docs, we should create an unparsed Text child
-    // node here
     // do not interprete entities in the string, its literal!
 
     // NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly
@@ -129,6 +135,12 @@ void AttrImpl::setValue( const DOMString &v, int &exceptioncode )
         return;
     }
 
+    int e = 0;
+    m_ignoreChildrenChanged++;
+    removeChildren();
+    appendChild(getDocument()->createTextNode(v.implementation()), e);
+    m_ignoreChildrenChanged--;
+    
     m_attribute->setValue(v.implementation());
     if (m_element)
         m_element->attributeChanged(m_attribute);
@@ -143,7 +155,10 @@ void AttrImpl::setNodeValue( const DOMString &v, int &exceptioncode )
 
 NodeImpl *AttrImpl::cloneNode ( bool /*deep*/)
 {
-    return new AttrImpl(0, docPtr(), m_attribute->clone());
+    AttrImpl *clone = new AttrImpl(0, docPtr(), m_attribute->clone(), false);
+    
+    cloneChildNodes(clone);
+    return clone;
 }
 
 // DOM Section 1.1.1
@@ -167,6 +182,26 @@ bool AttrImpl::childTypeAllowed( unsigned short type )
     }
 }
 
+void AttrImpl::childrenChanged()
+{
+    NodeImpl::childrenChanged();
+    
+    if (m_ignoreChildrenChanged > 0)
+        return;
+    
+    // FIXME: We should include entity references in the value
+    
+    DOMString val = "";
+    for (NodeImpl *n = firstChild(); n; n = n->nextSibling()) {
+        if (n->isTextNode())
+            val += static_cast<TextImpl *>(n)->data();
+    }
+    
+    m_attribute->setValue(val.implementation());
+    if (m_element)
+        m_element->attributeChanged(m_attribute);
+}
+
 DOMString AttrImpl::toString() const
 {
     DOMString result;
index b35de4a796088793ed361dd1552249c8c95b9c6b..94c513a3b516b6327f8fd7d3e3782c72635d12fb 100644 (file)
@@ -115,7 +115,7 @@ class AttrImpl : public ContainerNodeImpl
     friend class NamedAttrMapImpl;
 
 public:
-    AttrImpl(ElementImpl* element, DocumentPtr* docPtr, AttributeImpl* a);
+    AttrImpl(ElementImpl* element, DocumentPtr* docPtr, AttributeImpl* a, bool createTextChild);
     ~AttrImpl();
 
 private:
@@ -147,11 +147,13 @@ public:
     virtual bool childAllowed( NodeImpl *newChild );
     virtual bool childTypeAllowed( unsigned short type );
 
+    virtual void childrenChanged();
     virtual DOMString toString() const;
 
 protected:
     ElementImpl* m_element;
     AttributeImpl* m_attribute;
+    int m_ignoreChildrenChanged;
 };
 
 
index c8fa003fb33a3c36930bf37d054ccd4891cedb03..a22ec07727147ce17b96f7a3bd8eb315674b3755 100644 (file)
@@ -233,10 +233,27 @@ bool NodeImpl::hasChildNodes(  ) const
 
 void NodeImpl::normalize ()
 {
-    // ### normalize attributes? (when we store attributes using child nodes)
     int exceptioncode = 0;
     NodeImpl *child = firstChild();
 
+    if (isElementNode()) {
+        // Normalize any attribute children we might have 
+        ElementImpl *element = static_cast<ElementImpl *>(this);
+        NamedAttrMapImpl *attrMap = element->attributes();
+        
+        if (attrMap) {
+            unsigned long numAttrs = attrMap->length();
+            
+            for (unsigned long i = 0; i < numAttrs; i++) {
+                AttributeImpl *attribute = attrMap->attributeItem(i);
+                AttrImpl *attr = attribute->attrImpl();
+                
+                if (attr)
+                    attr->normalize();
+            }
+        }
+    }
+    
     // Recursively go through the subtree beneath us, normalizing all nodes. In the case
     // where there are two adjacent text nodes, they are merged together
     while (child) {