RESOLVED FIXED 91907
Implement setRangeText() on text controls
https://bugs.webkit.org/show_bug.cgi?id=91907
Summary Implement setRangeText() on text controls
Attachments
Patch (14.34 KB, patch)
2012-07-20 16:09 PDT, Pablo Flouret
no flags
Patch (79.72 KB, patch)
2012-07-26 17:43 PDT, Pablo Flouret
no flags
Patch (54.36 KB, patch)
2012-07-31 16:56 PDT, Pablo Flouret
no flags
Patch (55.08 KB, patch)
2012-10-11 16:11 PDT, Pablo Flouret
no flags
Patch (86.22 KB, patch)
2012-10-17 17:22 PDT, Pablo Flouret
no flags
Patch (84.40 KB, patch)
2012-10-17 22:04 PDT, Pablo Flouret
no flags
Patch (84.40 KB, patch)
2012-10-18 10:29 PDT, Pablo Flouret
tkent: review+
webkit.review.bot: commit-queue-
Patch for landing (84.27 KB, patch)
2012-10-19 11:09 PDT, Pablo Flouret
no flags
Pablo Flouret
Comment 1 2012-07-20 16:09:09 PDT
Pablo Flouret
Comment 2 2012-07-20 16:10:54 PDT
I ran into some small issues in the spec while implementing this (https://www.w3.org/Bugs/Public/show_bug.cgi?id=18337). They look straightforward to fix, but if it's deemed important, this patch can probably wait for the spec to be fixed.
Pablo Flouret
Comment 3 2012-07-20 16:14:54 PDT
Also, i noticed setSelectionRange (and consequently setRangeText) never fires the "select" event via HTMLTextFormControlElement::selectionChanged() since the selection is not marked as UserTriggered when set on the frame. Is this intentional?
Kent Tamura
Comment 4 2012-07-23 18:40:52 PDT
You should announce this feature on webkit-dev.
Kent Tamura
Comment 5 2012-07-23 18:42:47 PDT
Comment on attachment 153615 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=153615&action=review > LayoutTests/ChangeLog:9 > + * fast/forms/text-control-setrangetext.html: Added. > + need to add text-control-setrangetext-expected.txt. > LayoutTests/fast/forms/text-control-setrangetext.html:11 > +<input type=text> > +<input type=text dir="rtl"> We need to test with all of input types.
Pablo Flouret
Comment 6 2012-07-24 10:13:46 PDT
I'll send an email to webkit-dev, and add the expectation i missed to the patch. Any ideas on what to do with the gtk issue? I guess the gobject generator doesn't like IDL overloads?
Kent Tamura
Comment 7 2012-07-24 19:09:22 PDT
(In reply to comment #6) > Any ideas on what to do with the gtk issue? I guess the gobject generator doesn't like IDL overloads? I don't know much about gobject binding. If you can't resolve the issue, you can disable gobject binding by wrapping functions with #if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT in *.idl.
Pablo Flouret
Comment 8 2012-07-26 17:43:12 PDT
Ryosuke Niwa
Comment 9 2012-07-26 17:46:55 PDT
Comment on attachment 154797 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=154797&action=review > Source/WebCore/html/HTMLInputElement.idl:86 > +#if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT > + void setRangeText(in DOMString replacement) raises(DOMException); > +#endif Why do we have a different interface for Gobject? > Source/WebCore/html/HTMLTextAreaElement.idl:58 > +#if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT > + void setRangeText(in DOMString replacement) raises(DOMException); > +#endif Ditto.
Pablo Flouret
Comment 10 2012-07-26 17:47:22 PDT
Comment on attachment 154797 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=154797&action=review New patch adds the expectation file, tests all input types, and fixes a few issues that popped up. > Source/WebCore/html/HTMLTextFormControlElement.cpp:270 > + // FIXME: What should happen to the value (as in value()) if there's no renderer? > + if (!renderer()) > + return; The form control's value should be set even if there's no renderer, right? I'm not sure what would be the correct way of setting it.
Pablo Flouret
Comment 11 2012-07-26 17:54:36 PDT
(In reply to comment #9) > (From update of attachment 154797 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=154797&action=review > > > Source/WebCore/html/HTMLInputElement.idl:86 > > +#if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT > > + void setRangeText(in DOMString replacement) raises(DOMException); > > +#endif > > Why do we have a different interface for Gobject? GTK build failed on the last patch, seemingly due to the idl overload of the method. I'm not sure what's the proper solution, and i can't build for gtk to play around. Do you have any suggestions?
Kent Tamura
Comment 12 2012-07-26 18:56:58 PDT
(In reply to comment #10) > (From update of attachment 154797 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=154797&action=review > > New patch adds the expectation file, tests all input types, and fixes a few issues that popped up. > > > Source/WebCore/html/HTMLTextFormControlElement.cpp:270 > > + // FIXME: What should happen to the value (as in value()) if there's no renderer? > > + if (!renderer()) > > + return; > > The form control's value should be set even if there's no renderer, right? I'm not sure what would be the correct way of setting it. I think so. Why do you check renderer()? Did you have any trouble if you removed the !renderer() check?
Kent Tamura
Comment 13 2012-07-26 19:02:01 PDT
Comment on attachment 154797 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=154797&action=review > Source/WebCore/html/HTMLTextFormControlElement.cpp:245 > + if (!isTextFormControl()) > + return; According to the standard, we should throw InvalidStateError. Also, HTMLInputElement::isTextFormControl() implementation is wrong. We shouldn't support setRangeText() only for text, search, url, tel, and password. http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#textFieldSelection > When these methods and attributes are used with input elements while they don't apply, they must throw an InvalidStateError exception.
Kent Tamura
Comment 14 2012-07-26 19:03:45 PDT
(In reply to comment #13) > Also, HTMLInputElement::isTextFormControl() implementation is wrong. We shouldn't support setRangeText() only for text, search, url, tel, and password. Oops, shouldn't -> should
Pablo Flouret
Comment 15 2012-07-27 17:12:03 PDT
(In reply to comment #12) > (In reply to comment #10) > > > The form control's value should be set even if there's no renderer, right? I'm not sure what would be the correct way of setting it. > > I think so. Why do you check renderer()? Did you have any trouble if you removed the !renderer() check? subtreeHasChanged() asserts for a renderer. Eventually the value gets updated via setValueFromRenderer(), that's why i was wondering how to properly update the value if there isn't a renderer. (In reply to comment #13) > (From update of attachment 154797 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=154797&action=review > > > Source/WebCore/html/HTMLTextFormControlElement.cpp:245 > > + if (!isTextFormControl()) > > + return; > > According to the standard, we should throw InvalidStateError. > Also, HTMLInputElement::isTextFormControl() implementation is wrong. We shouldn't support setRangeText() only for text, search, url, tel, and password. > http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary > > > http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#textFieldSelection > > When these methods and attributes are used with input elements while they don't apply, they must throw an InvalidStateError exception. Ah, hadn't seen those, will fix.
Pablo Flouret
Comment 16 2012-07-31 16:56:16 PDT
Ryosuke Niwa
Comment 17 2012-07-31 16:58:20 PDT
Comment on attachment 155677 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=155677&action=review > Source/WebCore/html/HTMLInputElement.idl:86 > +#if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT > + void setRangeText(in DOMString replacement) raises(DOMException); > +#endif I don't think this is right.
Ryosuke Niwa
Comment 18 2012-07-31 16:58:21 PDT
Comment on attachment 155677 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=155677&action=review > Source/WebCore/html/HTMLInputElement.idl:86 > +#if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT > + void setRangeText(in DOMString replacement) raises(DOMException); > +#endif I don't think this is right.
Ryosuke Niwa
Comment 19 2012-07-31 16:59:06 PDT
Martin, there's some weird G-object binding here. Could you take a look?
Pablo Flouret
Comment 20 2012-09-27 14:35:25 PDT
Any ideas on a proper fix for overloads on the gobject bindings?
Martin Robinson
Comment 21 2012-09-28 06:59:13 PDT
Zan or Xan more experience with the bindings, but I think what's happening is that the code generator doesn't know how to deal with method overrides in the IDL. What do the other code generators do in this case?
Pablo Flouret
Comment 22 2012-10-03 12:24:09 PDT
(In reply to comment #21) > Zan or Xan more experience with the bindings, but I think what's happening is that the code generator doesn't know how to deal with method overrides in the IDL. What do the other code generators do in this case? Yeah, doesn't look like the GObject generator deals with overloads at all. For what is worth, and from a cursory glance, the JSC generator generates a function with a different name for each overload, and one with the proper name that dispatches to the correct one. Looking around the idl files, CanvasRenderingContext2D declares a whole bunch of drawImage overloads without any #ifdeffery, i wonder what's going on there. In other places it seems to be handled with custom bindings or other hackery (e.g. XMLHttpRequest.send, window.set{Timeout,Interval}, HTMLSelectElement.add, etc).
Zan Dobersek
Comment 23 2012-10-04 01:39:35 PDT
(In reply to comment #21) > Zan or Xan more experience with the bindings, but I think what's happening is that the code generator doesn't know how to deal with method overrides in the IDL. What do the other code generators do in this case? That's exactly the problem, overloading functions support in GObject DOM bindings is non-existent. I'd recommend skipping the function: http://trac.webkit.org/browser/trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm#L213
Pablo Flouret
Comment 24 2012-10-11 16:11:24 PDT
Kent Tamura
Comment 25 2012-10-14 19:22:16 PDT
Comment on attachment 168308 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=168308&action=review > Source/WebCore/html/HTMLInputElement.cpp:1882 > + if (!m_inputType->isTextType() || m_inputType->isEmailField()) { Please do not add type checking code in HTMLInputElement. We should add InputType::supportsSelectionAPI(). > Source/WebCore/html/HTMLTextAreaElement.h:65 > + virtual void setRangeText(const String& replacement, ExceptionCode& ec) OVERRIDE { HTMLTextFormControlElement::setRangeText(replacement, ec); } > + virtual void setRangeText(const String& replacement, unsigned start, unsigned end, const String& selectionMode, ExceptionCode& ec) OVERRIDE { HTMLTextFormControlElement::setRangeText(replacement, start, end, selectionMode, ec); } > + They look unnecessary. > Source/WebCore/html/HTMLTextFormControlElement.cpp:252 > + start = min(start, textLength); > + end = min(end, textLength); They should be std::min. http://www.webkit.org/coding/coding-style.html#using-in-cpp > LayoutTests/fast/forms/text-control-setrangetext.html:207 > +runTestsShouldFail("input", { type: "submit" }); We need to test other types; date, datetime, datetime-local, month, time, and week. Their support status depend on platforms. So we should prepare test files for each of types and put them into the type directories. e.g. fast/forms/resource/common-setrangetext.js fast/forms/text/text-setrangetext.html fast/forms/search/search-setrangetext.html fast/forms/input-button/input-button-setrangetext.html fast/forms/file/file-setrangetext.html fast/forms/date/date-setrangetext.html ....
Pablo Flouret
Comment 26 2012-10-17 17:22:34 PDT
Kent Tamura
Comment 27 2012-10-17 21:01:57 PDT
Comment on attachment 169309 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=169309&action=review > LayoutTests/fast/forms/color/color-setrangetext-expected.txt:11 > +element.value = '0123456789XYZ' > +PASS element.setRangeText('ABC', 0, 0) threw exception Error: INVALID_STATE_ERR: DOM Exception 11. > +PASS element.value is "0123456789XYZ" Because input[type=color] sanitizes the value, element.value should be "#000000" > LayoutTests/fast/forms/datalist/datalist-setrangetext.html:11 > +runTestsShouldFail("input", { type: "datalist" }); datalist is not an input type. You don't need add a test. > LayoutTests/fast/forms/date/date-setrangetext-expected.txt:11 > +PASS element.value is "0123456789XYZ" element.value should be "" because of value sanitization. > LayoutTests/fast/forms/datetime/datetime-setrangetext-expected.txt:11 > +PASS element.value is "0123456789XYZ" element.value should be "" because of value sanitization. > LayoutTests/fast/forms/datetimelocal/datetimelocal-setrangetext-expected.txt:11 > +PASS element.value is "0123456789XYZ" element.value should be "" because of value sanitization. > LayoutTests/fast/forms/month/month-setrangetext-expected.txt:11 > +PASS element.value is "0123456789XYZ" element.value should be "" because of value sanitization. > LayoutTests/fast/forms/time/time-setrangetext-expected.txt:11 > +PASS element.value is "0123456789XYZ" element.value should be "" because of value sanitization. > LayoutTests/fast/forms/week/week-setrangetext-expected.txt:11 > +PASS element.value is "0123456789XYZ" element.value should be "" because of value sanitization.
Pablo Flouret
Comment 28 2012-10-17 22:04:40 PDT
WebKit Review Bot
Comment 29 2012-10-18 00:15:05 PDT
Comment on attachment 169341 [details] Patch Attachment 169341 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/14384878 New failing tests: fast/forms/time/time-setrangetext.html fast/forms/datetimelocal/datetimelocal-setrangetext.html
Kent Tamura
Comment 30 2012-10-18 00:17:55 PDT
Comment on attachment 169341 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=169341&action=review > LayoutTests/fast/forms/datetimelocal/datetimelocal-setrangetext.html:11 > +runTestsShouldFail("input", { type: "datetimelocal" }); should be type: "datetime-local" > LayoutTests/fast/forms/time/time-setrangetext.html:10 > +description("Test setRangeText() method rs not available in time inputs."); rs -> is
Pablo Flouret
Comment 31 2012-10-18 10:29:58 PDT
Created attachment 169433 [details] Patch Thanks, sorry about that.
Kent Tamura
Comment 32 2012-10-18 18:07:29 PDT
Comment on attachment 169433 [details] Patch ok. Thank you!
WebKit Review Bot
Comment 33 2012-10-18 18:23:02 PDT
Comment on attachment 169433 [details] Patch Rejecting attachment 169433 [details] from commit-queue. Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2 Last 500 characters of output: commit-queue/Source/WebKit/chromium/third_party/v8-i18n --revision 153 --non-interactive --force --accept theirs-conflict --ignore-externals' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium' 47>At revision 153. ________ running '/usr/bin/python tools/clang/scripts/update.py --mac-only' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium' ________ running '/usr/bin/python gyp_webkit' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium' Updating webkit projects from gyp files... Full output: http://queues.webkit.org/results/14459262
Kent Tamura
Comment 34 2012-10-18 18:33:45 PDT
Comment on attachment 169433 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=169433&action=review > LayoutTests/ChangeLog:8 > + Additional information of the change such as approach, rationale. Please add per-function descriptions below (OOPS!). Need to update/remove this line.
Pablo Flouret
Comment 35 2012-10-19 11:09:33 PDT
Created attachment 169653 [details] Patch for landing
WebKit Review Bot
Comment 36 2012-10-19 18:07:24 PDT
Comment on attachment 169653 [details] Patch for landing Clearing flags on attachment: 169653 Committed r131969: <http://trac.webkit.org/changeset/131969>
Note You need to log in before you can comment on or make changes to this bug.