Bug 85244 - Disabled input/textarea doesn't trigger selection change
Summary: Disabled input/textarea doesn't trigger selection change
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Daniel Cheng
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-30 16:27 PDT by Daniel Cheng
Modified: 2013-01-27 18:48 PST (History)
10 users (show)

See Also:


Attachments
Test case (221 bytes, text/html)
2012-04-30 16:27 PDT, Daniel Cheng
no flags Details
Patch (1.55 KB, patch)
2012-10-16 00:38 PDT, Kaustubh Atrawalkar
no flags Details | Formatted Diff | Diff
Patch (4.37 KB, patch)
2012-10-16 03:06 PDT, Kaustubh Atrawalkar
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
WIP (6.03 KB, patch)
2012-12-20 22:44 PST, Shinya Kawanaka
no flags Details | Formatted Diff | Diff
Patch (6.14 KB, patch)
2013-01-24 23:21 PST, Shinya Kawanaka
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 2012-04-30 16:27:01 PDT
Created attachment 139543 [details]
Test case

I've attached a simple test case that illustrates this issue in Chromium.
Comment 1 Daniel Cheng 2012-05-01 16:50:56 PDT
I think the root cause of this is WebViewImpl::caretOrSelectionRange returning false for selections inside disabled elements. Inside that function, we call  TextIterator::getLocationAndLengthFromRange. Everything goes as expected until:

    // The critical assumption is that this only gets called with ranges that
    // concentrate on a given area containing the selection root. This is done
    // because of text fields and textareas. The DOM for those is not
    // directly in the document DOM, so ensure that the range does not cross a
    // boundary of one of those.
    if (range->startContainer() != scope && !range->startContainer()->isDescendantOf(scope))
        return false;

At that point:
range->startContainer() == range->endContainer() == #text node in shadow DOM
scope == selection->rootEditableElementOrDocumentElement() == HTML element, since there is no editable element in a readonly control.

It seems like for the purposes of the selection code, we should be setting scope to put to a node inside the shadow DOM as well.
Comment 2 Ryosuke Niwa 2012-05-01 16:54:29 PDT
Ugh... yeah, thanks for filing a bug on this.
Comment 3 Kaustubh Atrawalkar 2012-10-16 00:38:30 PDT
Created attachment 168878 [details]
Patch
Comment 4 Kaustubh Atrawalkar 2012-10-16 00:38:57 PDT
I was working on the same issue filed on crbug.com/152552
The issue is in WebCore/page/EventHandler.cpp In function handleLongPressGesture() there is condition to check isContentEditable() which seems to be wrong as it will not select the text from disabled Input boxes. I have added a fix for the same to change it to canStartSelection(). Please review. Thanks.
Comment 5 Hajime Morrita 2012-10-16 00:56:25 PDT
Comment on attachment 168878 [details]
Patch

We needs some LayoutTest for exercising this.
You can find selection related tests under LayoutTests/editing/selection.
Comment 6 Kaustubh Atrawalkar 2012-10-16 03:06:29 PDT
Created attachment 168907 [details]
Patch
Comment 7 WebKit Review Bot 2012-10-16 03:57:56 PDT
Comment on attachment 168907 [details]
Patch

Attachment 168907 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14385148

New failing tests:
fast/events/touch/gesture/disabled-input-text-selection.html
Comment 8 Kaustubh Atrawalkar 2012-10-18 02:02:48 PDT
Comment on attachment 168907 [details]
Patch

This issue being little different than the one mentioned here - crbug.com/152552, as per Daniel, I have filed separate bug for the same at wkbug.com/99698. Please check there.
Comment 9 Shinya Kawanaka 2012-12-20 22:44:44 PST
Created attachment 180486 [details]
WIP
Comment 10 Shinya Kawanaka 2012-12-20 22:46:44 PST
Returning document seems wrong. Instead of it, I think we should return the root node of tree scope.
But I don't know how we add a test here. Maybe run-api-tests?
After writing a test, I'll upload the review-ready patch again.
Comment 11 kov's GTK+ EWS bot 2012-12-20 23:38:12 PST
Comment on attachment 180486 [details]
WIP

Attachment 180486 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/15445390
Comment 12 Build Bot 2012-12-21 01:12:07 PST
Comment on attachment 180486 [details]
WIP

Attachment 180486 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/15455329
Comment 13 danya.postfactum 2013-01-24 06:41:45 PST
Any news here? I don't know whether it was said here, but textareas with readonly attribute have the same problem.
Comment 14 Shinya Kawanaka 2013-01-24 23:21:15 PST
Created attachment 184678 [details]
Patch
Comment 15 Shinya Kawanaka 2013-01-24 23:24:43 PST
The previous WIP patch I uploaded before was for another Bug. I didn't noticed it.... sorry!
Anyway, I've attacked this bug.
Comment 16 Ryosuke Niwa 2013-01-24 23:25:25 PST
Comment on attachment 184678 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=184678&action=review

Makes sense.

> LayoutTests/fast/forms/input-readonly-select.html:38
> +input.addEventListener('select', function() {
> +    selectEventFiredOnInput = true;
> +});

Should we also check selectstart and selectionchange events?
Comment 17 Shinya Kawanaka 2013-01-25 00:17:22 PST
> Should we also check selectstart and selectionchange events?

http://jsfiddle.net/wzbUE/

selectionchange is working even in disabled/readonly input/textarea.
selectstart is only fired in contenteditable. Should it fired in input or textarea?

Anyway, I'll land this patch after seeing bots green.
Comment 18 Ryosuke Niwa 2013-01-25 00:17:57 PST
(In reply to comment #17)
> > Should we also check selectstart and selectionchange events?
> 
> http://jsfiddle.net/wzbUE/
> 
> selectionchange is working even in disabled/readonly input/textarea.
> selectstart is only fired in contenteditable. Should it fired in input or textarea?

selectstart should fire.
Comment 19 Shinya Kawanaka 2013-01-27 18:13:37 PST
(In reply to comment #18)
> (In reply to comment #17)
> > > Should we also check selectstart and selectionchange events?
> > 
> > http://jsfiddle.net/wzbUE/
> > 
> > selectionchange is working even in disabled/readonly input/textarea.
> > selectstart is only fired in contenteditable. Should it fired in input or textarea?
> 
> selectstart should fire.

OK. But now I remember that we have a bug where a user cannot input any text in <input> or <textarea> if selectstart is cancelled somewhere in JS. Maybe it should be resolved first.
Comment 20 Shinya Kawanaka 2013-01-27 18:15:41 PST
Filed the bug in https://bugs.webkit.org/show_bug.cgi?id=108043
Comment 21 WebKit Review Bot 2013-01-27 18:48:47 PST
Comment on attachment 184678 [details]
Patch

Clearing flags on attachment: 184678

Committed r140936: <http://trac.webkit.org/changeset/140936>
Comment 22 WebKit Review Bot 2013-01-27 18:48:52 PST
All reviewed patches have been landed.  Closing bug.