Title: [139720] branches/chromium/1364
Revision
139720
Author
[email protected]
Date
2013-01-14 23:47:40 -0800 (Mon, 14 Jan 2013)

Log Message

Merge 139151

> 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:
> 

[email protected]
Review URL: https://codereview.chromium.org/11884049

Modified Paths

Diff

Modified: branches/chromium/1364/LayoutTests/fast/forms/number/number-validity-badinput-expected.txt (139719 => 139720)


--- branches/chromium/1364/LayoutTests/fast/forms/number/number-validity-badinput-expected.txt	2013-01-15 07:20:13 UTC (rev 139719)
+++ branches/chromium/1364/LayoutTests/fast/forms/number/number-validity-badinput-expected.txt	2013-01-15 07:47:40 UTC (rev 139720)
@@ -26,6 +26,8 @@
 PASS number.value is ""
 The element losts a renderer. The element state should not be changed.
 PASS number.style.display = "none"; number.validity.badInput is true
+A bad input should be cleared by value="".
+PASS number.value = ""; document.execCommand("SelectAll"); document.getSelection().toString() is ""
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: branches/chromium/1364/LayoutTests/fast/forms/number/number-validity-badinput.html (139719 => 139720)


--- branches/chromium/1364/LayoutTests/fast/forms/number/number-validity-badinput.html	2013-01-15 07:20:13 UTC (rev 139719)
+++ branches/chromium/1364/LayoutTests/fast/forms/number/number-validity-badinput.html	2013-01-15 07:47:40 UTC (rev 139720)
@@ -59,6 +59,11 @@
 debug("The element losts a renderer. The element state should not be changed.");
 shouldBeTrue('number.style.display = "none"; number.validity.badInput');
 
+number.style.display = 'inline-block';
+number.focus();
+debug('A bad input should be cleared by value="".');
+shouldBeEqualToString('number.value = ""; document.execCommand("SelectAll"); document.getSelection().toString()', '');
+
 document.getElementById('parent').innerHTML = '';
 </script>
 <script src=""

Modified: branches/chromium/1364/Source/WebCore/html/NumberInputType.cpp (139719 => 139720)


--- branches/chromium/1364/Source/WebCore/html/NumberInputType.cpp	2013-01-15 07:20:13 UTC (rev 139719)
+++ branches/chromium/1364/Source/WebCore/html/NumberInputType.cpp	2013-01-15 07:47:40 UTC (rev 139720)
@@ -106,6 +106,13 @@
     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());

Modified: branches/chromium/1364/Source/WebCore/html/NumberInputType.h (139719 => 139720)


--- branches/chromium/1364/Source/WebCore/html/NumberInputType.h	2013-01-15 07:20:13 UTC (rev 139719)
+++ branches/chromium/1364/Source/WebCore/html/NumberInputType.h	2013-01-15 07:47:40 UTC (rev 139720)
@@ -42,6 +42,7 @@
 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;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to