Closed Bug 771559 Opened 8 years ago Closed 6 years ago

HTML's "valid floating point number" doesn't match ToDouble()

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla28

People

(Reporter: mounir, Assigned: jwatt)

References

()

Details

(Whiteboard: [qa-])

Attachments

(1 file)

See: 
http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#valid-floating-point-number

I haven't checked more deeply than that but it seems at least that we allow stuff like "+22" while HTML algorithm refuses it.
FWIW, Webkit and Presto are following the specs.
I should be able to get what we want using StringToDoubleConverter, I think.
Assignee: nobody → jwatt
Interesting thread on HTML vs. JS number parsing:

http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-August/thread.html#32792
(In reply to Jonathan Watt [:jwatt] from comment #1)
> I should be able to get what we want using StringToDoubleConverter, I think.

Actually, no. We now have webcore's Decimal class and, like for NS_FORM_INPUT_RANGE, we should use HTMLInputElement::ConvertStringToNumber, which uses webcore's Decimal::fromString, which Google has written to conform to the HTML5's rules for a "valid floating point number":

https://mxr.mozilla.org/mozilla-central/source/mfbt/decimal/Decimal.h?mark=165-172&rev=a296036e608f#165
Attached patch patchSplinter Review
Attachment #8336809 - Flags: review?(bugs)
Comment on attachment 8336809 [details] [diff] [review]
patch

Some test would be nice.
Attachment #8336809 - Flags: review?(bugs) → review+
https://hg.mozilla.org/mozilla-central/rev/836ee14f6a37
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
Whiteboard: [qa-]
You need to log in before you can comment on or make changes to this bug.