Bug 38175 - REGRESSION (r48698): Selection drag-and-drop doesn't work for input/textarea
Summary: REGRESSION (r48698): Selection drag-and-drop doesn't work for input/textarea
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P1 Normal
Assignee: Nobody
URL: http://crbug.com/new
Keywords: InRadar, Regression
Depends on:
Blocks:
 
Reported: 2010-04-26 23:38 PDT by Daniel Cheng
Modified: 2010-04-29 05:03 PDT (History)
7 users (show)

See Also:


Attachments
Patch (6.30 KB, patch)
2010-04-27 06:12 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff
Patch (rev.2) (6.79 KB, patch)
2010-04-27 19:05 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Cheng 2010-04-26 23:38:06 PDT
In http://crbug.com/new, attempt to drag some text from a TEXTAREA to an empty text input. It will fail, and will raise an assert in debug builds:
ASSERT(oldLength >= selectionLength);

I think this is because WebCore is calculating oldLength from the wrong element; it looks like it's calculating the length of the text field being dragged to rather than the text field being dragged from. However, I'm not familiar enough with this code to say for sure.
Comment 1 Kent Tamura 2010-04-27 06:12:49 PDT
Created attachment 54411 [details]
Patch
Comment 2 Darin Adler 2010-04-27 13:04:19 PDT
Comment on attachment 54411 [details]
Patch

In what way is this "incorrect arithmetic"? Can we re-title the bug to be clearer?

I don't understand the comment "No need to calculate the selection length in a case of selection drag-and-drop."
- The comment doesn't say why focused() is a reliable way to detect the fact that selected text is being dragged within the element.
- The comment doesn't say why setting selectionLength to 0 is a good way to bypass the selection check entirely.
The main purpose of comments is to explain why the code exists. The code can speak for itself on *what* it does.

I am not convinced that setting selectionLength to 0 is the best way to handle this.
Comment 3 Kent Tamura 2010-04-27 19:05:38 PDT
Created attachment 54498 [details]
Patch (rev.2)
Comment 4 mitz 2010-04-27 19:09:43 PDT
This seems to be a regression from Safari 4.0.5. Any idea what caused it? I am asking because whatever it was may have had other side effects that your patch will not address.
Comment 5 Kent Tamura 2010-04-27 19:11:11 PDT
Thank you for reviewing

(In reply to comment #2)
> I don't understand the comment "No need to calculate the selection length in a
> case of selection drag-and-drop."
> - The comment doesn't say why focused() is a reliable way to detect the fact
> that selected text is being dragged within the element.
> - The comment doesn't say why setting selectionLength to 0 is a good way to
> bypass the selection check entirely.
> The main purpose of comments is to explain why the code exists. The code can
> speak for itself on *what* it does.
> 
> I am not convinced that setting selectionLength to 0 is the best way to handle
> this.

I updated the comments. I think the new comments explain them.

And I removed the existing comment "// selection() may be a pre-edit text.".  I added it when I fixed an issue for IME, but the comment is not helpful for now though it was helpful during the IME change.
Comment 6 mitz 2010-04-27 19:23:51 PDT
Caused by <http://trac.webkit.org/changeset/48698>.
Comment 7 mitz 2010-04-27 19:26:11 PDT
<rdar://problem/7915903>
Comment 8 Kent Tamura 2010-04-27 19:27:58 PDT
(In reply to comment #6)
> Caused by <http://trac.webkit.org/changeset/48698>.

Or r48011.

The assertion has been there for a long time. The code have never considered
text drag-and-drop, but it worked accidentally.  It seems my change exposed the
problem.
Comment 9 Kent Tamura 2010-04-29 04:27:17 PDT
Landed as r58502.
Comment 10 WebKit Review Bot 2010-04-29 04:50:13 PDT
http://trac.webkit.org/changeset/58502 might have broken GTK Linux 32-bit Release
Comment 11 Kent Tamura 2010-04-29 05:03:50 PDT
(In reply to comment #10)
> http://trac.webkit.org/changeset/58502 might have broken GTK Linux 32-bit
> Release

I'll add the test to the skipped list for GTK and Qt.