WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
28934
Add <input type=number> validation support
https://bugs.webkit.org/show_bug.cgi?id=28934
Summary
Add <input type=number> validation support
Kent Tamura
Reported
2009-09-02 22:42:46 PDT
Also see
http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#valid-floating-point-number
Attachments
Proposed patch
(9.17 KB, patch)
2009-09-03 00:17 PDT
,
Kent Tamura
eric
: review-
Details
Formatted Diff
Diff
Proposed patch (rev.2)
(9.21 KB, patch)
2009-09-03 02:08 PDT
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Proposed patch (rev.3)
(9.20 KB, patch)
2009-09-03 19:06 PDT
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Proposed patch (rev.4)
(8.18 KB, patch)
2009-09-04 02:18 PDT
,
Kent Tamura
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Kent Tamura
Comment 1
2009-09-03 00:17:08 PDT
Created
attachment 38969
[details]
Proposed patch stringToFloat() is in HTMLInputElement.cpp because it will be used to parse min= max= step= attributes.
Eric Seidel (no email)
Comment 2
2009-09-03 01:21:51 PDT
Comment on
attachment 38969
[details]
Proposed patch It seems stringToFloat should have HTML5 in teh name. It's not a generic function, but rather a specific html5-compatible implementation. html5CompatStringToFloat html5SpecStingToFloat ? This would be better as a single if unless there is a grand plan to add a bunch more types... + switch (input->inputType()) { + case HTMLInputElement::NUMBER: + return !HTMLInputElement::stringToFloat(value, 0); + default: + return false; + } if (input->type() != HTMLInputElement::NUMBER) return false; // Check to make sure the number is valid, ignore the parsed number. return !HTMLInputElement::stringToFloat(value, 0); Otherwise looks fine.
Kent Tamura
Comment 3
2009-09-03 02:08:26 PDT
Created
attachment 38976
[details]
Proposed patch (rev.2) - Followed Eric's comments
Peter Kasting
Comment 4
2009-09-03 11:19:09 PDT
I disagree with Eric. Putting "HTML5" in function names is completely inappropriate given that this functionality will also be required for HTML 6, 7, ... and in fact HTML is switching to be unversioned (see e.g. "DOCTYPE HTML" and some of Hixie's comments). These functions should be called things like "userInputToDouble" or "inputStringToDouble" or something to indicate that the difference between them and a generic conversion to double is the fact that the origin is some kind of user input which needs additional validation or conversion. Also, nitpick: "numeber" -> "number" in at least one place.
Darin Adler
Comment 5
2009-09-03 12:59:36 PDT
(In reply to
comment #4
)
> These functions should be called things like > "userInputToDouble" or "inputStringToDouble" or something to indicate that the > difference between them and a generic conversion to double is the fact that the > origin is some kind of user input which needs additional validation or > conversion.
That sounds right to me too.
Ian 'Hixie' Hickson
Comment 6
2009-09-03 15:50:18 PDT
Putting "html5" in method or file names will just mean that a few years from now someone will have to go and rename the methods or files, just like we did recently with html4.css.
Kent Tamura
Comment 7
2009-09-03 19:06:56 PDT
Created
attachment 39031
[details]
Proposed patch (rev.3) Thank you for the comments. - toDoubleForHtml5() -> formStringToDouble() I didn't use "input" "user" because this method will be used for min= max= step= attributes. - Fix a typo
Kent Tamura
Comment 8
2009-09-04 02:18:51 PDT
Created
attachment 39046
[details]
Proposed patch (rev.4) - Resolve conflict with type=color.
Eric Seidel (no email)
Comment 9
2009-09-08 09:49:53 PDT
Comment on
attachment 39046
[details]
Proposed patch (rev.4) LGTM.
Eric Seidel (no email)
Comment 10
2009-09-08 10:00:55 PDT
Comment on
attachment 39046
[details]
Proposed patch (rev.4) Rejecting patch 39046 from commit-queue. This patch will require manual commit. ['WebKitTools/Scripts/run-webkit-tests', '--no-launch-safari', '--quiet', '--exit-after-n-failures=1'] failed with exit code 1
Eric Seidel (no email)
Comment 11
2009-09-08 10:02:48 PDT
Comment on
attachment 39046
[details]
Proposed patch (rev.4) Bitten by
bug 29037
.
Eric Seidel (no email)
Comment 12
2009-09-08 10:23:15 PDT
Comment on
attachment 39046
[details]
Proposed patch (rev.4) Clearing flags on attachment: 39046 Committed
r48163
: <
http://trac.webkit.org/changeset/48163
>
Eric Seidel (no email)
Comment 13
2009-09-08 10:23:20 PDT
All reviewed patches have been landed. Closing bug.
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