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 42484
Support localized numbers in <input type=number>
https://bugs.webkit.org/show_bug.cgi?id=42484
Summary
Support localized numbers in <input type=number>
Kent Tamura
Reported
2010-07-16 15:21:02 PDT
In the current implementation, the value of <input type=number> must be an HTML5 number (ASCII digits) and is sent to a server as is. We should accept localized number representations and convert them to an HTML5 number for form submission.
Attachments
Patch
(18.24 KB, patch)
2011-01-27 01:23 PST
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 2
(18.29 KB, patch)
2011-01-27 01:31 PST
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 3
(32.40 KB, patch)
2011-02-01 02:33 PST
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 4
(32.63 KB, patch)
2011-02-01 06:30 PST
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 5
(30.03 KB, patch)
2011-02-01 20:55 PST
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Patch 6
(30.10 KB, patch)
2011-02-28 19:51 PST
,
Kent Tamura
dglazkov
: review+
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Patryk Zawadzki
Comment 1
2010-09-30 15:09:29 PDT
It would also be nice to display numbers in their localized form. Same probably applies to date/time fields.
Kent Tamura
Comment 2
2011-01-27 01:23:24 PST
Created
attachment 80305
[details]
Patch
Kent Tamura
Comment 3
2011-01-27 01:26:18 PST
I'm not sure how to use new ICU headers in Mac. Why we have Source/WebCore/icu/?
Kent Tamura
Comment 4
2011-01-27 01:31:26 PST
Created
attachment 80307
[details]
Patch 2
Alexey Proskuryakov
Comment 5
2011-01-27 08:56:01 PST
> We should accept localized number representations and convert them to an HTML5 number for form submission.
Is that mandated by HTML5? The bug needs to explain where this "should" comes from. <
http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values
> in particular is not localization aware.
> I'm not sure how to use new ICU headers in Mac. Why we have Source/WebCore/icu/?
ICU is not an officially supported API on Mac OS X, so ICU headers aren't shipped with it. When really needed, we copy an appropriate version of a particular ICU header to our repository. I'm not sure if this is one of those cases, or we should just use CFNumberFormatter API.
Ian 'Hixie' Hickson
Comment 6
2011-01-27 15:54:47 PST
This is a UI issue and is out of scope of the spec. You "should" accept localised forms if that's what's best for users.
Kent Tamura
Comment 7
2011-01-27 16:07:30 PST
(In reply to
comment #5
)
> > We should accept localized number representations and convert them to an HTML5 number for form submission. > > Is that mandated by HTML5? The bug needs to explain where this "should" comes from. <
http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values
> in particular is not localization aware.
It's not mandatory. I should have added more words to ChangeLog. This change is only for UI. HTML parsing and DOM property access are not affected. I saw several requests for localized numbers for <input type=number>, I haven't seen any objections, and I believe we should support them.
> > I'm not sure how to use new ICU headers in Mac. Why we have Source/WebCore/icu/? > > ICU is not an officially supported API on Mac OS X, so ICU headers aren't shipped with it. When really needed, we copy an appropriate version of a particular ICU header to our repository. I'm not sure if this is one of those cases, or we should just use CFNumberFormatter API.
CFNumberFormatter looks enough. Thank you.
Alexey Proskuryakov
Comment 8
2011-01-27 16:27:45 PST
> This change is only for UI.
Will is affect VoiceOver?
Kent Tamura
Comment 9
2011-01-27 17:26:44 PST
(In reply to
comment #8
)
> Will is affect VoiceOver?
I don't know. How VoiceOver obtain text form an application?
Darin Adler
Comment 10
2011-01-27 17:41:11 PST
(In reply to
comment #9
)
> (In reply to
comment #8
) > > Will it affect VoiceOver? > > I don't know. How does VoiceOver obtain text form an application?
It calls the functions defined in the WebCore/accessibility directory.
Kent Tamura
Comment 11
2011-01-31 21:53:40 PST
(In reply to
comment #10
)
> > > Will it affect VoiceOver? > > > > I don't know. How does VoiceOver obtain text form an application? > > It calls the functions defined in the WebCore/accessibility directory.
Thanks. I took a look at WebCore/accessibility/, and I couldn't get what would happen in this case. ok, I'll implement LocalizedNumberCF and try VoiceOver. I think VoiceOver should get localized text.
Kent Tamura
Comment 12
2011-02-01 02:33:42 PST
Created
attachment 80733
[details]
Patch 3 Add LocalizedNumberMac.mm and a test
Kent Tamura
Comment 13
2011-02-01 02:34:35 PST
(In reply to
comment #11
)
> I think VoiceOver should get localized text.
I confirmed that VoiceOver got a localized one with the patch.
Kent Tamura
Comment 14
2011-02-01 06:30:57 PST
Created
attachment 80755
[details]
Patch 4 Fix parsing error handling in LocalizedNumberMac.mm
Kent Tamura
Comment 15
2011-02-01 20:55:30 PST
Created
attachment 80884
[details]
Patch 5
Kent Tamura
Comment 16
2011-02-28 19:51:45 PST
Created
attachment 84179
[details]
Patch 6 Rebased
Dimitri Glazkov (Google)
Comment 17
2011-03-01 15:28:58 PST
Comment on
attachment 84179
[details]
Patch 6 View in context:
https://bugs.webkit.org/attachment.cgi?id=84179&action=review
> Source/WebCore/WebCore.xcodeproj/project.pbxproj:5665 > + F5CC42DC12F801CA00D5F7E3 /* LocalizedNumberMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5CC42DB12F801CA00D5F7E3 /* LocalizedNumberMac.mm */; };
Did you run sort-Xcode-project-file after your changes? This file looks out of order.
> Source/WebCore/platform/text/mac/LocalizedNumberMac.mm:58 > + NSNumberFormatter* formatter = [[[NSNumberFormatter alloc] init] autorelease];
I don't know how this stuff works. Can you check with ObJC-heads before landing?
Alexey Proskuryakov
Comment 18
2011-03-01 16:08:42 PST
> Source/WebCore/platform/text/mac/LocalizedNumberMac.mm:58 > + NSNumberFormatter* formatter = [[[NSNumberFormatter alloc] init] autorelease];
Although autorelease works, we prefer explicit refcounting in WebCore. So, this should be: RetainPtr<NSNumberFormatter> formatter(AdoptNS, [[NSNumberFormatter alloc] init]); + NSNumber* num = [formatter numberFromString:numberString]; Please don't abbreviate. + if (num == nil) WebKit style is to not compare to zero, so this should just be "if (!num)" (with a better name for num). + NSNumber* num = [NSNumber numberWithDouble:number]; WebKit style is to put stars on the other side for Objective-C types. But it would be better to use alloc/init and RetainPtr here, too. The reasons I know of are: 1) It's faster to destroy temporaries right away, while they are in memory cache. 2) The autorelease pool won't be drained during micro-benchmarks that spin without returning to message loop, causing high memory usage.
Kent Tamura
Comment 19
2011-03-01 17:24:03 PST
Dimitri, Alexey, thank you for reviewing. I'll update the code and commit it.
Kent Tamura
Comment 20
2011-03-01 22:21:45 PST
> + NSNumber* num = [formatter numberFromString:numberString]; > + if (num == nil)
Should we use RetainPtr<> here too?
Kent Tamura
Comment 21
2011-03-01 22:47:06 PST
(In reply to
comment #20
)
> > + NSNumber* num = [formatter numberFromString:numberString]; > > + if (num == nil) > > Should we use RetainPtr<> here too?
Probably, no. This object is already registered to an autorelease pool by NSNumberFormatter.
Kent Tamura
Comment 22
2011-03-01 22:55:56 PST
Landed:
http://trac.webkit.org/changeset/80096
Alexey Proskuryakov
Comment 23
2011-03-01 23:04:44 PST
I think that it's more of a coding style issue in this case. If we were optimizing this function, we'd likely have to cache NSNumberFormatter instance at least.
Kent Tamura
Comment 24
2011-03-02 15:41:52 PST
(In reply to
comment #23
)
> I think that it's more of a coding style issue in this case. If we were optimizing this function, we'd likely have to cache NSNumberFormatter instance at least.
Indeed. These functions should be called only the main thread. It's easy to cache the number formatter.
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