Summary: | [chromium] Add WebKit API to access inner text value of input element | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Keishi Hattori <keishi> | ||||||||||||||||||||
Component: | Forms | Assignee: | Keishi Hattori <keishi> | ||||||||||||||||||||
Status: | RESOLVED FIXED | ||||||||||||||||||||||
Severity: | Normal | CC: | abarth, dglazkov, fishd, gustavo, isherman, jamesr, philn, tkent, tkent+wkapi, webkit.review.bot, xan.lopez | ||||||||||||||||||||
Priority: | P2 | ||||||||||||||||||||||
Version: | 528+ (Nightly build) | ||||||||||||||||||||||
Hardware: | Unspecified | ||||||||||||||||||||||
OS: | Unspecified | ||||||||||||||||||||||
Bug Depends on: | |||||||||||||||||||||||
Bug Blocks: | 84346, 85356 | ||||||||||||||||||||||
Attachments: |
|
Description
Keishi Hattori
2012-05-02 01:56:35 PDT
Created attachment 139771 [details]
Patch
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI. Chromium patch is here. https://chromiumcodereview.appspot.com/10307004 Comment on attachment 139771 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=139771&action=review > Source/WebKit/chromium/public/WebInputElement.h:78 > + WEBKIT_EXPORT WebString innerTextValue() const; > + WEBKIT_EXPORT void setInnerTextValue(const WebString&); * You should add explanation what is these functions. It's not clear. * "innerTextValue" is not a good name for public API. It should be visibleValue, editingValue, userEditingValue, shownValue, etc. * If possible, we should avoid to expose setInnerTextValue(). Can you set the value by editing commands and remove setInnerTextValue()? (In reply to comment #4) > (From update of attachment 139771 [details]) > * If possible, we should avoid to expose setInnerTextValue(). Can you set the value by editing commands and remove setInnerTextValue()? Hmm. Using the "InsertText" command instantly reopens the autofill popup. Calling hidePopup right after didn't hide it. I'll see what I can do. (In reply to comment #5) > I'll see what I can do. AutofillAgent was putting the textFieldDidChange event into a task queue. I was able to work around it and achieve the original behavior by doing this. So I think I can remove setInnerTextValue. void AutofillAgent::SetNodeText(const string16& value, WebKit::WebInputElement* node) { string16 substring = value; substring = substring.substr(0, node->maxLength()); WebKit::WebView* web_view = render_view()->GetWebView(); if (!web_view || !web_view->focusedFrame()) return; web_view->focusedFrame()->executeCommand(WebString::fromUTF8("selectAll")); web_view->focusedFrame()->executeCommand(WebString::fromUTF8("InsertText"), substring); weak_ptr_factory_.InvalidateWeakPtrs(); MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&AutofillAgent::DidSetNodeText, weak_ptr_factory_.GetWeakPtr())); } void AutofillAgent::DidSetNodeText() { WebKit::WebView* web_view = render_view()->GetWebView(); if (web_view) web_view->hidePopups(); } Created attachment 140454 [details]
Patch
(In reply to comment #4) > (From update of attachment 139771 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=139771&action=review > > > Source/WebKit/chromium/public/WebInputElement.h:78 > > + WEBKIT_EXPORT WebString innerTextValue() const; > > + WEBKIT_EXPORT void setInnerTextValue(const WebString&); > > * You should add explanation what is these functions. It's not clear. Done. > * "innerTextValue" is not a good name for public API. It should be visibleValue, editingValue, userEditingValue, shownValue, etc. visibleValue is used in WebCore for something else so I went with editingValue. (In reply to comment #0) > I need this to implement the datalist UI for <input type=email multiple>. > HTMLInputElement.value gives you the sanitized value so the whitespace between values are trimmed. > We need to append the selected suggestion to the end without modifying the rest of the text. Perhaps we should expose a method to append the selected suggestion, rather than exposing the internal details? Created attachment 141409 [details]
Patch
Comment on attachment 141409 [details] Patch Attachment 141409 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/12668419 Comment on attachment 141409 [details] Patch Attachment 141409 [details] did not pass win-ews (win): Output: http://queues.webkit.org/results/12663724 Comment on attachment 141409 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=141409&action=review r- because of build errors. > Source/WebCore/html/HTMLInputElement.cpp:920 > +void HTMLInputElement::setEditingValue(const String& value) > +{ > + setInnerTextValue(value); > + subtreeHasChanged(); > + dispatchInputEvent(); > +} What happens if setEditingValue() is called for non-textfield input types, or textfield without a renderer? Created attachment 141874 [details]
Patch
(In reply to comment #13) > (From update of attachment 141409 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=141409&action=review > > r- because of build errors. Fixed. > > Source/WebCore/html/HTMLInputElement.cpp:920 > > +void HTMLInputElement::setEditingValue(const String& value) > > +{ > > + setInnerTextValue(value); > > + subtreeHasChanged(); > > + dispatchInputEvent(); > > +} > > What happens if setEditingValue() is called for non-textfield input types, or textfield without a renderer? Yes the assertion fails. Fixed. Comment on attachment 141874 [details] Patch Attachment 141874 [details] did not pass win-ews (win): Output: http://queues.webkit.org/results/12694532 Comment on attachment 141874 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=141874&action=review r- because of build errors. > Source/WebKit/chromium/public/WebInputElement.h:80 > + // Sets the value inside the text field without being sanitized. > + WEBKIT_EXPORT void setEditingValue(const WebString&); We had better mention the limitations of non-textfield types and renderer. Created attachment 141889 [details]
Patch
Comment on attachment 141889 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=141889&action=review ok > LayoutTests/fast/forms/editing-value.html:20 > + testPassed("onchange event was fired."); > +}; > +input.oninput = function() { > + testPassed("oninput event was fired."); nit: We prefer 4-space indentation. > LayoutTests/fast/forms/editing-value.html:28 > +if (window.internals) > + internals.setEditingValue(input, " foo "); > +shouldBe('input.value', '"foo"'); > +shouldBe('document.querySelector(":invalid")', 'input'); > +input.blur(); We had better show a message if window.internals is not available. Created attachment 141902 [details]
Patch
Created attachment 141930 [details]
Patch
Could you review this again? I changed it to move the caret to the end. (like setValue) Comment on attachment 141930 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=141930&action=review > Source/WebKit/chromium/public/WebInputElement.h:81 > + // Sets the value inside the text field without being sanitized. > + // Can't be used if a renderer doesn't exist or on a non text field type. > + WEBKIT_EXPORT void setEditingValue(const WebString&); You should mention the caret position. Created attachment 141934 [details]
Patch
Comment on attachment 141934 [details] Patch Rejecting attachment 141934 [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: t/git/webkit-commit-queue/Source/WebKit/chromium/v8 --revision 11551 --non-interactive --force --accept theirs-conflict --ignore-externals' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium' 47>At revision 11551. ________ 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/12704651 Created attachment 142195 [details]
Patch
Comment on attachment 142195 [details] Patch Clearing flags on attachment: 142195 Committed r117263: <http://trac.webkit.org/changeset/117263> All reviewed patches have been landed. Closing bug. |