When WebKit loads a textarea, it removes the first blank line it finds in it. Steps to reproduce: 1) Open the URL in Safari, look at the textareas. 2) Open the URL in Firefox 4 (not 3), look again. 3) Firefox 4 keeps the blank lines, WebKit doesn't. Additional notes: a) Reported in Firefox here: https://bugzilla.mozilla.org/show_bug.cgi?id=591988 b) Fixed in Firefox here: https://bugzilla.mozilla.org/show_bug.cgi?id=620267
Works in Safari 5.0.4.
<rdar://problem/9142454>
This regressed in nightly r64727. So, the culprit revision is in [64637, 64727]. If I have some time then I'll try to bisect this further/look through the change log entries in this range.
http://trac.webkit.org/log/trunk/WebCore?action=stop_on_copy&mode=stop_on_copy&rev=64727&stop_rev=64637&limit=100 Suspicious changes: http://trac.webkit.org/changeset/64712 http://trac.webkit.org/changeset/64711 http://trac.webkit.org/changeset/64702 http://trac.webkit.org/changeset/64677
Adam & Eric, Can this be a HTML5 Tree Builder regression?
Anything could be an HTML5 regression. :) Although this may also be an intentional change in HTML5. We'd need to check the spec.
I suspect we will be finding (long tail) fallout from our HTML5 parser re-write for years.
Differences between Firefox 4 are likely to be bugs in our code.
I know there is special code for removing the first \n in a <pre> tag. I'm not sure about <textarea> without checking the spec.
Just confirming that this is caused by turning on the HTML5 tree builder in <http://trac.webkit.org/changeset/64712>.
Capturing test case in case the site goes down: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang='en'> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> </head> <body> <p><textarea cols="20" rows="6">No blank lines here</textarea></p> <p><textarea cols="20" rows="6"> No blank lines here</textarea></p> <p><textarea cols="20" rows="6"> One blank line here</textarea></p> <p><textarea cols="20" rows="6"> Two blank lines here</textarea></p> </body> </html>
Looking in the Web Inspector, it looks like the DOM has the proper number of blank lines. I suspect we used to strip the initial blank line in the render tree rather than in the parser. We're now probably stripping it twice (both in the parser and in the render tree).
Created attachment 87250 [details] Patch
Comment on attachment 87250 [details] Patch Please review.
Comment on attachment 87250 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=87250&action=review > LayoutTests/fast/forms/textarea-newline.html:12 > +<script> > + function checkValue(id, value) { > + var ta = document.getElementById(id); > + if (ta.value == value) > + document.getElementById(id + '_res').innerHTML = "Test Passed"; > + > + } > + function test() { > + if (window.layoutTestController) > + layoutTestController.dumpAsText(); This test is acceptable, however I recommend to use fast/js/resources/js-test-pre.js and js-test-post.js. They make the test simpler. > Source/WebCore/ChangeLog:8 > + REGRESSION (r64712): Safari removes the first blank line in a textarea > + https://bugs.webkit.org/show_bug.cgi?id=56434 > + > + Test: fast/forms/textarea-newline.html Would you write a reason why HTML5 tree builder made the regression and why this change fixes it please?
Created attachment 87255 [details] Patch
Comment on attachment 87255 [details] Patch Please review.
Comment on attachment 87255 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=87255&action=review > LayoutTests/fast/forms/textarea-newline-expected.txt:10 > +No line feed. > + > +One line feed after textarea tag is ignored. > + > +Two line feeds after textarea tag and the first one is ignored. > + > +One line feed escaped character after textarea tag and line feed and both are not ignored. > + > +Two line feed escaped characters after textarea tag and both are not ignored. The readability of the test result is not good. These five sentences are confusing. I recommend: - Remove them, and - Print them by debug() function, or change ID names. e.g. debug('No line feed.'); var textarea = document.getElementById('Madoka'); shouldBe('textarea.value', '"Madoka"'); or Replacing id="Madoka" with id="no-line-feed", and shouldBe('document.getElementById("no-line-feed").value', '"Madoka"'); > LayoutTests/fast/forms/textarea-newline.html:46 > +var textarea = document.getElementById('Madoka'); > +shouldBe('textarea.value', '"Madoka"'); > + > +var textarea = document.getElementById('Sayaka'); Declaring "var textarea" multiple times is not good. > Source/WebCore/ChangeLog:12 > + A linefeed removal after a textarea tag is originally processed in WebCore::HTMLTextAreaElement::defaultValue(). > + But HTML5 tree builder now removes the linefeed. It means linefeed removal happens twice. > + And devalutValue() removal is not needed anymore. Great. Thank you.
Created attachment 87263 [details] Patch
Comment on attachment 87263 [details] Patch Review again.
Comment on attachment 87263 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=87263&action=review > LayoutTests/fast/forms/textarea-newline.html:11 > +<br> > +No line feed. Please remove it. > LayoutTests/fast/forms/textarea-newline.html:17 > +<br> > +One line feed after textarea tag is ignored. > +<br> ditto. > LayoutTests/fast/forms/textarea-newline.html:23 > +<br> > +Two line feeds after textarea tag and the first one is ignored. > +<br> ditto. > LayoutTests/fast/forms/textarea-newline.html:30 > +<br> > +One line feed escaped character after textarea tag and line feed and both are not ignored. > +<br> ditto. > LayoutTests/fast/forms/textarea-newline.html:36 > +<br> > +Two line feed escaped characters after textarea tag and both are not ignored. > +<br> ditto.
Created attachment 87266 [details] Patch
Comment on attachment 87266 [details] Patch Great!
Comment on attachment 87266 [details] Patch Sorry for bothering you again and again. Please review.
Comment on attachment 87266 [details] Patch Rejecting attachment 87266 [details] from commit-queue. Failed to run "['./Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '--bot-id=eseidel-cq-sf', 'bu..." exit_code: 2 Last 500 characters of output: ......................................................................................................................................................................................................................................................... fast/forms/textarea-default-value-leading-newline.html -> failed Exiting early after 1 failures. 8825 tests run. 212.47s total testing time 8824 test cases (99%) succeeded 1 test case (<1%) had incorrect layout 4 test cases (<1%) had stderr output Full output: http://queues.webkit.org/results/8273842
(In reply to comment #25) > fast/forms/textarea-default-value-leading-newline.html -> failed Yeah, we need to update setDefaultValue() too.
Created attachment 87815 [details] Patch
Comment on attachment 87815 [details] Patch Fixed setDefaultValue() function. Please review again.
Comment on attachment 87815 [details] Patch Clearing flags on attachment: 87815 Committed r82656: <http://trac.webkit.org/changeset/82656>
All reviewed patches have been landed. Closing bug.