RESOLVED FIXED Bug 29069
[HTML5][Forms] min/max attributes support for type=number
https://bugs.webkit.org/show_bug.cgi?id=29069
Summary [HTML5][Forms] min/max attributes support for type=number
Kent Tamura
Reported 2009-09-08 23:04:24 PDT
Implement min/max attributes and ValidityState.rangeUnderflow and .rangeOverflow for <input type=number>.
Attachments
Proposed patch (28.08 KB, patch)
2009-09-09 20:01 PDT, Kent Tamura
no flags
Proposed patch (rev.2) (31.19 KB, patch)
2009-09-21 10:03 PDT, Kent Tamura
eric: review-
Proposed patch (rev.3) (31.24 KB, patch)
2009-09-23 17:38 PDT, Kent Tamura
no flags
Proposed patch (rev.4) (31.33 KB, patch)
2009-10-04 19:08 PDT, Kent Tamura
darin: review+
Proposed patch (rev.5) (31.37 KB, patch)
2009-10-04 19:36 PDT, Kent Tamura
darin: review+
Proposed patch (rev.6) (31.38 KB, patch)
2009-10-04 21:24 PDT, Kent Tamura
no flags
Proposed patch (rev.7) (32.34 KB, patch)
2009-10-05 19:43 PDT, Kent Tamura
no flags
Kent Tamura
Comment 1 2009-09-08 23:06:06 PDT
I'm working on this.
Kent Tamura
Comment 2 2009-09-09 20:01:04 PDT
Created attachment 39319 [details] Proposed patch
Kent Tamura
Comment 3 2009-09-21 10:03:19 PDT
Created attachment 39858 [details] Proposed patch (rev.2) resources/ -> script-tests/
Eric Seidel (no email)
Comment 4 2009-09-23 10:54:04 PDT
Comment on attachment 39858 [details] Proposed patch (rev.2) Reversed, no? 53 double maximum; // maximum must be <= minimum. Tab, will cause commit to fail: 13 testPassed(resultText); I would have probably written a little static inline function to help grab the numbers, but I think my "make a function" threshold is lower than most others: double min; 202 double doubleValue; 203 if (hasAttribute(minAttr) && formStringToDouble(getAttribute(minAttr).string(), &min) && formStringToDouble(value(), &doubleValue)) 204 return doubleValue < min; This comment mostly confuses me: 249 max = min; // The spec allows min == max. I'm not surprised that min is allowed to equal max. Why not write that whole if as: max = max(min, max(100, max)) obviously you'd have to use std:: or change the name of max. r- for the nits. Really only the backwards comment, the rest doesn't need to be changed. If you were a committer, I would r+ this and you could commit it with mods yourself.
Kent Tamura
Comment 5 2009-09-23 17:38:38 PDT
Created attachment 40033 [details] Proposed patch (rev.3) > Reversed, no? > 53 double maximum; // maximum must be <= minimum. Right! Fixed. > Tab, will cause commit to fail: > 13 testPassed(resultText); Fixed 8 instances in 4 files. > I would have probably written a little static inline function to help grab the > numbers, but I think my "make a function" threshold is lower than most others: > double min; > 202 double doubleValue; > 203 if (hasAttribute(minAttr) && formStringToDouble(getAttribute(minAttr).string(), &min) && formStringToDouble(value(), &doubleValue)) > 204 return doubleValue < min; I didn't make a such function, and simplified this code by removing hasAttribute() and .string() instead. formStringToDouble() returns false if the input string is null. > This comment mostly confuses me: > 249 max = min; // The spec allows min == max. > I'm not surprised that min is allowed to equal max. I improved the code and comments here.
Kent Tamura
Comment 6 2009-10-04 19:08:12 PDT
Created attachment 40601 [details] Proposed patch (rev.4) Resolved conflicts with today's WebKit.
Darin Adler
Comment 7 2009-10-04 19:27:14 PDT
Comment on attachment 40601 [details] Proposed patch (rev.4) > + // Returns the minimum value for type=range. Don't call this for other types. > + double minRange() const; I think this should be named rangeMinimum(), not minRange(), which sounds like "minimum range" to me. > + // Returns the maximum value for type=range. Don't call this for other types. > + // This always returns a value which is <= minRange(). > + double maxRange() const; And rangeMaximum() for this. Otherwise seems fine to me, r=me
Kent Tamura
Comment 8 2009-10-04 19:36:35 PDT
Created attachment 40602 [details] Proposed patch (rev.5) Renamed minRange() to rangeMinimum(), maxRange() to rangeMaximum().
Darin Adler
Comment 9 2009-10-04 20:18:50 PDT
Comment on attachment 40602 [details] Proposed patch (rev.5) > + (WebCore::HTMLInputElement::minRange): > + (WebCore::HTMLInputElement::maxRange): Needs new name here. > + // This always returns a value which is <= minRange(). And here. Still fine as-is, but better to get it right.
Kent Tamura
Comment 10 2009-10-04 21:24:41 PDT
Created attachment 40608 [details] Proposed patch (rev.6) Oops, updated a comment and ChangeLog for rangeMinimum()/rangeMaximum().
WebKit Commit Bot
Comment 11 2009-10-05 11:14:57 PDT
Comment on attachment 40608 [details] Proposed patch (rev.6) Clearing flags on attachment: 40608 Committed r49104: <http://trac.webkit.org/changeset/49104>
WebKit Commit Bot
Comment 12 2009-10-05 11:15:01 PDT
All reviewed patches have been landed. Closing bug.
Eric Seidel (no email)
Comment 13 2009-10-05 12:00:34 PDT
This broke the windows bots: http://build.webkit.org/builders/Windows%20Debug%20%28Build%29/builds/5913 so I've asked the commit-bot to roll out this patch. Should be rolled out in 10 minutes or so.
Darin Adler
Comment 14 2009-10-05 12:02:07 PDT
Looks like the build failure was due to MSVC not being smart enough about uninitialized variables and code flow. Should be easy to work around.
Eric Seidel (no email)
Comment 15 2009-10-05 12:05:26 PDT
Brian got past that error by initializing doubleValue to 0.0, but then hit 17 more and gave up. Hence the rollout.
Eric Seidel (no email)
Comment 16 2009-10-05 12:11:43 PDT
Kent Tamura
Comment 17 2009-10-05 19:43:17 PDT
Created attachment 40679 [details] Proposed patch (rev.7) Fixed the build problems on Windows. - Initialize local variables with 0.0 - Not define max/min for COM to avoid conflict in WebKit.h I think to add "#define NOMINMAX" to WebKit.h is the right fix. But I couldn't find who generates WebKit.h.
Kent Tamura
Comment 18 2009-10-05 22:40:53 PDT
I found WebKit.h was generated by MIDL. It's hard to insert "#define NO_MINMAX" to it. I think WebKit.h is a public header, and we should not add "#define NO_MINMAX" to it and should not request "define NO_MINMAX before including WebKit.h" because it would break source-code compatibility. So, I think the patch (rev.7) is the best approach.
WebKit Commit Bot
Comment 19 2009-10-06 11:47:29 PDT
Comment on attachment 40679 [details] Proposed patch (rev.7) Clearing flags on attachment: 40679 Committed r49199: <http://trac.webkit.org/changeset/49199>
WebKit Commit Bot
Comment 20 2009-10-06 11:47:34 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.