[Webkit-unassigned] [Bug 8104] REGRESSION (NativeTextField): New text fields should not allow pasting newlines

bugzilla-daemon at opendarwin.org bugzilla-daemon at opendarwin.org
Sat Apr 1 08:50:12 PST 2006


http://bugzilla.opendarwin.org/show_bug.cgi?id=8104


darin at apple.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|webkit-                     |adele at apple.com
                   |unassigned at opendarwin.org   |
             Status|ASSIGNED                    |NEW




------- Comment #4 from darin at apple.com  2006-04-01 08:50 PDT -------
(In reply to comment #3)
> I don't like doing another test rendering in ReplaceSelectionCommand though. 
> So I'm trying to find a better solution.  Feel free to jump in w/ ideas :)

Well, this version seems fine to me; we shouldn'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't need to be done twice
if you aren't in the plain text case:

+    range->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 >= 0 && (truncateLength < 0 || truncateLength >
newLinePosition))
            truncateLength = newLinePosition;

I think that'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 < 0)
            return p2;
        if (p2 < 0)
            return p1;
        return min(p1, p2);
    }

        truncateLength = minPosition(truncateLength, newLinePosition);


-- 
Configure bugmail: http://bugzilla.opendarwin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list