summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/html
diff options
context:
space:
mode:
authorKent Tamura <tkent@chromium.org>2013-04-08 10:38:11 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-08 21:04:58 +0200
commit7e9bbda3e9bfbe90ca0b017ec1f8b1b1efd746c4 (patch)
treed7ab11dac85d069cce95adcf14ff1af11e017cc5 /Source/WebCore/html
parenta878703f1652ba6e541b81cb19d5a7d3e842aadc (diff)
REGRESSION(r135836): Invalid user input for input[type=number] should be cleared by input.value=""
https://bugs.webkit.org/show_bug.cgi?id=106284 Reviewed by Hajime Morita. Source/WebCore: No new tests. Updates fast/forms/number/number/validity-badinput.html. * html/NumberInputType.cpp: (WebCore::NumberInputType::setValue): If the new sanitized value is empty and innerTextValue is a bad input (it means !valueChanged && !innerTextValue().isEmpty() because the new sanitized value is empty), we need to update innerTextValue with the empty string. * html/NumberInputType.h: (NumberInputType): Declare setValue. LayoutTests: * fast/forms/number/number-validity-badinput.html: Add a test case. * fast/forms/number/number-validity-badinput-expected.txt: Change-Id: Id878a7107578da2e88bcc344d61e1193a3fee9e6 git-svn-id: http://svn.webkit.org/repository/webkit/trunk@139151 268f45cc-cd09-0410-ab3c-d52691b4dbfc Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'Source/WebCore/html')
-rw-r--r--Source/WebCore/html/NumberInputType.cpp7
-rw-r--r--Source/WebCore/html/NumberInputType.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/Source/WebCore/html/NumberInputType.cpp b/Source/WebCore/html/NumberInputType.cpp
index 440ee7b9b..d52275c5f 100644
--- a/Source/WebCore/html/NumberInputType.cpp
+++ b/Source/WebCore/html/NumberInputType.cpp
@@ -106,6 +106,13 @@ const AtomicString& NumberInputType::formControlType() const
return InputTypeNames::number();
}
+void NumberInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior)
+{
+ if (!valueChanged && sanitizedValue.isEmpty() && !element()->innerTextValue().isEmpty())
+ updateInnerTextValue();
+ TextFieldInputType::setValue(sanitizedValue, valueChanged, eventBehavior);
+}
+
double NumberInputType::valueAsDouble() const
{
return parseToDoubleForNumberType(element()->value());
diff --git a/Source/WebCore/html/NumberInputType.h b/Source/WebCore/html/NumberInputType.h
index c77a9a78e..1efcdc13c 100644
--- a/Source/WebCore/html/NumberInputType.h
+++ b/Source/WebCore/html/NumberInputType.h
@@ -42,6 +42,7 @@ public:
private:
NumberInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
virtual const AtomicString& formControlType() const OVERRIDE;
+ virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE;
virtual double valueAsDouble() const OVERRIDE;
virtual void setValueAsDouble(double, TextFieldEventBehavior, ExceptionCode&) const OVERRIDE;
virtual void setValueAsDecimal(const Decimal&, TextFieldEventBehavior, ExceptionCode&) const OVERRIDE;