2006-12-18 Kirby White <KWhiteRight@gmail.com>
authorbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Dec 2006 23:22:20 +0000 (23:22 +0000)
committerbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Dec 2006 23:22:20 +0000 (23:22 +0000)
        Reviewed by Darin.

        Changed hidden input controls to reset to their initial values
        when the form is reset.  Also added layout tests for resetting
        other input controls.

        Fixes http://bugs.webkit.org/show_bug.cgi?id=11866

        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::setValue):
        (WebCore::HTMLInputElement::storesValueSeparateFromAttribute):

2006-12-18  Kirby White  <KWhiteRight@gmail.com>

        Reviewed by Darin.

        Layout tests for http://bugs.webkit.org/show_bug.cgi?id=11866

        * fast/dom/HTMLInputElement/input-checked-reset-expected.txt: Added.
        * fast/dom/HTMLInputElement/input-checked-reset.html: Added.
        * fast/dom/HTMLInputElement/input-text-reset-expected.txt: Added.
        * fast/dom/HTMLInputElement/input-text-reset.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLInputElement/input-checked-reset-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLInputElement/input-checked-reset.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLInputElement/input-text-reset-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLInputElement/input-text-reset.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLInputElement.cpp

index 03a77833a73734c6e8dc804e944f217981f82668..fccc394d8ebc186108b68061e25dad41dc46ae1e 100644 (file)
@@ -1,3 +1,14 @@
+2006-12-18  Kirby White  <KWhiteRight@gmail.com>
+
+        Reviewed by Darin.
+
+        Layout tests for http://bugs.webkit.org/show_bug.cgi?id=11866
+
+        * fast/dom/HTMLInputElement/input-checked-reset-expected.txt: Added.
+        * fast/dom/HTMLInputElement/input-checked-reset.html: Added.
+        * fast/dom/HTMLInputElement/input-text-reset-expected.txt: Added.
+        * fast/dom/HTMLInputElement/input-text-reset.html: Added.
+
 2006-12-18  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Mitz.
diff --git a/LayoutTests/fast/dom/HTMLInputElement/input-checked-reset-expected.txt b/LayoutTests/fast/dom/HTMLInputElement/input-checked-reset-expected.txt
new file mode 100644 (file)
index 0000000..6ea722c
--- /dev/null
@@ -0,0 +1,14 @@
+
+
+
+
+ Reset Button
+This test verifies that check-type input form controls are properly reset by both a reset input control and a reset button control.
+
+You should see four element IDs below, and the word "SUCCESS" twice after each:
+
+checkboxUnchecked : SUCCESS : SUCCESS 
+checkboxChecked : SUCCESS : SUCCESS 
+radioUnchecked : SUCCESS : SUCCESS 
+radioChecked : SUCCESS : SUCCESS 
+
diff --git a/LayoutTests/fast/dom/HTMLInputElement/input-checked-reset.html b/LayoutTests/fast/dom/HTMLInputElement/input-checked-reset.html
new file mode 100644 (file)
index 0000000..1b78948
--- /dev/null
@@ -0,0 +1,56 @@
+<html>
+<head>
+</head>
+<body>
+<form>
+<input id="checkboxUnchecked" type="checkbox" value="Unchecked"><br>
+<input id="checkboxChecked" type="checkbox" value="Checked" checked="checked"><br>
+<input id="radioUnchecked" name="radio1" type="radio" value="Unchecked"><br>
+<input id="radioChecked" name="radio1" type="radio" value="Checked" checked="checked"><br>
+
+<input id="inputReset" type="reset">
+<button id="buttonReset" type="reset">Reset Button</button>
+</form>
+<p>This test verifies that check-type input form controls are properly reset by
+both a reset input control and a reset button control.
+
+<p>You should see four element IDs below, and the word "SUCCESS" twice after each:</p>
+
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+var inputReset = document.getElementById("inputReset");
+var buttonReset = document.getElementById("buttonReset");
+
+function testChecked(testElement, expected, button)
+{
+    var success = false;
+    if (testElement.checked == expected)
+    {
+        testElement.checked = !expected;
+        button.click();
+        if (testElement.checked == expected)
+            success = true;
+    }
+    if (success)
+        document.writeln(": SUCCESS");
+    else
+        document.writeln(": FAILED (checked = " + testElement.checked + ")");
+}
+
+function test(elementId, expected)
+{
+    var element = document.getElementById(elementId);
+    document.writeln(elementId);
+    testChecked(element, expected, inputReset);
+    testChecked(element, expected, buttonReset);
+    document.writeln("<br>");
+}
+
+test("checkboxUnchecked", false);
+test("checkboxChecked", true);
+test("radioUnchecked", false);
+test("radioChecked", true);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLInputElement/input-text-reset-expected.txt b/LayoutTests/fast/dom/HTMLInputElement/input-text-reset-expected.txt
new file mode 100644 (file)
index 0000000..382df80
--- /dev/null
@@ -0,0 +1,18 @@
+
+
+
+
+
+ Reset Button
+This test verifies that text-type input form controls are properly reset by both a reset input control and a reset button control.
+(But file input element values can't be modified by JS, so this test can't be used for those.)
+
+You should see six element IDs below, and the word "SUCCESS" twice after each:
+
+textEmpty : SUCCESS : SUCCESS 
+textValue : SUCCESS : SUCCESS 
+passwordEmpty : SUCCESS : SUCCESS 
+passwordValue : SUCCESS : SUCCESS 
+hiddenEmpty : SUCCESS : SUCCESS 
+hiddenValue : SUCCESS : SUCCESS 
+
diff --git a/LayoutTests/fast/dom/HTMLInputElement/input-text-reset.html b/LayoutTests/fast/dom/HTMLInputElement/input-text-reset.html
new file mode 100644 (file)
index 0000000..14bf149
--- /dev/null
@@ -0,0 +1,62 @@
+<html>
+<head>
+</head>
+<body>
+<form>
+<input id="textEmpty" type="text"><br>
+<input id="textValue" type="text" value="Default Value"><br>
+<input id="passwordEmpty" type="password"><br>
+<input id="passwordValue" type="password" value="Default Value"><br>
+<input id="hiddenEmpty" type="hidden"><br>
+<input id="hiddenValue" type="hidden" value="Default Value">
+
+<input id="inputReset" type="reset">
+<button id="buttonReset" type="reset">Reset Button</button>
+</form>
+<p>This test verifies that text-type input form controls are properly reset by
+both a reset input control and a reset button control.<br>
+(But file input element values can't be modified by JS, so this test can't be
+used for those.)</p>
+
+<p>You should see six element IDs below, and the word "SUCCESS" twice after each:</p>
+
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+var inputReset = document.getElementById("inputReset");
+var buttonReset = document.getElementById("buttonReset");
+
+function testValue(testElement, expected, button)
+{
+    var success = false;
+    if (testElement.value == expected)
+    {
+        testElement.value = "Not Expected! " + expected;
+        button.click();
+        if (testElement.value == expected)
+          success = true;
+    }
+    if (success)
+        document.writeln(": SUCCESS");
+    else
+        document.writeln(": FAILED (value = " + testElement.value + ")");
+}
+
+function test(elementId, expected)
+{
+    var element = document.getElementById(elementId);
+    document.writeln(elementId);
+    testValue(element, expected, inputReset);
+    testValue(element, expected, buttonReset);
+    document.writeln("<br>");
+}
+
+test("textEmpty", "");
+test("textValue", "Default Value");
+test("passwordEmpty", "");
+test("passwordValue", "Default Value");
+test("hiddenEmpty", "");
+test("hiddenValue", "Default Value");
+</script>
+</body>
+</html>
index a0f9fed08b5a003ea18160665e584fb9a0a5da16..e7282ea6004f6b016dc66050a094a4e8d2e35889 100644 (file)
@@ -1,3 +1,17 @@
+2006-12-18  Kirby White  <KWhiteRight@gmail.com>
+
+        Reviewed by Darin.
+
+        Changed hidden input controls to reset to their initial values
+        when the form is reset.  Also added layout tests for resetting
+        other input controls.
+
+        Fixes http://bugs.webkit.org/show_bug.cgi?id=11866
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::setValue):
+        (WebCore::HTMLInputElement::storesValueSeparateFromAttribute):
+
 2006-12-18  Alice Liu  <alice.liu@apple.com>
 
         Oops forgot a file. 
index 963b2f9eaefabac73b78d1de6f5930b2461bfe17..6fe5bfbf1160cb93deb7f8fe2b9ed35b4525c49b 100644 (file)
@@ -1070,7 +1070,9 @@ void HTMLInputElement::setValue(const String& value)
         m_value = constrainValue(value);
         if (renderer())
             renderer()->updateFromElement();
-        setChanged();
+        // Changes to hidden values don't require re-rendering.
+        if (m_type != HIDDEN)
+            setChanged();
     } else
         setAttribute(valueAttr, constrainValue(value));
     
@@ -1107,13 +1109,13 @@ bool HTMLInputElement::storesValueSeparateFromAttribute() const
         case BUTTON:
         case CHECKBOX:
         case FILE:
-        case HIDDEN:
         case IMAGE:
         case RADIO:
         case RANGE:
         case RESET:
         case SUBMIT:
             return false;
+        case HIDDEN:
         case ISINDEX:
         case PASSWORD:
         case SEARCH: