WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 45730
API to support localized numbers for <input type=number>
https://bugs.webkit.org/show_bug.cgi?id=45730
Summary
API to support localized numbers for <input type=number>
Kent Tamura
Reported
2010-09-13 20:30:38 PDT
API to support localized numbers for <input type=number>
Attachments
Patch
(20.07 KB, patch)
2010-09-13 20:37 PDT
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 2 (Fix Mac build)
(20.06 KB, patch)
2010-09-13 21:13 PDT
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 2 (comment update, rebased)
(20.08 KB, patch)
2010-10-08 01:44 PDT
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch rev.4
(21.03 KB, patch)
2010-10-12 00:17 PDT
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 5 (rebased)
(21.03 KB, patch)
2010-11-01 23:16 PDT
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 6 (rebased)
(21.01 KB, patch)
2010-11-15 21:31 PST
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 7 (rebased)
(21.00 KB, patch)
2010-12-06 20:09 PST
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 8 (rebased)
(23.27 KB, patch)
2011-01-05 23:29 PST
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Show Obsolete
(7)
View All
Add attachment
proposed patch, testcase, etc.
Kent Tamura
Comment 1
2010-09-13 20:37:32 PDT
Created
attachment 67514
[details]
Patch
Eric Seidel (no email)
Comment 2
2010-09-13 21:01:52 PDT
Attachment 67514
[details]
did not build on mac: Build output:
http://queues.webkit.org/results/4042003
Kent Tamura
Comment 3
2010-09-13 21:13:14 PDT
Created
attachment 67518
[details]
Patch 2 (Fix Mac build)
Alexey Proskuryakov
Comment 4
2010-09-13 22:08:30 PDT
+// Returns true if the input character can be used to represent a +// localized number. For example, this should return true for 0-9 . , + +// - for en-US locale. +bool isLocalizedNumberCharacter(UChar32); Should this depend on browser locale, or on page language?
Kent Tamura
Comment 5
2010-09-13 22:46:48 PDT
(In reply to
comment #4
)
> +// Returns true if the input character can be used to represent a > +// localized number. For example, this should return true for 0-9 . , + > +// - for en-US locale. > +bool isLocalizedNumberCharacter(UChar32); > > Should this depend on browser locale, or on page language?
It should be the same as other functions in this file. So, it's browser locale. I'll update the comment.
Kent Tamura
Comment 6
2010-09-13 23:35:01 PDT
Note that I'll add LocalizedNumberICU.cpp after this patch. Probably Qt needs LocalizedNumberQt.cpp, which uses QLocale, and Mac needs LocalizedNumberMac.mm for NSNumberFormatter?
Kent Tamura
Comment 7
2010-10-08 01:44:54 PDT
Created
attachment 70209
[details]
Patch 2 (comment update, rebased)
Dimitri Glazkov (Google)
Comment 8
2010-10-08 09:54:16 PDT
Comment on
attachment 70209
[details]
Patch 2 (comment update, rebased) ok.
Alexey Proskuryakov
Comment 9
2010-10-08 10:27:38 PDT
static bool isNumberCharacter(UChar ch) { - return ch == '+' || ch == '-' || ch == '.' || ch == 'e' || ch == 'E' - || (ch >= '0' && ch <= '9'); + return isLocalizedNumberCharacter(ch) || ch == '+' || ch == '-' || ch == '.' || ch == 'e' || ch == 'E' || (ch >= '0' && ch <= '9'); } This is confusing. Where does the definition come from? For example, a comment before isLocalizedNumberCharacter() says that it includes both period and comma for U.S. locale. But this only forces period. Why? +++ b/WebCore/rendering/RenderTextControlSingleLine.cpp @@ -693,7 +693,7 @@ void RenderTextControlSingleLine::updateFromElement() shouldUpdateValue = static_cast<HTMLTextFormControlElement*>(node())->supportsPlaceholder() || !static_cast<HTMLInputElement*>(node())->formControlValueMatchesRenderer(); } if (shouldUpdateValue) - setInnerTextValue(inputElement()->value()); + setInnerTextValue(inputElement()->visibleValue()); } What is this change expected to provide? It seems out of place in a bug that adds an API. ChangeLog comment doesn't explain the reason for this change. The concept of "visibleValue" in general seems unclear. How is one supposed to perform DOM manipulation if rendered value is different from DOM value? E.g. what if JS code want to select part of the number in the input field?
Alexey Proskuryakov
Comment 10
2010-10-08 10:28:10 PDT
Comment on
attachment 70209
[details]
Patch 2 (comment update, rebased) Marking r- for the sake of ongoing discussion.
Kent Tamura
Comment 11
2010-10-12 00:17:17 PDT
Created
attachment 70515
[details]
Patch rev.4
Kent Tamura
Comment 12
2010-10-12 00:23:03 PDT
Thank you for the comments. (In reply to
comment #9
)
> static bool isNumberCharacter(UChar ch) > { > - return ch == '+' || ch == '-' || ch == '.' || ch == 'e' || ch == 'E' > - || (ch >= '0' && ch <= '9'); > + return isLocalizedNumberCharacter(ch) || ch == '+' || ch == '-' || ch == '.' || ch == 'e' || ch == 'E' || (ch >= '0' && ch <= '9'); > } > > This is confusing. Where does the definition come from? For example, a comment before isLocalizedNumberCharacter() says that it includes both period and comma for U.S. locale. But this only forces period. Why?
We try to parse a value in a localized number format, and try to parse it in the HTML5 format if the parsing in the localized number format fails. I added a comment about this to HTMLInputElement::sanitizeValue() and ChangeLog.
> +++ b/WebCore/rendering/RenderTextControlSingleLine.cpp > @@ -693,7 +693,7 @@ void RenderTextControlSingleLine::updateFromElement() > shouldUpdateValue = static_cast<HTMLTextFormControlElement*>(node())->supportsPlaceholder() || !static_cast<HTMLInputElement*>(node())->formControlValueMatchesRenderer(); > } > if (shouldUpdateValue) > - setInnerTextValue(inputElement()->value()); > + setInnerTextValue(inputElement()->visibleValue()); > } > > What is this change expected to provide? It seems out of place in a bug that adds an API. ChangeLog comment doesn't explain the reason for this change. > > The concept of "visibleValue" in general seems unclear. How is one supposed to perform DOM manipulation if rendered value is different from DOM value?
ok, I added an explanation of visibleValue() to ChangeLog. visibleValue() is a localized representation of a number, and value() (DOM manipulation) is the HTML5 number representation.
> E.g. what if JS code want to select part of the number in the input field?
We can't do it. HTML5 doesn't provide selection API for type=number.
Kent Tamura
Comment 13
2010-11-01 23:16:57 PDT
Created
attachment 72631
[details]
Patch 5 (rebased)
Kent Tamura
Comment 14
2010-11-15 21:31:16 PST
Created
attachment 73959
[details]
Patch 6 (rebased)
Kent Tamura
Comment 15
2010-12-06 20:09:02 PST
Created
attachment 75777
[details]
Patch 7 (rebased)
WebKit Review Bot
Comment 16
2010-12-06 20:11:54 PST
Attachment 75777
[details]
did not pass style-queue: Failed to run "[u'git', u'reset', u'--hard', u'HEAD']" exit_code: 128 error: git checkout-index: unable to write file LayoutTests/ChangeLog error: git checkout-index: unable to write file LayoutTests/fast/css/custom-font-xheight.html error: git checkout-index: unable to write file WebCore/ChangeLog fatal: Could not reset index file to revision 'HEAD'. If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Review Bot
Comment 17
2010-12-07 08:27:40 PST
Attachment 75777
[details]
did not pass style-queue: Failed to run "[u'git', u'reset', u'--hard', u'refs/remotes/trunk']" exit_code: 128 error: Could not write new index file. fatal: Could not reset index file to revision 'refs/remotes/trunk'. If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Review Bot
Comment 18
2010-12-07 09:29:17 PST
Attachment 75777
[details]
did not pass style-queue: Failed to run "[u'git', u'reset', u'--hard', u'refs/remotes/trunk']" exit_code: 128 error: Could not write new index file. fatal: Could not reset index file to revision 'refs/remotes/trunk'. If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Review Bot
Comment 19
2010-12-07 10:30:22 PST
Attachment 75777
[details]
did not pass style-queue: Failed to run "[u'git', u'reset', u'--hard', u'refs/remotes/trunk']" exit_code: 128 error: Could not write new index file. fatal: Could not reset index file to revision 'refs/remotes/trunk'. If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Review Bot
Comment 20
2010-12-07 11:31:30 PST
Attachment 75777
[details]
did not pass style-queue: Failed to run "[u'git', u'reset', u'--hard', u'refs/remotes/trunk']" exit_code: 128 error: Could not write new index file. fatal: Could not reset index file to revision 'refs/remotes/trunk'. If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Review Bot
Comment 21
2010-12-07 12:32:56 PST
Attachment 75777
[details]
did not pass style-queue: Failed to run "[u'git', u'reset', u'--hard', u'refs/remotes/trunk']" exit_code: 128 error: Could not write new index file. fatal: Could not reset index file to revision 'refs/remotes/trunk'. If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Review Bot
Comment 22
2010-12-07 21:29:41 PST
Attachment 75777
[details]
did not pass style-queue: Failed to run "['WebKitTools/Scripts/update-webkit']" exit_code: 2 Updating OpenSource Incomplete data: Delta source ended unexpectedly at /usr/lib/git-core/git-svn line 5061 Died at WebKitTools/Scripts/update-webkit line 132. If any of these errors are false positives, please file a bug against check-webkit-style.
Kent Tamura
Comment 23
2010-12-14 15:49:16 PST
Ping. ap, dglazkov, would you take a look at the patch please?
Kent Tamura
Comment 24
2011-01-05 23:29:45 PST
Created
attachment 78100
[details]
Patch 8 (rebased)
Dimitri Glazkov (Google)
Comment 25
2011-01-25 18:26:25 PST
Comment on
attachment 78100
[details]
Patch 8 (rebased) ok.
Kent Tamura
Comment 26
2011-01-25 19:47:05 PST
Landed:
http://trac.webkit.org/changeset/76661
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug