summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authorkeishi@webkit.org <keishi@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2012-12-21 12:42:20 +0000
committerkeishi@webkit.org <keishi@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2012-12-21 12:42:20 +0000
commitc1cdaec5af4162dd3672db0caf3d54aca5278da7 (patch)
treed442ead25759d9f63bf29c208eec1932c6e607f8 /third_party
parent719c7e82cfc487d7a97549a78385d529172f8c4f (diff)
downloadchromium_src-c1cdaec5af4162dd3672db0caf3d54aca5278da7.zip
chromium_src-c1cdaec5af4162dd3672db0caf3d54aca5278da7.tar.gz
chromium_src-c1cdaec5af4162dd3672db0caf3d54aca5278da7.tar.bz2
Fix typing zero into multiple field input
https://bugs.webkit.org/show_bug.cgi?id=105501 Reviewed by Kent Tamura. Source/WebCore: We have a couple of problems when handling zero in a multiple fields element. 1. Typing '02' into a month field will set '12'. 2. Typing '0' into 12 hour hour field will set '12' and move to the focus to the next field. This change adds a type ahead buffer so we can handle these cases properly. If the value in the type ahead buffer is valid we set it so a change event will fire. Added tests to *-multiple-fields-keyboard-events.html. * html/shadow/DateTimeNumericFieldElement.cpp: (WebCore::DateTimeNumericFieldElement::didBlur): Clear the type ahead buffer. handleKeyboardEvent() won't set the type ahead value if it is not in range, so we set the value here. (WebCore::DateTimeNumericFieldElement::handleKeyboardEvent): (WebCore::DateTimeNumericFieldElement::setEmptyValue): Clear type ahead buffer. (WebCore::DateTimeNumericFieldElement::setValueAsInteger): (WebCore::DateTimeNumericFieldElement::stepDown): Clear type ahead buffer. (WebCore::DateTimeNumericFieldElement::stepUp): Clear type ahead buffer. (WebCore::DateTimeNumericFieldElement::typeAheadValue): Returns integer value for the type ahead characters. (WebCore): (WebCore::DateTimeNumericFieldElement::visibleValue): If we have type ahead characters, show that. * html/shadow/DateTimeNumericFieldElement.h: (DateTimeNumericFieldElement): LayoutTests: * fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events-expected.txt: * fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events.html: * fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events-expected.txt: * fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events.html: * fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events-expected.txt: * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt: * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html: * fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events-expected.txt: * fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events.html: git-svn-id: svn://svn.chromium.org/blink/trunk@138365 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party')
-rw-r--r--third_party/WebKit/LayoutTests/ChangeLog17
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events-expected.txt4
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events.html23
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events-expected.txt4
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events.html32
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events-expected.txt2
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt4
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html17
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events-expected.txt4
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events.html18
-rw-r--r--third_party/WebKit/Source/WebCore/ChangeLog35
-rw-r--r--third_party/WebKit/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp47
-rw-r--r--third_party/WebKit/Source/WebCore/html/shadow/DateTimeNumericFieldElement.h2
13 files changed, 193 insertions, 16 deletions
diff --git a/third_party/WebKit/LayoutTests/ChangeLog b/third_party/WebKit/LayoutTests/ChangeLog
index c84c1be..54ea9b3 100644
--- a/third_party/WebKit/LayoutTests/ChangeLog
+++ b/third_party/WebKit/LayoutTests/ChangeLog
@@ -1,3 +1,20 @@
+2012-12-21 Keishi Hattori <keishi@webkit.org>
+
+ Fix typing zero into multiple field input
+ https://bugs.webkit.org/show_bug.cgi?id=105501
+
+ Reviewed by Kent Tamura.
+
+ * fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events-expected.txt:
+ * fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events.html:
+ * fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events-expected.txt:
+ * fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events.html:
+ * fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events-expected.txt:
+ * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt:
+ * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html:
+ * fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events-expected.txt:
+ * fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events.html:
+
2012-12-21 János Badics <jbadics@inf.u-szeged.hu>
[Qt][WK2] Gardening after r138232. Skipped 4 tests timing out.
diff --git a/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events-expected.txt
index ab8e136..d4d38fe 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events-expected.txt
@@ -14,6 +14,10 @@ Backspace - Make value empty
== Digit keys ==
PASS input.value is "0012-09-20"
+== Digit keys starting with zero ==
+PASS input.value is "0044-02-03"
+== Digit keys and backspace key ==
+PASS input.value is "0008-05-06"
== Left/Right keys ==
PASS input.value is "2012-09-06"
PASS document.activeElement.id is "input"
diff --git a/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events.html b/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events.html
index 41d2290..29ceb52 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events.html
@@ -54,6 +54,29 @@ keyDown('2'); // -> 09/20/[0012]
keyDown('A'); // Ignored.
shouldBeEqualToString('input.value', '0012-09-20');
+beginTest('Digit keys starting with zero');
+keyDown('0'); // -> [00]/dd/yyyy
+keyDown('2'); // -> 02/[dd]/yyyy
+keyDown('0'); // -> 02/[00]/yyyy
+keyDown('3'); // -> 02/03/[yyyy]
+keyDown('0'); // -> 02/03/[0000]
+keyDown('0'); // -> 02/03/[0000]
+keyDown('0'); // -> 02/03/[0000]
+keyDown('4'); // -> 02/03/[0004]
+keyDown('4'); // -> 02/03/[0044]
+shouldBeEqualToString('input.value', '0044-02-03');
+
+beginTest('Digit keys and backspace key');
+keyDown('1'); // -> [01]/dd/yyyy
+keyDown("\b"); // -> [mm]/20/2012
+keyDown('5'); // -> 05/[dd]/yyyy
+keyDown('6'); // -> 05/06/[yyyy]
+keyDown("\b"); // -> 05/06/[yyyy]
+keyDown('7'); // -> 05/06/[0007]
+keyDown("\b"); // -> 05/06/[yyyy]
+keyDown('8'); // -> 05/06/[0008]
+shouldBeEqualToString('input.value', '0008-05-06');
+
// FIXME: We should test type ahead time out. When event.leapForward() affects
// keyboard event time stamp, we can uncomment this fragment.
/*
diff --git a/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events-expected.txt
index 322a593..ce06397 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events-expected.txt
@@ -14,6 +14,10 @@ Backspace - Make value empty
== Digit keys ==
PASS input.value is "98765-09-20T07:56"
+== Digit keys starting with zero ==
+PASS input.value is "0044-02-03T05:06"
+== Digit keys and backspace key ==
+PASS input.value is "0008-05-06T09:10"
== Left/Right keys ==
PASS input.value is "0004-09-05T19:05"
PASS document.activeElement.id is "input"
diff --git a/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events.html b/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events.html
index d5b7cc8..1c15a17 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events.html
@@ -58,6 +58,38 @@ keyDown('6'); // -> 09/20/98765 07:56 [--]
keyDown('A'); // -> 09/20/98765 07:56 AM
shouldBeEqualToString('input.value', '98765-09-20T07:56');
+beginTest('Digit keys starting with zero', null, null, '9999-12-31T23:59');
+keyDown('0'); // -> [00]/dd/yyyy --:-- --
+keyDown('2'); // -> 02/[dd]/yyyy --:-- --
+keyDown('0'); // -> 02/[00]/yyyy --:-- --
+keyDown('3'); // -> 02/03/[yyyy] --:-- --
+keyDown('0'); // -> 02/03/[0000] --:-- --
+keyDown('0'); // -> 02/03/[0000] --:-- --
+keyDown('4'); // -> 02/03/[0044] --:-- --
+keyDown('4'); // -> 02/03/[0044] --:-- --
+keyDown('0'); // -> 02/03/0044 [00]:-- --
+keyDown('5'); // -> 02/03/0044 05:[--] --
+keyDown('0'); // -> 02/03/0044 01:[01] --
+keyDown('6'); // -> 02/03/0044 05:06 [--]
+keyDown('A'); // -> 02/03/0044 05:06 AM
+shouldBeEqualToString('input.value', '0044-02-03T05:06');
+
+beginTest('Digit keys and backspace key');
+keyDown('1'); // -> [01]/dd/yyyy --:-- --
+keyDown("\b"); // -> [mm]/20/2012 --:-- --
+keyDown('5'); // -> 05/[dd]/yyyy --:-- --
+keyDown('6'); // -> 05/06/[yyyy] --:-- --
+keyDown("\b"); // -> 05/06/[yyyy] --:-- --
+keyDown('7'); // -> 05/06/[0007] --:-- --
+keyDown("\b"); // -> 05/06/[yyyy] --:-- --
+keyDown('8'); // -> 05/06/[0008] --:-- --
+keyDown('rightArrow'); // -> 05/06/0008 [--]:-- --
+keyDown('9'); // -> 05/06/0008 09:[--] --
+keyDown('1'); // -> 05/06/0008 09:[01] --
+keyDown('0'); // -> 05/06/0008 09:10 [--]
+keyDown('A'); // -> 05/06/0008 09:10 [AM]
+shouldBeEqualToString('input.value', '0008-05-06T09:10');
+
// FIXME: We should test type ahead time out. When event.leapForward() affects
// keyboard event time stamp, we can uncomment this fragment.
/*
diff --git a/third_party/WebKit/LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events-expected.txt
index c698d99..b2c9ecd 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events-expected.txt
@@ -13,7 +13,7 @@ Tab - Move focus field
Backspace - Make value empty
== Digit keys ==
-FAIL input.value should be 0012-09. Was 0112-09.
+PASS input.value is "0012-09"
== Left/Right keys ==
PASS input.value is "0005-06"
PASS document.activeElement.id is "input"
diff --git a/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt
index 66f04e8..65cbdf3 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt
@@ -14,6 +14,10 @@ Backspace - Make value empty
== Digit keys ==
PASS input.value is "07:56"
+== Digit keys starting with zero ==
+PASS input.value is "14:03"
+== Digit keys and backspace key ==
+PASS input.value is "17:06"
== Left/Right keys ==
PASS input.value is "06:05"
PASS document.activeElement.id is "input"
diff --git a/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html
index 194dcad..16c6c5d 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html
@@ -48,6 +48,23 @@ keyDown('6');
keyDown('A');
shouldBeEqualToString('input.value', '07:56');
+beginTest('Digit keys starting with zero');
+keyDown('0'); // -> [00]:-- --
+keyDown('2'); // -> 02:[--] --
+keyDown('0'); // -> 02:[00] --
+keyDown('3'); // -> 02:03 [--]
+keyDown('P'); // -> 02:03 [PM]
+shouldBeEqualToString('input.value', '14:03');
+
+beginTest('Digit keys and backspace key','01:01');
+keyDown('0'); // -> [00]:-- --
+keyDown('\b'); // -> [--]:-- --
+keyDown('5'); // -> 05:[--] --
+keyDown('6'); // -> 05:06 [--]
+keyDown('\b'); // -> 05:06 [--]
+keyDown('P'); // -> 05:06 [PM]
+shouldBeEqualToString('input.value', '17:06');
+
// FIXME: We should test type ahead time out. When event.leapForward() affects
// keyboard event time stamp, we can uncomment this fragment.
/*
diff --git a/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events-expected.txt
index 733cb39..8287cb5 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events-expected.txt
@@ -14,6 +14,10 @@ Backspace - Make value empty
== Digit keys ==
PASS input.value is "0012-W09"
+== Digit keys starting with zero ==
+PASS input.value is "0300-W02"
+== Digit keys and backspace key ==
+PASS input.value is "0006-W01"
== Left/Right keys ==
PASS input.value is "0005-W06"
PASS document.activeElement.id is "input"
diff --git a/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events.html b/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events.html
index 2565e8b..5bbc983 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-keyboard-events.html
@@ -52,6 +52,24 @@ keyDown('2'); // -> Week 09, [0012]
keyDown('A'); // Ignored.
shouldBeEqualToString('input.value', '0012-W09');
+beginTest('Digit keys starting with zero');
+keyDown('0'); // -> Week [00], yyyy
+keyDown('2'); // -> Week 02, [yyyy]
+keyDown('0'); // -> Week 02, [0000]
+keyDown('3'); // -> Week 02, [0003]
+keyDown('0'); // -> Week 02, [0030]
+keyDown('0'); // -> Week 02, [0300]
+shouldBeEqualToString('input.value', '0300-W02');
+
+beginTest('Digit keys and backspace key');
+keyDown('0'); // -> Week [00], yyyy
+keyDown('\b'); // -> Week [ww], yyyy
+keyDown('0'); // -> Week [00], yyyy
+keyDown('0'); // -> Week 01, [yyyy]
+keyDown('0'); // -> Week 01, [0000]
+keyDown('6'); // -> Week 05, [0006]
+shouldBeEqualToString('input.value', '0006-W01');
+
// FIXME: We should test type ahead time out. When event.leapForward() affects
// keyboard event time stamp, we can uncomment this fragment.
/*
diff --git a/third_party/WebKit/Source/WebCore/ChangeLog b/third_party/WebKit/Source/WebCore/ChangeLog
index ca22a33..c83d4d2 100644
--- a/third_party/WebKit/Source/WebCore/ChangeLog
+++ b/third_party/WebKit/Source/WebCore/ChangeLog
@@ -1,3 +1,38 @@
+2012-12-21 Keishi Hattori <keishi@webkit.org>
+
+ Fix typing zero into multiple field input
+ https://bugs.webkit.org/show_bug.cgi?id=105501
+
+ Reviewed by Kent Tamura.
+
+ We have a couple of problems when handling zero in a multiple fields
+ element.
+ 1. Typing '02' into a month field will set '12'.
+ 2. Typing '0' into 12 hour hour field will set '12' and move to the
+ focus to the next field.
+ This change adds a type ahead buffer so we can handle these cases
+ properly. If the value in the type ahead buffer is valid we set it so a
+ change event will fire.
+
+ Added tests to *-multiple-fields-keyboard-events.html.
+
+ * html/shadow/DateTimeNumericFieldElement.cpp:
+ (WebCore::DateTimeNumericFieldElement::didBlur): Clear the type ahead
+ buffer. handleKeyboardEvent() won't set the type ahead value if it is
+ not in range, so we set the value here.
+ (WebCore::DateTimeNumericFieldElement::handleKeyboardEvent):
+ (WebCore::DateTimeNumericFieldElement::setEmptyValue): Clear type ahead buffer.
+ (WebCore::DateTimeNumericFieldElement::setValueAsInteger):
+ (WebCore::DateTimeNumericFieldElement::stepDown): Clear type ahead buffer.
+ (WebCore::DateTimeNumericFieldElement::stepUp): Clear type ahead buffer.
+ (WebCore::DateTimeNumericFieldElement::typeAheadValue): Returns integer
+ value for the type ahead characters.
+ (WebCore):
+ (WebCore::DateTimeNumericFieldElement::visibleValue): If we have type
+ ahead characters, show that.
+ * html/shadow/DateTimeNumericFieldElement.h:
+ (DateTimeNumericFieldElement):
+
2012-12-21 Xabier Rodriguez Calvar <calvaris@igalia.com>
[GStreamer] Buffering ranges are reported incorrectly with GStreamer 1.0
diff --git a/third_party/WebKit/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp b/third_party/WebKit/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp
index dc1b564..321beee 100644
--- a/third_party/WebKit/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp
+++ b/third_party/WebKit/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp
@@ -107,7 +107,10 @@ int DateTimeNumericFieldElement::defaultValueForStepUp() const
void DateTimeNumericFieldElement::didBlur()
{
- m_lastDigitCharTime = 0;
+ int value = typeAheadValue();
+ m_typeAheadBuffer.clear();
+ if (value >= 0)
+ setValueAsInteger(value, DispatchEvent);
DateTimeFieldElement::didBlur();
}
@@ -130,23 +133,28 @@ void DateTimeNumericFieldElement::handleKeyboardEvent(KeyboardEvent* keyboardEve
return;
UChar charCode = static_cast<UChar>(keyboardEvent->charCode());
- if (charCode < ' ')
- return;
-
- DOMTimeStamp delta = keyboardEvent->timeStamp() - m_lastDigitCharTime;
- m_lastDigitCharTime = 0;
-
String number = localeForOwner().convertFromLocalizedNumber(String(&charCode, 1));
const int digit = number[0] - '0';
if (digit < 0 || digit > 9)
return;
- keyboardEvent->setDefaultHandled();
- setValueAsInteger(m_hasValue && delta < typeAheadTimeout ? m_value * 10 + digit : digit, DispatchEvent);
- if (m_value * 10 > m_range.maximum)
- focusOnNextField();
+ DOMTimeStamp delta = keyboardEvent->timeStamp() - m_lastDigitCharTime;
+ m_lastDigitCharTime = keyboardEvent->timeStamp();
+
+ if (delta > typeAheadTimeout)
+ m_typeAheadBuffer.clear();
+ m_typeAheadBuffer.append(number);
+
+ int newValue = typeAheadValue();
+ if (m_range.isInRange(newValue))
+ setValueAsInteger(newValue, DispatchEvent);
else
- m_lastDigitCharTime = keyboardEvent->timeStamp();
+ updateVisibleValue(DispatchEvent);
+
+ if (m_typeAheadBuffer.length() >= DateTimeNumericFieldElement::formatValue(m_range.maximum).length() || newValue * 10 > m_range.maximum)
+ focusOnNextField();
+
+ keyboardEvent->setDefaultHandled();
}
bool DateTimeNumericFieldElement::hasValue() const
@@ -166,13 +174,12 @@ int DateTimeNumericFieldElement::minimum() const
void DateTimeNumericFieldElement::setEmptyValue(EventBehavior eventBehavior)
{
- m_lastDigitCharTime = 0;
-
if (isReadOnly())
return;
m_hasValue = false;
m_value = 0;
+ m_typeAheadBuffer.clear();
updateVisibleValue(eventBehavior);
}
@@ -181,7 +188,6 @@ void DateTimeNumericFieldElement::setValueAsInteger(int value, EventBehavior eve
m_value = clampValueForHardLimits(value);
m_hasValue = true;
updateVisibleValue(eventBehavior);
- m_lastDigitCharTime = 0;
}
void DateTimeNumericFieldElement::stepDown()
@@ -189,6 +195,7 @@ void DateTimeNumericFieldElement::stepDown()
int newValue = roundDown(m_hasValue ? m_value - 1 : defaultValueForStepDown());
if (!m_range.isInRange(newValue))
newValue = roundDown(m_range.maximum);
+ m_typeAheadBuffer.clear();
setValueAsInteger(newValue, DispatchEvent);
}
@@ -197,6 +204,7 @@ void DateTimeNumericFieldElement::stepUp()
int newValue = roundUp(m_hasValue ? m_value + 1 : defaultValueForStepUp());
if (!m_range.isInRange(newValue))
newValue = roundUp(m_range.minimum);
+ m_typeAheadBuffer.clear();
setValueAsInteger(newValue, DispatchEvent);
}
@@ -210,8 +218,17 @@ int DateTimeNumericFieldElement::valueAsInteger() const
return m_hasValue ? m_value : -1;
}
+int DateTimeNumericFieldElement::typeAheadValue() const
+{
+ if (m_typeAheadBuffer.length())
+ return m_typeAheadBuffer.toString().toInt();
+ return -1;
+}
+
String DateTimeNumericFieldElement::visibleValue() const
{
+ if (m_typeAheadBuffer.length())
+ return formatValue(typeAheadValue());
return m_hasValue ? value() : m_placeholder;
}
diff --git a/third_party/WebKit/Source/WebCore/html/shadow/DateTimeNumericFieldElement.h b/third_party/WebKit/Source/WebCore/html/shadow/DateTimeNumericFieldElement.h
index 317c84c..3d3a33f 100644
--- a/third_party/WebKit/Source/WebCore/html/shadow/DateTimeNumericFieldElement.h
+++ b/third_party/WebKit/Source/WebCore/html/shadow/DateTimeNumericFieldElement.h
@@ -87,6 +87,7 @@ private:
String formatValue(int) const;
int roundUp(int) const;
int roundDown(int) const;
+ int typeAheadValue() const;
DOMTimeStamp m_lastDigitCharTime;
const String m_placeholder;
@@ -95,6 +96,7 @@ private:
bool m_hasValue;
int m_step;
int m_stepBase;
+ mutable StringBuilder m_typeAheadBuffer;
};
} // namespace WebCore