Reviewed by Maciej.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Mar 2006 04:23:18 +0000 (04:23 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Mar 2006 04:23:18 +0000 (04:23 +0000)
        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=4616
          Setting nodeValue on a textnode with collapsed whitespace only has no visual effect

        Test: fast/dom/space-to-text.html

        * dom/CharacterData.cpp:
        (WebCore::CharacterData::setData): Create a renderer if it's needed, but missing.
        (WebCore::CharacterData::appendData): Ditto.
        (WebCore::CharacterData::insertData): Ditto.
        (WebCore::CharacterData::replaceData): Ditto.

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/space-to-text-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/space-to-text.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/CharacterData.cpp

index 55f5ac6e7fba1a6c81558fa4203e8a3e3a6f2690..7404cf8e78f3f9201f30f6b2a5ba803a3fe3a9d2 100644 (file)
@@ -1,3 +1,13 @@
+2006-03-28  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Maciej.
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=4616
+          Setting nodeValue on a textnode with collapsed whitespace only has no visual effect
+
+        * fast/dom/space-to-text-expected.txt: Added.
+        * fast/dom/space-to-text.html: Added.
+
 2006-03-28  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by darin.
diff --git a/LayoutTests/fast/dom/space-to-text-expected.txt b/LayoutTests/fast/dom/space-to-text-expected.txt
new file mode 100644 (file)
index 0000000..2a299f0
--- /dev/null
@@ -0,0 +1,9 @@
+Test for bug 4616: Setting textNode.nodeValue does not work when nodeValue is whitespace only.
+
+Should say "SUCCESS":
+
+SU
+CC
+ES
+S
+
diff --git a/LayoutTests/fast/dom/space-to-text.html b/LayoutTests/fast/dom/space-to-text.html
new file mode 100644 (file)
index 0000000..a9e3996
--- /dev/null
@@ -0,0 +1,20 @@
+<html>
+<head>
+<script type="text/javascript">
+function test() {
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    document.getElementById("s1").firstChild.nodeValue="SU";
+    document.getElementById("s2").firstChild.insertData(0, "CC");
+    document.getElementById("s3").firstChild.appendData("ES");
+    document.getElementById("s4").firstChild.replaceData(0, 1, "S");
+}
+</script>
+<body onLoad="test()">
+<p>Test for <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=4616">bug 4616</a>:
+Setting textNode.nodeValue does not work when nodeValue is whitespace only.</p>
+<p>Should say "SUCCESS":</p>
+<div id="s1"> </div><div id="s2"> </div><div id="s3"> </div><div id="s4"> </div>
+</body>
+</html>
index c412c7bf76711d1ab822de80a8cf84382a7951aa..65ca78253a91b1d1a1ce5908f4adde8622351d02 100644 (file)
@@ -1,3 +1,18 @@
+2006-03-28  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Maciej.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=4616
+          Setting nodeValue on a textnode with collapsed whitespace only has no visual effect
+
+        Test: fast/dom/space-to-text.html
+
+        * dom/CharacterData.cpp:
+        (WebCore::CharacterData::setData): Create a renderer if it's needed, but missing.
+        (WebCore::CharacterData::appendData): Ditto.
+        (WebCore::CharacterData::insertData): Ditto.
+        (WebCore::CharacterData::replaceData): Ditto.
+
 2006-03-28  Tim Omernick  <timo@apple.com>
 
         Reviewed by Maciej.
index cf11d83172be3f69fbadbc9a0e452e0ebb1574e2..c6da6ad9c6ea3d49b3f75fce153c8cd84b77da39 100644 (file)
@@ -69,7 +69,14 @@ void CharacterData::setData( const String &_data, ExceptionCode& ec)
     if(str == _data.impl()) return; // ### fire DOMCharacterDataModified if modified?
     StringImpl *oldStr = str;
     str = _data.impl();
-    if(str) str->ref();
+    if (str)
+        str->ref();
+    
+    if (!renderer() && attached()) {
+        detach();
+        attach();
+    }
+    
     if (renderer())
         static_cast<RenderText*>(renderer())->setText(str);
     
@@ -108,6 +115,12 @@ void CharacterData::appendData( const String &arg, ExceptionCode& ec)
     str = str->copy();
     str->ref();
     str->append(arg.impl());
+
+    if (!renderer() && attached()) {
+        detach();
+        attach();
+    }
+
     if (renderer())
         static_cast<RenderText*>(renderer())->setTextWithOffset(str, oldStr->length(), 0);
     
@@ -126,6 +139,12 @@ void CharacterData::insertData( const unsigned offset, const String &arg, Except
     str = str->copy();
     str->ref();
     str->insert(arg.impl(), offset);
+
+    if (!renderer() && attached()) {
+        detach();
+        attach();
+    }
+
     if (renderer())
         static_cast<RenderText*>(renderer())->setTextWithOffset(str, offset, 0);
     
@@ -177,6 +196,12 @@ void CharacterData::replaceData( const unsigned offset, const unsigned count, co
     str->ref();
     str->remove(offset,realCount);
     str->insert(arg.impl(), offset);
+
+    if (!renderer() && attached()) {
+        detach();
+        attach();
+    }
+
     if (renderer())
         static_cast<RenderText*>(renderer())->setTextWithOffset(str, offset, count);