Bug 47549 - Textarea highlighting text out of text box highlights entire box
Summary: Textarea highlighting text out of text box highlights entire box
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-12 11:52 PDT by indosauros
Modified: 2017-07-18 08:29 PDT (History)
6 users (show)

See Also:


Attachments
IE8 behavior (correct) (6.30 KB, image/png)
2010-10-12 11:52 PDT, indosauros
no flags Details
Firefox 3.6 behavior (correct) (4.53 KB, image/png)
2010-10-12 11:52 PDT, indosauros
no flags Details
Chrome / WebKit behavior (19.44 KB, image/png)
2010-10-12 11:53 PDT, indosauros
no flags Details
DRT demo (1.39 KB, text/html)
2011-01-11 19:03 PST, Ryosuke Niwa
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description indosauros 2010-10-12 11:52:15 PDT
Created attachment 70547 [details]
IE8 behavior (correct)

Scenario:
Multi-row textarea element (paragraph style text input box).
Populated with multiple lines of text.

Actions to reproduce:
Highlight a line of text in the middle of the paragraph, and drag cursor outside of text input box boundary (either left or right).

Desired outcome (Firefox, IE8 behavior):
Highlight stops (vertically) at the Y position of your mouse cursor, outside of the textarea boundaries.

Webkit behaviour:
Highlights entire text box from the initial line to the beginning (if exited left) or the end (if exited right), regardless of where your mouse cursor is vertically.

Attached 3 images to illustrate for comparison (Firefox, IE8 and Chrome behaviors)
Comment 1 indosauros 2010-10-12 11:52:48 PDT
Created attachment 70548 [details]
Firefox 3.6 behavior (correct)
Comment 2 indosauros 2010-10-12 11:53:18 PDT
Created attachment 70549 [details]
Chrome / WebKit behavior
Comment 3 indosauros 2010-10-12 11:55:49 PDT
In each the images, my mouse is to the left of the word "multiline", just outside of the textarea boundary
Comment 4 Peter Kasting 2010-10-12 12:09:19 PDT
CCing some text editing folks for triage
Comment 5 Ojan Vafai 2010-10-13 14:24:11 PDT
I always assumed this was just a Mac-ism, but it seems that TextEdit does the IE8/FF3.6 behavior. So, I'm less confident now that this was intentional.
Comment 6 Peter Kasting 2011-01-11 15:44:49 PST
Julie/Ojan/Ryosuke, is there any chance we could try and fix this some time soon?

There's also a related issue here where dragging out of the box vertically highlights from the selection beginning to the start or end of the text (which seems wrong for single-line textfields at least) but which way it goes flipflops in strange ways as you move the mouse up and down (e.g. as you're dragging the mouse down it will highlight to end, then for 2 pixels flip to highlighting to start, then flip back to highlighting to end).  I don't know if these issues are on file elsewhere.
Comment 7 Ryosuke Niwa 2011-01-11 15:59:00 PST
(In reply to comment #6)
> Julie/Ojan/Ryosuke, is there any chance we could try and fix this some time soon?
> 
> There's also a related issue here where dragging out of the box vertically highlights from the selection beginning to the start or end of the text (which seems wrong for single-line textfields at least) but which way it goes flipflops in strange ways as you move the mouse up and down (e.g. as you're dragging the mouse down it will highlight to end, then for 2 pixels flip to highlighting to start, then flip back to highlighting to end).  I don't know if these issues are on file elsewhere.

Let me take a look later.
Comment 8 Ryosuke Niwa 2011-01-11 19:03:57 PST
Created attachment 78641 [details]
DRT demo

This demo only works in DRT.
Comment 9 Ryosuke Niwa 2011-01-11 19:28:10 PST
Fixing this bug requires significant amount of work.

Right now, EventHandler::updateSelectionForMouseDrag sets setExtent regardless of where targetPosition is and VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries adjusts the extent to the first or the last position in the editable region when the extent's root editable element and base's root editable element are different.

However, adjustSelectionToAvoidCrossingEditingBoundaries doesn't know how the extent was set so there's no way we can "fix" adjustSelectionToAvoidCrossingEditingBoundaries to deal with this situation. So we'll need to have EventHandler::updateSelectionForMouseDrag detect that we're in a different editable root and do the correct thing there. But just checking the root editable elements isn't sufficient because an editable element may also contain non-editable elements and we can't simply assume that targetPosition we're getting is outside of base's root editable element.
Comment 10 Alexey Proskuryakov 2011-01-11 19:42:36 PST
I vaguely recall seeing an earlier bug on this, but I can't find it.
Comment 11 Ryosuke Niwa 2011-02-08 01:27:12 PST
Unassigning myself since I don't intend to work on this bug anytime soon.