Changeset 70615 in webkit
- Timestamp:
- Oct 26, 2010 10:42:29 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r70609 r70615 1 2010-10-26 Dai Mikurube <dmikurube@google.com> 2 3 Reviewed by Kent Tamura. 4 5 constraint validation: stepMismatch (rounding error) 6 https://bugs.webkit.org/show_bug.cgi?id=48220 7 8 * fast/forms/ValidityState-stepMismatch-expected.txt: 9 * fast/forms/script-tests/ValidityState-stepMismatch.js: 10 1 11 2010-10-26 Antonio Gomes <agomes@rim.com> 2 12 -
trunk/LayoutTests/fast/forms/ValidityState-stepMismatch-expected.txt
r70549 r70615 143 143 PASS stepMismatchFor("0.9", "0.1000000000000001", "") is false 144 144 PASS stepMismatchFor("1.0", "0.3333333333333333", "") is false 145 Rounding 146 PASS stepMismatchFor("5.005", "0.005", "4") is false 145 147 146 148 Range type -
trunk/LayoutTests/fast/forms/script-tests/ValidityState-stepMismatch.js
r70549 r70615 160 160 shouldBe('stepMismatchFor("0.9", "0.1000000000000001", "")', 'false'); 161 161 shouldBe('stepMismatchFor("1.0", "0.3333333333333333", "")', 'false'); 162 debug('Rounding'); 163 shouldBe('stepMismatchFor("5.005", "0.005", "4")', 'false'); 162 164 163 165 debug(''); -
trunk/WebCore/ChangeLog
r70605 r70615 1 2010-10-26 Dai Mikurube <dmikurube@google.com> 2 3 Reviewed by Kent Tamura. 4 5 constraint validation: stepMismatch (rounding error) 6 https://bugs.webkit.org/show_bug.cgi?id=48220 7 8 1. Changed the computation to achieve difference from a integral 9 multiple of the allowed value step. 10 11 The previous fmod(doubleValue, step) sometimes returned unacceptable 12 remainder. For example, 13 double doubleValue = 1.005; // Actually, near to 1.005 14 double step = 0.005; // Actually, near to 0.005 15 fmod(doubleValue, step) ==> (near to) 0.005 16 It's a case that doubleValue is a little smaller than 1.005 and step is 17 a little larger than 0.005. 18 19 2. Changed the error threshold. 20 21 Number values in HTML5 are expressed in IEEE 754 single-precision. 22 Too precise comparison sometimes leads unintended errors. 23 24 For example, I found a case : 25 remainder = 0.00000000000000022204460 26 acceptableError = 0.00000000000000007105427 27 28 * html/NumberInputType.cpp: 29 (WebCore::NumberInputType::stepMismatch): 30 1 31 2010-10-26 Chris Rogers <crogers@google.com> 2 32 -
trunk/WebCore/html/NumberInputType.cpp
r70549 r70615 122 122 return false; 123 123 // double's fractional part size is DBL_MAN_DIG-bit. If the current value 124 // is greater than step*2^DBL_MANT_DIG, the following fmod() makes no sense. 124 // is greater than step*2^DBL_MANT_DIG, the following computation for 125 // remainder makes no sense. 125 126 if (doubleValue / pow(2.0, DBL_MANT_DIG) > step) 126 127 return false; 127 double remainder = fmod(doubleValue, step); 128 // Accepts errors in lower 7-bit. 129 double acceptableError = step / pow(2.0, DBL_MANT_DIG - 7); 128 // The computation follows HTML5 4.10.7.2.10 `The step attribute' : 129 // ... that number subtracted from the step base is not an integral multiple 130 // of the allowed value step, the element is suffering from a step mismatch. 131 double remainder = fabs(doubleValue - step * round(doubleValue / step)); 132 // Accepts erros in lower fractional part which IEEE 754 single-precision 133 // can't represent. 134 double acceptableError = step / pow(2.0, FLT_MANT_DIG); 130 135 return acceptableError < remainder && remainder < (step - acceptableError); 131 136 }
Note: See TracChangeset
for help on using the changeset viewer.