WebCore:
authorddkilzer <ddkilzer@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2006 19:09:54 +0000 (19:09 +0000)
committerddkilzer <ddkilzer@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2006 19:09:54 +0000 (19:09 +0000)
        Reviewed by Darin.

        - Fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9358
          REGRESSION: Assertion failure in HTMLInputElement::setValueFromRenderer
          (value == constrainValue(value)) when deleting all text

        Test: editing/deleting/delete-all-text-in-text-field-assertion.html

        Bug 9661 filed to fix the follow-up issue:
        http://bugzilla.opendarwin.org/show_bug.cgi?id=9661
        textContent returns "\n" for a <br> even if it is collapsed

        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::setValueFromRenderer): Work around "\n" value
        when all characters are deleted from a text field.

LayoutTests:

        Reviewed by Darin.

        - Test for http://bugzilla.opendarwin.org/show_bug.cgi?id=9358
          REGRESSION: Assertion failure in HTMLInputElement::setValueFromRenderer
          (value == constrainValue(value)) when deleting all text

        * editing/deleting/delete-all-text-in-text-field-assertion-expected.txt: Added.
        * editing/deleting/delete-all-text-in-text-field-assertion.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/deleting/delete-all-text-in-text-field-assertion-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-all-text-in-text-field-assertion.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLInputElement.cpp

index d159a9d23886415b604679d781446e4754ccc55d..e843d71c6c977d6156109b11e40ab30492d37b09 100644 (file)
@@ -1,3 +1,14 @@
+2006-06-30  David Kilzer  <ddkilzer@kilzer.net>
+
+        Reviewed by Darin.
+
+        - Test for http://bugzilla.opendarwin.org/show_bug.cgi?id=9358
+          REGRESSION: Assertion failure in HTMLInputElement::setValueFromRenderer
+          (value == constrainValue(value)) when deleting all text
+
+        * editing/deleting/delete-all-text-in-text-field-assertion-expected.txt: Added.
+        * editing/deleting/delete-all-text-in-text-field-assertion.html: Added.
+
 2006-06-29  Sam Weinig  <sam.weinig@gmail.com>
 
         Reviewed by Hyatt.
diff --git a/LayoutTests/editing/deleting/delete-all-text-in-text-field-assertion-expected.txt b/LayoutTests/editing/deleting/delete-all-text-in-text-field-assertion-expected.txt
new file mode 100644 (file)
index 0000000..ef48c7c
--- /dev/null
@@ -0,0 +1,11 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of #text > DIV to 1 of #text > DIV toDOMRange:range from 0 of #text > DIV to 1 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV to 0 of DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+Bug 9358: REGRESSION: Assertion failure in HTMLInputElement::setValueFromRenderer (value == constrainValue(value)) when deleting all text
+http://bugzilla.opendarwin.org/show_bug.cgi?id=9358
+
+Assertion fails when all characters are deleted: 
+SUCCESS if the test didn't crash and you see this message.
+
diff --git a/LayoutTests/editing/deleting/delete-all-text-in-text-field-assertion.html b/LayoutTests/editing/deleting/delete-all-text-in-text-field-assertion.html
new file mode 100644 (file)
index 0000000..352b9d9
--- /dev/null
@@ -0,0 +1,30 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+    layoutTestController.dumpAsText();
+}
+</script>
+<script src="../editing.js"></script>
+</head>
+<body>
+<div>Bug 9358: REGRESSION: Assertion failure in HTMLInputElement::setValueFromRenderer (value == constrainValue(value)) when deleting all text</div>
+<div><a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=9358">http://bugzilla.opendarwin.org/show_bug.cgi?id=9358</a></div>
+<div><br></div>
+<form>
+Assertion fails when all characters are deleted: <input type="text" id="t" value="X">
+</form>
+<script>
+document.getElementById("t").focus();
+document.execCommand("SelectAll");
+document.execCommand("Delete");
+</script>
+<div>SUCCESS if the test didn't crash and you see this message.</div>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.notifyDone()
+}
+</script>
+<body>
+</html>
index 37f4437c018eb378858c5202cc5725ba801db103..acd772f0ff7f56f5c94239665d50d31a41aed3b7 100644 (file)
@@ -1,3 +1,21 @@
+2006-06-30  David Kilzer  <ddkilzer@kilzer.net>
+
+        Reviewed by Darin.
+
+        - Fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9358
+          REGRESSION: Assertion failure in HTMLInputElement::setValueFromRenderer
+          (value == constrainValue(value)) when deleting all text
+
+        Test: editing/deleting/delete-all-text-in-text-field-assertion.html
+
+        Bug 9661 filed to fix the follow-up issue:
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=9661
+        textContent returns "\n" for a <br> even if it is collapsed
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::setValueFromRenderer): Work around "\n" value
+        when all characters are deleted from a text field.
+
 2006-06-30  David Harrison  <harrison@apple.com>
 
         Reviewed by Tim Omernick
index ccafe09765740a6485e98088876c9501b7922b35..7b5b3007aee3605895a0b2bd7b7408b0071f8ac2 100644 (file)
@@ -1089,9 +1089,16 @@ void HTMLInputElement::setValue(const String& value)
 void HTMLInputElement::setValueFromRenderer(const String& value)
 {
     // Renderer and our event handler are responsible for constraining values.
-    ASSERT(value == constrainValue(value));
+    ASSERT(value == constrainValue(value) || constrainValue(value).isEmpty());
+
+    // Workaround for bug where trailing \n is included in the result of textContent.
+    // The assert macro above may also be simplified to:  value == constrainValue(value)
+    // http://bugzilla.opendarwin.org/show_bug.cgi?id=9661
+    if (value == "\n")
+        m_value = "";
+    else
+        m_value = value;
 
-    m_value = value;
     setValueMatchesRenderer();
 
     // Fire the "input" DOM event.