Title: [121552] trunk
Revision
121552
Author
[email protected]
Date
2012-06-29 05:08:52 -0700 (Fri, 29 Jun 2012)

Log Message

<textarea> unnecessarily saves the value in some cases
https://bugs.webkit.org/show_bug.cgi?id=90259

Reviewed by Hajime Morita.

Source/WebCore:

Test: fast/forms/textarea/textarea-state-restore.html

* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::saveFormControlState):
We apply EOL normalization to value(), but don't apply it to
defaultValue(). Also value() can return a null string, which never
equals to any strings. To check m_isDirty is what we need..

LayoutTests:

* fast/forms/textarea/textarea-state-restore-expected.txt: Added.
* fast/forms/textarea/textarea-state-restore.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (121551 => 121552)


--- trunk/LayoutTests/ChangeLog	2012-06-29 12:06:11 UTC (rev 121551)
+++ trunk/LayoutTests/ChangeLog	2012-06-29 12:08:52 UTC (rev 121552)
@@ -1,3 +1,13 @@
+2012-06-29  Kent Tamura  <[email protected]>
+
+        <textarea> unnecessarily saves the value in some cases
+        https://bugs.webkit.org/show_bug.cgi?id=90259
+
+        Reviewed by Hajime Morita.
+
+        * fast/forms/textarea/textarea-state-restore-expected.txt: Added.
+        * fast/forms/textarea/textarea-state-restore.html: Added.
+
 2012-06-29  Sudarsana Nagineni  <[email protected]>
 
         [EFL] Gardening after r121468

Added: trunk/LayoutTests/fast/forms/textarea/textarea-state-restore-expected.txt (0 => 121552)


--- trunk/LayoutTests/fast/forms/textarea/textarea-state-restore-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/textarea/textarea-state-restore-expected.txt	2012-06-29 12:08:52 UTC (rev 121552)
@@ -0,0 +1,9 @@
+Confirm nothing is saved and restored:
+PASS $("inserted").value is ""
+PASS $("saved1").value is ""
+PASS $("saved2").value is "aaa\nbbb"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+

Added: trunk/LayoutTests/fast/forms/textarea/textarea-state-restore.html (0 => 121552)


--- trunk/LayoutTests/fast/forms/textarea/textarea-state-restore.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/textarea/textarea-state-restore.html	2012-06-29 12:08:52 UTC (rev 121552)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<div id="console"></div>
+
+<input id=emptyOnFirstVisit>
+
+<script>
+jsTestIsAsync = true;
+
+function makeForms(stage) {
+    document.write('<div id=parent>');
+    document.write('<form id=form1 action=""
+    if (stage == 2)
+        document.write('<textarea id=inserted></textarea>');
+    document.write('<textarea id=saved1></textarea>');
+    document.write('<textarea id=saved2>aaa&#x0d;&#x0a;bbb</textarea>');
+    document.write('</form>');
+    document.write('</div>');
+}
+
+function runTest()
+{
+    var state = $('emptyOnFirstVisit');
+    if (!state.value) {
+        // First visit.
+        state.value = 'visited';
+        makeForms(1);
+    
+        setTimeout(function() {
+            $('form1').submit();
+        }, 0);
+    } else {
+        // Second visit.
+        makeForms(2);
+    
+        debug('Confirm nothing is saved and restored:');
+        shouldBeEqualToString('$("inserted").value', '');
+        shouldBeEqualToString('$("saved1").value', '');
+        shouldBeEqualToString('$("saved2").value', 'aaa\nbbb');
+    
+        $('parent').innerHTML = '';
+        setTimeout(function() { finishJSTest(); }, 0);
+    }
+}
+
+runTest();
+</script>
+<script src=""
+</body>

Modified: trunk/Source/WebCore/ChangeLog (121551 => 121552)


--- trunk/Source/WebCore/ChangeLog	2012-06-29 12:06:11 UTC (rev 121551)
+++ trunk/Source/WebCore/ChangeLog	2012-06-29 12:08:52 UTC (rev 121552)
@@ -1,3 +1,18 @@
+2012-06-29  Kent Tamura  <[email protected]>
+
+        <textarea> unnecessarily saves the value in some cases
+        https://bugs.webkit.org/show_bug.cgi?id=90259
+
+        Reviewed by Hajime Morita.
+
+        Test: fast/forms/textarea/textarea-state-restore.html
+
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::saveFormControlState):
+        We apply EOL normalization to value(), but don't apply it to
+        defaultValue(). Also value() can return a null string, which never
+        equals to any strings. To check m_isDirty is what we need..
+
 2012-06-25  Alexander Pavlov  <[email protected]>
 
         Web Inspector: Provide source data for all known rule types in CSSParser, except "keyframe" and "region"

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (121551 => 121552)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2012-06-29 12:06:11 UTC (rev 121551)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2012-06-29 12:08:52 UTC (rev 121552)
@@ -101,10 +101,7 @@
 
 FormControlState HTMLTextAreaElement::saveFormControlState() const
 {
-    String currentValue = value();
-    if (currentValue == defaultValue())
-        return FormControlState();
-    return FormControlState(currentValue);
+    return m_isDirty ? FormControlState(value()) : FormControlState();
 }
 
 void HTMLTextAreaElement::restoreFormControlState(const FormControlState& state)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to