Changeset 31081 in webkit


Ignore:
Timestamp:
Mar 16, 2008 1:17:54 PM (16 years ago)
Author:
Darin Adler
Message:

WebCore:

2008-03-16 Darin Adler <Darin Adler>

Reviewed by Mitz.

Test: fast/forms/textarea-trailing-newline.html

  • rendering/RenderTextControl.cpp: (WebCore::RenderTextControl::finishText): Added code to strip the trailing newline. It's possible there are some obscure cases where this is not wanted, but I couldn't find any. If someone finds a case where this is bad, we can make the code conditional.

LayoutTests:

2008-03-16 Darin Adler <Darin Adler>

Reviewed by Mitz.

  • fast/forms/textarea-paste-newline.html: Updated test to expect correct behavior instead of expecting the bug.
  • fast/forms/textarea-trailing-newline-expected.txt: Added.
  • fast/forms/textarea-trailing-newline.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r31075 r31081  
     12008-03-16  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Mitz.
     4
     5        - test for http://bugs.webkit.org/show_bug.cgi?id=14941
     6          <rdar://problem/5404093> textarea value from JavaScript includes extra newline
     7
     8        * fast/forms/textarea-paste-newline.html: Updated test to expect correct behavior instead
     9        of expecting the bug.
     10
     11        * fast/forms/textarea-trailing-newline-expected.txt: Added.
     12        * fast/forms/textarea-trailing-newline.html: Added.
     13
    1142008-03-15  Darin Adler  <darin@apple.com>
    215
  • trunk/LayoutTests/fast/forms/textarea-paste-newline.html

    r25332 r31081  
    1515    var result2 = ta.value;
    1616
    17     if (result1 == "abc\n\n" && result2 == "abc\nabc\n\n")
     17    if (result1 == "abc\n" && result2 == "abc\nabc\n")
    1818        document.write("<p>Hooray, the test was successful!</p>");
    1919    else if (result1 == "")
    2020        document.write("<p>The test failed; doesn't work in release builds of Safari because paste is not allowed.</p>");
    2121    else
    22         document.write("<p>The test failed, result 1 was '" + result1.replace("\n", "\\n") + "' and result 2 was '" + result2.replace("\n", "\\n") + "'. This test demonstrates a bug (5299425): the final '\\n' in a textarea is reported by .value even if it is collapsed.</p>");
     22        document.write("<p>The test failed, result 1 was '" + result1.replace("\n", "\\n") + "' and result 2 was '" + result2.replace("\n", "\\n") + "'.</p>");
    2323}
    2424</script>
  • trunk/WebCore/ChangeLog

    r31080 r31081  
     12008-03-16  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Mitz.
     4
     5        - fix http://bugs.webkit.org/show_bug.cgi?id=14941
     6          <rdar://problem/5404093> textarea value from JavaScript includes extra newline
     7
     8        Test: fast/forms/textarea-trailing-newline.html
     9
     10        * rendering/RenderTextControl.cpp:
     11        (WebCore::RenderTextControl::finishText): Added code to strip the trailing
     12        newline. It's possible there are some obscure cases where this is not wanted,
     13        but I couldn't find any. If someone finds a case where this is bad, we can
     14        make the code conditional.
     15
    1162008-03-16  Darin Adler  <darin@apple.com>
    217
  • trunk/WebCore/rendering/RenderTextControl.cpp

    r30973 r31081  
    556556String RenderTextControl::finishText(Vector<UChar>& result) const
    557557{
     558    // Remove one trailing newline; there's always one that's collapsed out by rendering.
     559    size_t size = result.size();
     560    if (size && result[size - 1] == '\n')
     561        result.shrink(--size);
     562
     563    // Convert backslash to currency symbol.
    558564    UChar symbol = backslashAsCurrencySymbol();
    559565    if (symbol != '\\') {
    560         size_t size = result.size();
    561         for (size_t i = 0; i < size; ++i)
     566        for (size_t i = 0; i < size; ++i) {
    562567            if (result[i] == '\\')
    563568                result[i] = symbol;
     569        }
    564570    }
    565571
Note: See TracChangeset for help on using the changeset viewer.