Changeset 138365 in webkit
- Timestamp:
- Dec 21, 2012 4:42:20 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r138362 r138365 1 2012-12-21 Keishi Hattori <keishi@webkit.org> 2 3 Fix typing zero into multiple field input 4 https://bugs.webkit.org/show_bug.cgi?id=105501 5 6 Reviewed by Kent Tamura. 7 8 * fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events-expected.txt: 9 * fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events.html: 10 * fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events-expected.txt: 11 * fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events.html: 12 * fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events-expected.txt: 13 * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt: 14 * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html: 15 * fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events-expected.txt: 16 * fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events.html: 17 1 18 2012-12-21 János Badics <jbadics@inf.u-szeged.hu> 2 19 -
trunk/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events-expected.txt
r138255 r138365 15 15 == Digit keys == 16 16 PASS input.value is "0012-09-20" 17 == Digit keys starting with zero == 18 PASS input.value is "0044-02-03" 19 == Digit keys and backspace key == 20 PASS input.value is "0008-05-06" 17 21 == Left/Right keys == 18 22 PASS input.value is "2012-09-06" -
trunk/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events.html
r138255 r138365 55 55 shouldBeEqualToString('input.value', '0012-09-20'); 56 56 57 beginTest('Digit keys starting with zero'); 58 keyDown('0'); // -> [00]/dd/yyyy 59 keyDown('2'); // -> 02/[dd]/yyyy 60 keyDown('0'); // -> 02/[00]/yyyy 61 keyDown('3'); // -> 02/03/[yyyy] 62 keyDown('0'); // -> 02/03/[0000] 63 keyDown('0'); // -> 02/03/[0000] 64 keyDown('0'); // -> 02/03/[0000] 65 keyDown('4'); // -> 02/03/[0004] 66 keyDown('4'); // -> 02/03/[0044] 67 shouldBeEqualToString('input.value', '0044-02-03'); 68 69 beginTest('Digit keys and backspace key'); 70 keyDown('1'); // -> [01]/dd/yyyy 71 keyDown("\b"); // -> [mm]/20/2012 72 keyDown('5'); // -> 05/[dd]/yyyy 73 keyDown('6'); // -> 05/06/[yyyy] 74 keyDown("\b"); // -> 05/06/[yyyy] 75 keyDown('7'); // -> 05/06/[0007] 76 keyDown("\b"); // -> 05/06/[yyyy] 77 keyDown('8'); // -> 05/06/[0008] 78 shouldBeEqualToString('input.value', '0008-05-06'); 79 57 80 // FIXME: We should test type ahead time out. When event.leapForward() affects 58 81 // keyboard event time stamp, we can uncomment this fragment. -
trunk/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events-expected.txt
r138255 r138365 15 15 == Digit keys == 16 16 PASS input.value is "98765-09-20T07:56" 17 == Digit keys starting with zero == 18 PASS input.value is "0044-02-03T05:06" 19 == Digit keys and backspace key == 20 PASS input.value is "0008-05-06T09:10" 17 21 == Left/Right keys == 18 22 PASS input.value is "0004-09-05T19:05" -
trunk/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events.html
r138255 r138365 59 59 shouldBeEqualToString('input.value', '98765-09-20T07:56'); 60 60 61 beginTest('Digit keys starting with zero', null, null, '9999-12-31T23:59'); 62 keyDown('0'); // -> [00]/dd/yyyy --:-- -- 63 keyDown('2'); // -> 02/[dd]/yyyy --:-- -- 64 keyDown('0'); // -> 02/[00]/yyyy --:-- -- 65 keyDown('3'); // -> 02/03/[yyyy] --:-- -- 66 keyDown('0'); // -> 02/03/[0000] --:-- -- 67 keyDown('0'); // -> 02/03/[0000] --:-- -- 68 keyDown('4'); // -> 02/03/[0044] --:-- -- 69 keyDown('4'); // -> 02/03/[0044] --:-- -- 70 keyDown('0'); // -> 02/03/0044 [00]:-- -- 71 keyDown('5'); // -> 02/03/0044 05:[--] -- 72 keyDown('0'); // -> 02/03/0044 01:[01] -- 73 keyDown('6'); // -> 02/03/0044 05:06 [--] 74 keyDown('A'); // -> 02/03/0044 05:06 AM 75 shouldBeEqualToString('input.value', '0044-02-03T05:06'); 76 77 beginTest('Digit keys and backspace key'); 78 keyDown('1'); // -> [01]/dd/yyyy --:-- -- 79 keyDown("\b"); // -> [mm]/20/2012 --:-- -- 80 keyDown('5'); // -> 05/[dd]/yyyy --:-- -- 81 keyDown('6'); // -> 05/06/[yyyy] --:-- -- 82 keyDown("\b"); // -> 05/06/[yyyy] --:-- -- 83 keyDown('7'); // -> 05/06/[0007] --:-- -- 84 keyDown("\b"); // -> 05/06/[yyyy] --:-- -- 85 keyDown('8'); // -> 05/06/[0008] --:-- -- 86 keyDown('rightArrow'); // -> 05/06/0008 [--]:-- -- 87 keyDown('9'); // -> 05/06/0008 09:[--] -- 88 keyDown('1'); // -> 05/06/0008 09:[01] -- 89 keyDown('0'); // -> 05/06/0008 09:10 [--] 90 keyDown('A'); // -> 05/06/0008 09:10 [AM] 91 shouldBeEqualToString('input.value', '0008-05-06T09:10'); 92 61 93 // FIXME: We should test type ahead time out. When event.leapForward() affects 62 94 // keyboard event time stamp, we can uncomment this fragment. -
trunk/LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events-expected.txt
r137275 r138365 14 14 15 15 == Digit keys == 16 FAIL input.value should be 0012-09. Was 0112-09. 16 PASS input.value is "0012-09" 17 17 == Left/Right keys == 18 18 PASS input.value is "0005-06" -
trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt
r137275 r138365 15 15 == Digit keys == 16 16 PASS input.value is "07:56" 17 == Digit keys starting with zero == 18 PASS input.value is "14:03" 19 == Digit keys and backspace key == 20 PASS input.value is "17:06" 17 21 == Left/Right keys == 18 22 PASS input.value is "06:05" -
trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html
r137275 r138365 48 48 keyDown('A'); 49 49 shouldBeEqualToString('input.value', '07:56'); 50 51 beginTest('Digit keys starting with zero'); 52 keyDown('0'); // -> [00]:-- -- 53 keyDown('2'); // -> 02:[--] -- 54 keyDown('0'); // -> 02:[00] -- 55 keyDown('3'); // -> 02:03 [--] 56 keyDown('P'); // -> 02:03 [PM] 57 shouldBeEqualToString('input.value', '14:03'); 58 59 beginTest('Digit keys and backspace key','01:01'); 60 keyDown('0'); // -> [00]:-- -- 61 keyDown('\b'); // -> [--]:-- -- 62 keyDown('5'); // -> 05:[--] -- 63 keyDown('6'); // -> 05:06 [--] 64 keyDown('\b'); // -> 05:06 [--] 65 keyDown('P'); // -> 05:06 [PM] 66 shouldBeEqualToString('input.value', '17:06'); 50 67 51 68 // FIXME: We should test type ahead time out. When event.leapForward() affects -
trunk/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events-expected.txt
r138255 r138365 15 15 == Digit keys == 16 16 PASS input.value is "0012-W09" 17 == Digit keys starting with zero == 18 PASS input.value is "0300-W02" 19 == Digit keys and backspace key == 20 PASS input.value is "0006-W01" 17 21 == Left/Right keys == 18 22 PASS input.value is "0005-W06" -
trunk/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events.html
r138255 r138365 53 53 shouldBeEqualToString('input.value', '0012-W09'); 54 54 55 beginTest('Digit keys starting with zero'); 56 keyDown('0'); // -> Week [00], yyyy 57 keyDown('2'); // -> Week 02, [yyyy] 58 keyDown('0'); // -> Week 02, [0000] 59 keyDown('3'); // -> Week 02, [0003] 60 keyDown('0'); // -> Week 02, [0030] 61 keyDown('0'); // -> Week 02, [0300] 62 shouldBeEqualToString('input.value', '0300-W02'); 63 64 beginTest('Digit keys and backspace key'); 65 keyDown('0'); // -> Week [00], yyyy 66 keyDown('\b'); // -> Week [ww], yyyy 67 keyDown('0'); // -> Week [00], yyyy 68 keyDown('0'); // -> Week 01, [yyyy] 69 keyDown('0'); // -> Week 01, [0000] 70 keyDown('6'); // -> Week 05, [0006] 71 shouldBeEqualToString('input.value', '0006-W01'); 72 55 73 // FIXME: We should test type ahead time out. When event.leapForward() affects 56 74 // keyboard event time stamp, we can uncomment this fragment. -
trunk/Source/WebCore/ChangeLog
r138364 r138365 1 2012-12-21 Keishi Hattori <keishi@webkit.org> 2 3 Fix typing zero into multiple field input 4 https://bugs.webkit.org/show_bug.cgi?id=105501 5 6 Reviewed by Kent Tamura. 7 8 We have a couple of problems when handling zero in a multiple fields 9 element. 10 1. Typing '02' into a month field will set '12'. 11 2. Typing '0' into 12 hour hour field will set '12' and move to the 12 focus to the next field. 13 This change adds a type ahead buffer so we can handle these cases 14 properly. If the value in the type ahead buffer is valid we set it so a 15 change event will fire. 16 17 Added tests to *-multiple-fields-keyboard-events.html. 18 19 * html/shadow/DateTimeNumericFieldElement.cpp: 20 (WebCore::DateTimeNumericFieldElement::didBlur): Clear the type ahead 21 buffer. handleKeyboardEvent() won't set the type ahead value if it is 22 not in range, so we set the value here. 23 (WebCore::DateTimeNumericFieldElement::handleKeyboardEvent): 24 (WebCore::DateTimeNumericFieldElement::setEmptyValue): Clear type ahead buffer. 25 (WebCore::DateTimeNumericFieldElement::setValueAsInteger): 26 (WebCore::DateTimeNumericFieldElement::stepDown): Clear type ahead buffer. 27 (WebCore::DateTimeNumericFieldElement::stepUp): Clear type ahead buffer. 28 (WebCore::DateTimeNumericFieldElement::typeAheadValue): Returns integer 29 value for the type ahead characters. 30 (WebCore): 31 (WebCore::DateTimeNumericFieldElement::visibleValue): If we have type 32 ahead characters, show that. 33 * html/shadow/DateTimeNumericFieldElement.h: 34 (DateTimeNumericFieldElement): 35 1 36 2012-12-21 Xabier Rodriguez Calvar <calvaris@igalia.com> 2 37 -
trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp
r137712 r138365 108 108 void DateTimeNumericFieldElement::didBlur() 109 109 { 110 m_lastDigitCharTime = 0; 110 int value = typeAheadValue(); 111 m_typeAheadBuffer.clear(); 112 if (value >= 0) 113 setValueAsInteger(value, DispatchEvent); 111 114 DateTimeFieldElement::didBlur(); 112 115 } … … 131 134 132 135 UChar charCode = static_cast<UChar>(keyboardEvent->charCode()); 133 if (charCode < ' ')134 return;135 136 DOMTimeStamp delta = keyboardEvent->timeStamp() - m_lastDigitCharTime;137 m_lastDigitCharTime = 0;138 139 136 String number = localeForOwner().convertFromLocalizedNumber(String(&charCode, 1)); 140 137 const int digit = number[0] - '0'; … … 142 139 return; 143 140 141 DOMTimeStamp delta = keyboardEvent->timeStamp() - m_lastDigitCharTime; 142 m_lastDigitCharTime = keyboardEvent->timeStamp(); 143 144 if (delta > typeAheadTimeout) 145 m_typeAheadBuffer.clear(); 146 m_typeAheadBuffer.append(number); 147 148 int newValue = typeAheadValue(); 149 if (m_range.isInRange(newValue)) 150 setValueAsInteger(newValue, DispatchEvent); 151 else 152 updateVisibleValue(DispatchEvent); 153 154 if (m_typeAheadBuffer.length() >= DateTimeNumericFieldElement::formatValue(m_range.maximum).length() || newValue * 10 > m_range.maximum) 155 focusOnNextField(); 156 144 157 keyboardEvent->setDefaultHandled(); 145 setValueAsInteger(m_hasValue && delta < typeAheadTimeout ? m_value * 10 + digit : digit, DispatchEvent);146 if (m_value * 10 > m_range.maximum)147 focusOnNextField();148 else149 m_lastDigitCharTime = keyboardEvent->timeStamp();150 158 } 151 159 … … 167 175 void DateTimeNumericFieldElement::setEmptyValue(EventBehavior eventBehavior) 168 176 { 169 m_lastDigitCharTime = 0;170 171 177 if (isReadOnly()) 172 178 return; … … 174 180 m_hasValue = false; 175 181 m_value = 0; 182 m_typeAheadBuffer.clear(); 176 183 updateVisibleValue(eventBehavior); 177 184 } … … 182 189 m_hasValue = true; 183 190 updateVisibleValue(eventBehavior); 184 m_lastDigitCharTime = 0;185 191 } 186 192 … … 190 196 if (!m_range.isInRange(newValue)) 191 197 newValue = roundDown(m_range.maximum); 198 m_typeAheadBuffer.clear(); 192 199 setValueAsInteger(newValue, DispatchEvent); 193 200 } … … 198 205 if (!m_range.isInRange(newValue)) 199 206 newValue = roundUp(m_range.minimum); 207 m_typeAheadBuffer.clear(); 200 208 setValueAsInteger(newValue, DispatchEvent); 201 209 } … … 211 219 } 212 220 221 int DateTimeNumericFieldElement::typeAheadValue() const 222 { 223 if (m_typeAheadBuffer.length()) 224 return m_typeAheadBuffer.toString().toInt(); 225 return -1; 226 } 227 213 228 String DateTimeNumericFieldElement::visibleValue() const 214 229 { 230 if (m_typeAheadBuffer.length()) 231 return formatValue(typeAheadValue()); 215 232 return m_hasValue ? value() : m_placeholder; 216 233 } -
trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.h
r137712 r138365 88 88 int roundUp(int) const; 89 89 int roundDown(int) const; 90 int typeAheadValue() const; 90 91 91 92 DOMTimeStamp m_lastDigitCharTime; … … 96 97 int m_step; 97 98 int m_stepBase; 99 mutable StringBuilder m_typeAheadBuffer; 98 100 }; 99 101
Note: See TracChangeset
for help on using the changeset viewer.