Title: [97351] trunk
Revision
97351
Author
[email protected]
Date
2011-10-13 00:34:55 -0700 (Thu, 13 Oct 2011)

Log Message

REGRESSION(r89915): <input type=email multiple> don't show the default value
https://bugs.webkit.org/show_bug.cgi?id=69895

Reviewed by Hajime Morita.

Source/WebCore:

m_valueIfDirty became unexpectedly empty because
EmailInputType::sanitizeValue() returned an empty string for a
null input string.

To solve this issue, HTMLInputElement::sanitizeValue() checks
nullness, and remove the null check of sanitizeValue() of
InputType subclasses.
Also, we make InputType::sanitizeValue() const.

* html/ColorInputType.cpp:
(WebCore::ColorInputType::sanitizeValue):
- Make this const.
- Remove null check.
* html/ColorInputType.h: Make sanitizeValue() const.
* html/EmailInputType.cpp:
(WebCore::EmailInputType::sanitizeValue): Make this const.
* html/EmailInputType.h: Make sanitizeValue() const.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::sanitizeValue):
(WebCore::HTMLInputElement::updateValueIfNeeded):
* html/InputType.cpp:
(WebCore::InputType::sanitizeValue):
Returns a null string if the input string is null, and
don't call InputType::sanitizeValue() in this case.
* html/InputType.h: Make sanitizeValue() const.
* html/NumberInputType.cpp:
(WebCore::NumberInputType::sanitizeValue): Make this const.
* html/NumberInputType.h: Make sanitizeValue() const.
* html/RangeInputType.cpp:
(WebCore::RangeInputType::sanitizeValue):
- Make this const.
- Remove null check.
* html/RangeInputType.h: Make sanitizeValue() const.
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::sanitizeValue): Make this const.
* html/TextFieldInputType.h: Make sanitizeValue() const.

LayoutTests:

* fast/forms/input-value-sanitization-expected.txt:
* fast/forms/input-value-sanitization.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (97350 => 97351)


--- trunk/LayoutTests/ChangeLog	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/LayoutTests/ChangeLog	2011-10-13 07:34:55 UTC (rev 97351)
@@ -1,3 +1,13 @@
+2011-10-13  Kent Tamura  <[email protected]>
+
+        REGRESSION(r89915): <input type=email multiple> don't show the default value
+        https://bugs.webkit.org/show_bug.cgi?id=69895
+
+        Reviewed by Hajime Morita.
+
+        * fast/forms/input-value-sanitization-expected.txt:
+        * fast/forms/input-value-sanitization.html:
+
 2011-10-13  Csaba Osztrogonác  <[email protected]>
 
         [Qt] Unreviewed gardening.

Modified: trunk/LayoutTests/fast/forms/input-value-sanitization-expected.txt (97350 => 97351)


--- trunk/LayoutTests/fast/forms/input-value-sanitization-expected.txt	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/LayoutTests/fast/forms/input-value-sanitization-expected.txt	2011-10-13 07:34:55 UTC (rev 97351)
@@ -1,6 +1,11 @@
 Tests for value sanitization algorithm.
 
 
+Email with multiple:
+PASS input.value is "[email protected],tkent@example.!!!"
+Email without multiple:
+PASS input.value is " [email protected], tkent@example.***  "
+
 Number:
 PASS input.value is "65536"
 PASS input.value = "256"; input.value is "256"

Modified: trunk/LayoutTests/fast/forms/input-value-sanitization.html (97350 => 97351)


--- trunk/LayoutTests/fast/forms/input-value-sanitization.html	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/LayoutTests/fast/forms/input-value-sanitization.html	2011-10-13 07:34:55 UTC (rev 97351)
@@ -11,6 +11,20 @@
 var input;
 
 debug('');
+debug('Email with multiple:');
+input = document.createElement('input');
+input.multiple = true;
+input.type = 'email';
+input.setAttribute('value', ' [email protected], tkent@example.!!!  ');
+shouldBe('input.value', '"[email protected],tkent@example.!!!"');
+debug('Email without multiple:');
+input = document.createElement('input');
+input.multiple = false;
+input.type = 'email';
+input.setAttribute('value', ' [email protected], tkent@example.***  \r\n');
+shouldBe('input.value', '" [email protected], tkent@example.***  "');
+
+debug('');
 debug('Number:');
 input = document.createElement('input');
 input.setAttribute('value', '65536');

Modified: trunk/Source/WebCore/ChangeLog (97350 => 97351)


--- trunk/Source/WebCore/ChangeLog	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/ChangeLog	2011-10-13 07:34:55 UTC (rev 97351)
@@ -1,3 +1,47 @@
+2011-10-13  Kent Tamura  <[email protected]>
+
+        REGRESSION(r89915): <input type=email multiple> don't show the default value
+        https://bugs.webkit.org/show_bug.cgi?id=69895
+
+        Reviewed by Hajime Morita.
+
+        m_valueIfDirty became unexpectedly empty because
+        EmailInputType::sanitizeValue() returned an empty string for a
+        null input string.
+
+        To solve this issue, HTMLInputElement::sanitizeValue() checks
+        nullness, and remove the null check of sanitizeValue() of
+        InputType subclasses.
+        Also, we make InputType::sanitizeValue() const.
+
+        * html/ColorInputType.cpp:
+        (WebCore::ColorInputType::sanitizeValue):
+        - Make this const.
+        - Remove null check.
+        * html/ColorInputType.h: Make sanitizeValue() const.
+        * html/EmailInputType.cpp:
+        (WebCore::EmailInputType::sanitizeValue): Make this const.
+        * html/EmailInputType.h: Make sanitizeValue() const.
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::sanitizeValue):
+        (WebCore::HTMLInputElement::updateValueIfNeeded):
+        * html/InputType.cpp:
+        (WebCore::InputType::sanitizeValue):
+        Returns a null string if the input string is null, and
+        don't call InputType::sanitizeValue() in this case.
+        * html/InputType.h: Make sanitizeValue() const.
+        * html/NumberInputType.cpp:
+        (WebCore::NumberInputType::sanitizeValue): Make this const.
+        * html/NumberInputType.h: Make sanitizeValue() const.
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::sanitizeValue):
+        - Make this const.
+        - Remove null check.
+        * html/RangeInputType.h: Make sanitizeValue() const.
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::sanitizeValue): Make this const.
+        * html/TextFieldInputType.h: Make sanitizeValue() const.
+
 2011-10-12  Joseph Pecoraro  <[email protected]>
 
         Pass Parsed Accept Attribute MIME Types to WebKit Clients

Modified: trunk/Source/WebCore/html/ColorInputType.cpp (97350 => 97351)


--- trunk/Source/WebCore/html/ColorInputType.cpp	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/ColorInputType.cpp	2011-10-13 07:34:55 UTC (rev 97351)
@@ -89,11 +89,8 @@
     return String("#000000");
 }
 
-String ColorInputType::sanitizeValue(const String& proposedValue)
+String ColorInputType::sanitizeValue(const String& proposedValue) const
 {
-    if (proposedValue.isNull())
-        return proposedValue;
-
     if (!isValidColorString(proposedValue))
         return fallbackValue();
 

Modified: trunk/Source/WebCore/html/ColorInputType.h (97350 => 97351)


--- trunk/Source/WebCore/html/ColorInputType.h	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/ColorInputType.h	2011-10-13 07:34:55 UTC (rev 97351)
@@ -49,7 +49,7 @@
     virtual const AtomicString& formControlType() const;
     virtual bool supportsRequired() const;
     virtual String fallbackValue();
-    virtual String sanitizeValue(const String&);
+    virtual String sanitizeValue(const String&) const;
     virtual Color valueAsColor() const;
     virtual void createShadowSubtree();
     virtual void setValue(const String&, bool valueChanged, bool sendChangeEvent);

Modified: trunk/Source/WebCore/html/EmailInputType.cpp (97350 => 97351)


--- trunk/Source/WebCore/html/EmailInputType.cpp	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/EmailInputType.cpp	2011-10-13 07:34:55 UTC (rev 97351)
@@ -92,7 +92,7 @@
     return true;
 }
 
-String EmailInputType::sanitizeValue(const String& proposedValue)
+String EmailInputType::sanitizeValue(const String& proposedValue) const
 {
     String noLineBreakValue = proposedValue.removeCharacters(isHTMLLineBreak);
     if (!element()->multiple())

Modified: trunk/Source/WebCore/html/EmailInputType.h (97350 => 97351)


--- trunk/Source/WebCore/html/EmailInputType.h	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/EmailInputType.h	2011-10-13 07:34:55 UTC (rev 97351)
@@ -46,7 +46,7 @@
     virtual bool typeMismatch() const;
     virtual String typeMismatchText() const;
     virtual bool isEmailField() const;
-    virtual String sanitizeValue(const String&);
+    virtual String sanitizeValue(const String&) const;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (97350 => 97351)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2011-10-13 07:34:55 UTC (rev 97351)
@@ -1405,6 +1405,8 @@
 
 String HTMLInputElement::sanitizeValue(const String& proposedValue) const
 {
+    if (proposedValue.isNull())
+        return proposedValue;
     return m_inputType->sanitizeValue(proposedValue);
 }
 
@@ -1800,6 +1802,7 @@
 void HTMLInputElement::updateValueIfNeeded()
 {
     String newValue = sanitizeValue(m_valueIfDirty);
+    ASSERT(!m_valueIfDirty.isNull() || newValue.isNull());
     if (newValue != m_valueIfDirty)
         setValue(newValue);
 }

Modified: trunk/Source/WebCore/html/InputType.cpp (97350 => 97351)


--- trunk/Source/WebCore/html/InputType.cpp	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/InputType.cpp	2011-10-13 07:34:55 UTC (rev 97351)
@@ -573,7 +573,7 @@
     return true;
 }
 
-String InputType::sanitizeValue(const String& proposedValue)
+String InputType::sanitizeValue(const String& proposedValue) const
 {
     return proposedValue;
 }

Modified: trunk/Source/WebCore/html/InputType.h (97350 => 97351)


--- trunk/Source/WebCore/html/InputType.h	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/InputType.h	2011-10-13 07:34:55 UTC (rev 97351)
@@ -161,7 +161,8 @@
     virtual String convertFromVisibleValue(const String&) const;
     virtual bool isAcceptableValue(const String&);
     // Returing the null string means "use the default value."
-    virtual String sanitizeValue(const String&);
+    // This function must be called only by HTMLInputElement::sanitizeValue().
+    virtual String sanitizeValue(const String&) const;
     virtual bool hasUnacceptableValue();
 
     // Event handlers

Modified: trunk/Source/WebCore/html/NumberInputType.cpp (97350 => 97351)


--- trunk/Source/WebCore/html/NumberInputType.cpp	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/NumberInputType.cpp	2011-10-13 07:34:55 UTC (rev 97351)
@@ -308,7 +308,7 @@
     return proposedValue.isEmpty() || isfinite(parseLocalizedNumber(proposedValue)) || parseToDoubleForNumberType(proposedValue, 0);
 }
 
-String NumberInputType::sanitizeValue(const String& proposedValue)
+String NumberInputType::sanitizeValue(const String& proposedValue) const
 {
     if (proposedValue.isEmpty())
         return proposedValue;

Modified: trunk/Source/WebCore/html/NumberInputType.h (97350 => 97351)


--- trunk/Source/WebCore/html/NumberInputType.h	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/NumberInputType.h	2011-10-13 07:34:55 UTC (rev 97351)
@@ -68,7 +68,7 @@
     virtual String visibleValue() const;
     virtual String convertFromVisibleValue(const String&) const;
     virtual bool isAcceptableValue(const String&);
-    virtual String sanitizeValue(const String&);
+    virtual String sanitizeValue(const String&) const;
     virtual bool hasUnacceptableValue();
     virtual bool shouldRespectSpeechAttribute();
     virtual bool supportsPlaceholder() const;

Modified: trunk/Source/WebCore/html/RangeInputType.cpp (97350 => 97351)


--- trunk/Source/WebCore/html/RangeInputType.cpp	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/RangeInputType.cpp	2011-10-13 07:34:55 UTC (rev 97351)
@@ -300,14 +300,8 @@
     return serializeForNumberType(StepRange(element()).defaultValue());
 }
 
-String RangeInputType::sanitizeValue(const String& proposedValue)
+String RangeInputType::sanitizeValue(const String& proposedValue) const
 {
-    // If the proposedValue is null than this is a reset scenario and we
-    // want the range input's value attribute to take priority over the
-    // calculated default (middle) value.
-    if (proposedValue.isNull())
-        return proposedValue;
-
     return serializeForNumberType(StepRange(element()).clampValue(proposedValue));
 }
 

Modified: trunk/Source/WebCore/html/RangeInputType.h (97350 => 97351)


--- trunk/Source/WebCore/html/RangeInputType.h	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/RangeInputType.h	2011-10-13 07:34:55 UTC (rev 97351)
@@ -68,7 +68,7 @@
     virtual void minOrMaxAttributeChanged();
     virtual void setValue(const String&, bool valueChanged, bool sendChangeEvent);
     virtual String fallbackValue();
-    virtual String sanitizeValue(const String& proposedValue);
+    virtual String sanitizeValue(const String& proposedValue) const;
     virtual bool shouldRespectListAttribute();
 };
 

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (97350 => 97351)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2011-10-13 07:34:55 UTC (rev 97351)
@@ -299,7 +299,7 @@
     return string.left(newLength);
 }
 
-String TextFieldInputType::sanitizeValue(const String& proposedValue)
+String TextFieldInputType::sanitizeValue(const String& proposedValue) const
 {
     return limitLength(proposedValue.removeCharacters(isASCIILineBreak), HTMLInputElement::maximumLength);
 }

Modified: trunk/Source/WebCore/html/TextFieldInputType.h (97350 => 97351)


--- trunk/Source/WebCore/html/TextFieldInputType.h	2011-10-13 07:32:31 UTC (rev 97350)
+++ trunk/Source/WebCore/html/TextFieldInputType.h	2011-10-13 07:34:55 UTC (rev 97351)
@@ -73,7 +73,7 @@
     virtual bool shouldUseInputMethod() const;
     virtual void setValue(const String&, bool valueChanged, bool sendChangeEvent);
     virtual void dispatchChangeEventInResponseToSetValue();
-    virtual String sanitizeValue(const String&);
+    virtual String sanitizeValue(const String&) const;
     virtual bool shouldRespectListAttribute();
     virtual HTMLElement* placeholderElement() const;
     virtual void updatePlaceholderText();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to