<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>8104</bug_id>
          
          <creation_ts>2006-03-31 09:33:45 -0800</creation_ts>
          <short_desc>REGRESSION (NativeTextField): New text fields should not allow pasting newlines</short_desc>
          <delta_ts>2006-04-04 01:55:43 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Forms</component>
          <version>420+</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Regression</keywords>
          <priority>P1</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>mitz</reporter>
          <assigned_to name="Adele Peterson">adele</assigned_to>
          <cc>sdfisher</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>38086</commentid>
    <comment_count>0</comment_count>
    <who name="">mitz</who>
    <bug_when>2006-03-31 09:33:45 -0800</bug_when>
    <thetext>New text fields allow you to paste text containing newlines, and then their height changes to accommodate the multi-line text.

Old behavior was to paste the text only up to the first newline.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38105</commentid>
    <comment_count>1</comment_count>
    <who name="Adele Peterson">adele</who>
    <bug_when>2006-03-31 13:00:10 -0800</bug_when>
    <thetext>*** Bug 8107 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38116</commentid>
    <comment_count>2</comment_count>
    <who name="Adele Peterson">adele</who>
    <bug_when>2006-03-31 14:11:02 -0800</bug_when>
    <thetext>ok- i&apos;m working on this now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38134</commentid>
    <comment_count>3</comment_count>
      <attachid>7429</attachid>
    <who name="Adele Peterson">adele</who>
    <bug_when>2006-03-31 17:10:28 -0800</bug_when>
    <thetext>Created attachment 7429
initial patch

posting an initial patch...

I ran into a problem while testing a simpler version of this patch.  If you select all at cnn.com, and then go to paste that content into the text field, we ended up pasting in a newline at the end.  I realized that if we did a test rendering of the plain-text conversion first, and then sent the BeforeTextInserted event (which causes the truncation).

I don&apos;t like doing another test rendering in ReplaceSelectionCommand though.  So I&apos;m trying to find a better solution.  Feel free to jump in w/ ideas :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38180</commentid>
    <comment_count>4</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2006-04-01 08:50:11 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; I don&apos;t like doing another test rendering in ReplaceSelectionCommand though. 
&gt; So I&apos;m trying to find a better solution.  Feel free to jump in w/ ideas :)

Well, this version seems fine to me; we shouldn&apos;t worry unduly about the extra text rendering for now. But if you are doing this, you should move more lines inside the if statement. Specifically, these three don&apos;t need to be done twice if you aren&apos;t in the plain text case:

+    range-&gt;selectNodeContents(holder.get(), ec);
+    ASSERT(ec == 0);
+    text = plainText(range.get());

The use of min/max here is a bit confusing because of the special case for -1. You should probably just write it out like this:

        if (newLinePosition &gt;= 0 &amp;&amp; (truncateLength &lt; 0 || truncateLength &gt; newLinePosition))
            truncateLength = newLinePosition;
 
I think that&apos;s a little clearer. Another possibility would be to write a local function that is a version of min that handles the -1 value as a special case.

    static int minPosition(int p1, int p2)
    {
        if (p1 &lt; 0)
            return p2;
        if (p2 &lt; 0)
            return p1;
        return min(p1, p2);
    }

        truncateLength = minPosition(truncateLength, newLinePosition);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38181</commentid>
    <comment_count>5</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2006-04-01 08:53:12 -0800</bug_when>
    <thetext>(In reply to comment #4)
&gt; I think that&apos;s a little clearer. Another possibility would be to write a local
&gt; function that is a version of min that handles the -1 value as a special case.

Or you could initialize truncateLength to text.length() to simplify the code a bit. You&apos;re stuck with the &quot;-1&quot; for the find result, but not for your own code. You could even cover find with something that returns the string length instead of -1 when not finding anything.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38353</commentid>
    <comment_count>6</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2006-04-02 23:25:42 -0700</bug_when>
    <thetext>These are all text field regressions so they should all be P1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38420</commentid>
    <comment_count>7</comment_count>
    <who name="Adele Peterson">adele</who>
    <bug_when>2006-04-03 14:11:13 -0700</bug_when>
    <thetext>With further testing, and talking w/ Justin, I don&apos;t think we actually need to change how ReplaceSelectionCommand works for this fix.

Justin reviewed a simpler patch that just does the truncation in HTMLInputElement.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>7429</attachid>
            <date>2006-03-31 17:10:28 -0800</date>
            <delta_ts>2006-03-31 17:10:28 -0800</delta_ts>
            <desc>initial patch</desc>
            <filename>patch.txt</filename>
            <type>text/plain</type>
            <size>2820</size>
            <attacher name="Adele Peterson">adele</attacher>
            
              <data encoding="base64">SW5kZXg6IGh0bWwvSFRNTElucHV0RWxlbWVudC5jcHAKPT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gaHRtbC9IVE1M
SW5wdXRFbGVtZW50LmNwcAkocmV2aXNpb24gMTM2MTkpCisrKyBodG1sL0hUTUxJbnB1dEVsZW1l
bnQuY3BwCSh3b3JraW5nIGNvcHkpCkBAIC01MCw2ICs1MCw3IEBACiAKIHVzaW5nIG5hbWVzcGFj
ZSBFdmVudE5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kZShob2xk
ZXIpOwogICAgICAgICBtX2ZyYWdtZW50ID0gY3JlYXRlRnJhZ21lbnRGcm9tVGV4dChkb2N1bWVu
dCwgbmV3VGV4dC5kZXByZWNhdGVkU3RyaW5nKCkpOwogICAgICAgICBob2xkZXIgPSBpbnNlcnRG
cmFnbWVudEZvclRlc3RSZW5kZXJpbmcoKTsK
</data>

          </attachment>
      

    </bug>

</bugzilla>