[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

tkent at chromium.org tkent at chromium.org
Thu Feb 4 21:30:42 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit e9d74445e454c3014942954b683d30565f4093fb
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 28 07:29:39 2010 +0000

    2010-01-27  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            rangeOverflow/rangeUnderflow support for type=date
            https://bugs.webkit.org/show_bug.cgi?id=34209
    
            * fast/forms/ValidityState-rangeOverflow-date-expected.txt: Added.
            * fast/forms/ValidityState-rangeOverflow-date.html: Added.
            * fast/forms/ValidityState-rangeUnderflow-date-expected.txt: Added.
            * fast/forms/ValidityState-rangeUnderflow-date.html: Added.
            * fast/forms/script-tests/ValidityState-rangeOverflow-date.js: Added.
            * fast/forms/script-tests/ValidityState-rangeUnderflow-date.js: Added.
    
    2010-01-27  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            rangeOverflow/rangeUnderflow support for type=date
            https://bugs.webkit.org/show_bug.cgi?id=34209
    
            Add DATE type support to rangeUnderflow(), rangeOverflow(),
            minimum(), and maximum() of HTMLInputElement.
            In order to unify parsing code for value, min, and max strings,
            introduce parseToDouble() function and it is called by
            valueAsDate() and valueAsNumber() too.
    
            Tests: fast/forms/ValidityState-rangeOverflow-date.html
                   fast/forms/ValidityState-rangeUnderflow-date.html
    
            * html/HTMLInputElement.cpp:
            (WebCore::HTMLInputElement::rangeUnderflow): Support DATE type, and use parseToDouble().
            (WebCore::HTMLInputElement::rangeOverflow): ditto.
            (WebCore::HTMLInputElement::minimum): ditto.
            (WebCore::HTMLInputElement::maximum): ditto.
            (WebCore::HTMLInputElement::doubleValueFor): Added.
            (WebCore::HTMLInputElement::valueAsDate): Use parseToDouble().
            (WebCore::HTMLInputElement::valueAsNumber): Use parseToDouble().
            * html/HTMLInputElement.h: Declare parseToDouble().
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53975 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 9676510..91d794f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-01-27  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        rangeOverflow/rangeUnderflow support for type=date
+        https://bugs.webkit.org/show_bug.cgi?id=34209
+
+        * fast/forms/ValidityState-rangeOverflow-date-expected.txt: Added.
+        * fast/forms/ValidityState-rangeOverflow-date.html: Added.
+        * fast/forms/ValidityState-rangeUnderflow-date-expected.txt: Added.
+        * fast/forms/ValidityState-rangeUnderflow-date.html: Added.
+        * fast/forms/script-tests/ValidityState-rangeOverflow-date.js: Added.
+        * fast/forms/script-tests/ValidityState-rangeUnderflow-date.js: Added.
+
 2010-01-27  Csaba Osztrogonác  <ossy at webkit.org>
 
         [Qt] Skip test introduced in r53972 because of missing eventSender.beginDragWithFiles()
diff --git a/LayoutTests/fast/forms/ValidityState-rangeOverflow-date-expected.txt b/LayoutTests/fast/forms/ValidityState-rangeOverflow-date-expected.txt
new file mode 100644
index 0000000..3f0f802
--- /dev/null
+++ b/LayoutTests/fast/forms/ValidityState-rangeOverflow-date-expected.txt
@@ -0,0 +1,20 @@
+This test aims to check for rangeOverflow flag with type=date input fields
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The value "2010-01-27" doesn't overflow the maximum value "".
+PASS The value "2010-01-27" doesn't overflow the maximum value "".
+PASS The value "2010-01-27" doesn't overflow the maximum value "foo".
+PASS The value "2010-01-27" doesn't overflow the maximum value "2010-01-27".
+PASS The value "2010-01-27" doesn't overflow the maximum value "2010-01-28".
+PASS The value "2010-01-27" doesn't overflow the maximum value "2011-01-26".
+PASS The value "foo" doesn't overflow the maximum value "2011-01-26".
+PASS The value "2010-01-27" doesn't overflow the maximum value "1000-01-01".
+PASS The value "2010-01-27" overflows the maximum value "2010-01-26".
+PASS The value "9999-01-01" overflows the maximum value "2010-12-31".
+PASS The value "2010-01-27" overflows the maximum value "2010-01-26".
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/ValidityState-rangeOverflow-date.html b/LayoutTests/fast/forms/ValidityState-rangeOverflow-date.html
new file mode 100644
index 0000000..3fb9e35
--- /dev/null
+++ b/LayoutTests/fast/forms/ValidityState-rangeOverflow-date.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/ValidityState-rangeOverflow-date.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/ValidityState-rangeUnderflow-date-expected.txt b/LayoutTests/fast/forms/ValidityState-rangeUnderflow-date-expected.txt
new file mode 100644
index 0000000..d427ca9
--- /dev/null
+++ b/LayoutTests/fast/forms/ValidityState-rangeUnderflow-date-expected.txt
@@ -0,0 +1,20 @@
+This test aims to check for rangeUnderflow flag with type=date input fields
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The value "2010-01-27" doesn't underflow the minimum value "".
+PASS The value "2010-01-27" doesn't underflow the minimum value "".
+PASS The value "2010-01-27" doesn't underflow the minimum value "foo".
+PASS The value "1000-01-01" doesn't underflow the minimum value "".
+PASS The value "1582-10-15" doesn't underflow the minimum value "".
+PASS The value "2010-01-27" doesn't underflow the minimum value "2010-01-26".
+PASS The value "2010-01-27" doesn't underflow the minimum value "2009-01-28".
+PASS The value "foo" doesn't underflow the minimum value "2011-01-26".
+PASS The value "2010-01-27" undeflows the minimum value "2010-01-28".
+PASS The value "9999-01-01" undeflows the minimum value "10000-12-31".
+PASS The value "2010-01-27" undeflows the minimum value "2010-02-01".
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/ValidityState-rangeUnderflow-date.html b/LayoutTests/fast/forms/ValidityState-rangeUnderflow-date.html
new file mode 100644
index 0000000..3b90cb2
--- /dev/null
+++ b/LayoutTests/fast/forms/ValidityState-rangeUnderflow-date.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/ValidityState-rangeUnderflow-date.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-rangeOverflow-date.js b/LayoutTests/fast/forms/script-tests/ValidityState-rangeOverflow-date.js
new file mode 100644
index 0000000..efd46f1
--- /dev/null
+++ b/LayoutTests/fast/forms/script-tests/ValidityState-rangeOverflow-date.js
@@ -0,0 +1,50 @@
+description('This test aims to check for rangeOverflow flag with type=date input fields');
+
+var input = document.createElement('input');
+input.type = 'date';
+
+function checkOverflow(value, max)
+{
+    input.value = value;
+    input.max = max;
+    var overflow = input.validity.rangeOverflow;
+    var resultText = 'The value "' + input.value + '" ' +
+        (overflow ? 'overflows' : 'doesn\'t overflow') +
+        ' the maximum value "' + input.max + '".';
+    if (overflow)
+        testPassed(resultText);
+    else
+        testFailed(resultText);
+}
+
+function checkNotOverflow(value, max)
+{
+    input.value = value;
+    input.max = max;
+    var overflow = input.validity.rangeOverflow;
+    var resultText = 'The value "' + input.value + '" ' +
+        (overflow ? 'overflows' : 'doesn\'t overflow') +
+        ' the maximum value "' + input.max + '".';
+    if (overflow)
+        testFailed(resultText);
+    else
+        testPassed(resultText);
+}
+
+// No overflow cases
+checkNotOverflow('2010-01-27', null);
+checkNotOverflow('2010-01-27', '');
+checkNotOverflow('2010-01-27', 'foo');
+checkNotOverflow('2010-01-27', '2010-01-27');
+checkNotOverflow('2010-01-27', '2010-01-28');
+checkNotOverflow('2010-01-27', '2011-01-26');
+checkNotOverflow('foo', '2011-01-26');
+checkNotOverflow('2010-01-27', '1000-01-01'); // Too small max value.
+
+// Overflow cases
+checkOverflow('2010-01-27', '2010-01-26');
+checkOverflow('9999-01-01', '2010-12-31');
+input.min = '2010-01-28';  // value < min && value > max
+checkOverflow('2010-01-27', '2010-01-26');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/forms/script-tests/ValidityState-rangeUnderflow-date.js b/LayoutTests/fast/forms/script-tests/ValidityState-rangeUnderflow-date.js
new file mode 100644
index 0000000..06344d8
--- /dev/null
+++ b/LayoutTests/fast/forms/script-tests/ValidityState-rangeUnderflow-date.js
@@ -0,0 +1,52 @@
+description('This test aims to check for rangeUnderflow flag with type=date input fields');
+
+var input = document.createElement('input');
+input.type = 'date';
+
+function checkUnderflow(value, min)
+{
+    input.value = value;
+    input.min = min;
+    var underflow = input.validity.rangeUnderflow;
+    var resultText = 'The value "' + input.value + '" ' +
+        (underflow ? 'undeflows' : 'doesn\'t underflow') +
+        ' the minimum value "' + input.min + '".';
+    if (underflow)
+        testPassed(resultText);
+    else
+        testFailed(resultText);
+}
+
+function checkNotUnderflow(value, min)
+{
+    input.value = value;
+    input.min = min;
+    var underflow = input.validity.rangeUnderflow;
+    var resultText = 'The value "' + input.value + '" ' +
+        (underflow ? 'underflows' : 'doesn\'t underflow') +
+        ' the minimum value "' + input.min + '".';
+    if (underflow)
+        testFailed(resultText);
+    else
+        testPassed(resultText);
+}
+
+// No underflow cases
+checkNotUnderflow('2010-01-27', null);
+checkNotUnderflow('2010-01-27', '');
+checkNotUnderflow('2010-01-27', 'foo');
+// 1000-01-01 is smaller than the implicit minimum value.
+// But the date parser rejects it before comparing the minimum value.
+checkNotUnderflow('1000-01-01', '');
+checkNotUnderflow('1582-10-15', '');
+checkNotUnderflow('2010-01-27', '2010-01-26');
+checkNotUnderflow('2010-01-27', '2009-01-28');
+checkNotUnderflow('foo', '2011-01-26');
+
+// Underflow cases
+checkUnderflow('2010-01-27', '2010-01-28');
+checkUnderflow('9999-01-01', '10000-12-31');
+input.max = '2010-01-01';  // value < min && value > max
+checkUnderflow('2010-01-27', '2010-02-01');
+
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ab314cd..b36e94a 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-01-27  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        rangeOverflow/rangeUnderflow support for type=date
+        https://bugs.webkit.org/show_bug.cgi?id=34209
+
+        Add DATE type support to rangeUnderflow(), rangeOverflow(),
+        minimum(), and maximum() of HTMLInputElement.
+        In order to unify parsing code for value, min, and max strings,
+        introduce parseToDouble() function and it is called by
+        valueAsDate() and valueAsNumber() too.
+
+        Tests: fast/forms/ValidityState-rangeOverflow-date.html
+               fast/forms/ValidityState-rangeUnderflow-date.html
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::rangeUnderflow): Support DATE type, and use parseToDouble().
+        (WebCore::HTMLInputElement::rangeOverflow): ditto.
+        (WebCore::HTMLInputElement::minimum): ditto.
+        (WebCore::HTMLInputElement::maximum): ditto.
+        (WebCore::HTMLInputElement::doubleValueFor): Added.
+        (WebCore::HTMLInputElement::valueAsDate): Use parseToDouble().
+        (WebCore::HTMLInputElement::valueAsNumber): Use parseToDouble().
+        * html/HTMLInputElement.h: Declare parseToDouble().
+
 2010-01-27  Darin Fisher  <darin at chromium.org>
 
         Fix chromium build bustage (take 2).
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index 0d689cb..52a75be 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -79,9 +79,11 @@ const int maxSavedResults = 256;
 static const double numberDefaultStep = 1.0;
 static const double numberStepScaleFactor = 1.0;
 // Constant values for minimum().
+static const double dateDefaultMinimum = -12219292800000.0; // This means 1582-10-15T00:00Z.
 static const double numberDefaultMinimum = -DBL_MAX;
 static const double rangeDefaultMinimum = 0.0;
 // Constant values for maximum().
+static const double dateDefaultMaximum = DBL_MAX;
 static const double numberDefaultMaximum = DBL_MAX;
 static const double rangeDefaultMaximum = 100.0;
 
@@ -266,46 +268,153 @@ bool HTMLInputElement::tooLong() const
 
 bool HTMLInputElement::rangeUnderflow() const
 {
-    if (inputType() == NUMBER || inputType() == RANGE) {
-        double doubleValue;
-        if (formStringToDouble(value(), &doubleValue))
-            return doubleValue < minimum();
+    const double nan = numeric_limits<double>::quiet_NaN();
+    switch (inputType()) {
+    case DATE:
+    case NUMBER:
+    case RANGE: {
+        double doubleValue = parseToDouble(value(), nan);
+        return isfinite(doubleValue) && doubleValue < minimum();
+    }
+    case BUTTON:
+    case CHECKBOX:
+    case COLOR:
+    case DATETIME:
+    case DATETIMELOCAL:
+    case EMAIL:
+    case FILE:
+    case HIDDEN:
+    case IMAGE:
+    case ISINDEX:
+    case MONTH:
+    case PASSWORD:
+    case RADIO:
+    case RESET:
+    case SEARCH:
+    case SUBMIT:
+    case TELEPHONE:
+    case TEXT:
+    case TIME:
+    case URL:
+    case WEEK:
+        break;
     }
     return false;
 }
 
 bool HTMLInputElement::rangeOverflow() const
 {
-    if (inputType() == NUMBER || inputType() == RANGE) {
-        double doubleValue;
-        if (formStringToDouble(value(), &doubleValue))
-            return doubleValue > maximum();
+    const double nan = numeric_limits<double>::quiet_NaN();
+    switch (inputType()) {
+    case DATE:
+    case NUMBER:
+    case RANGE: {
+        double doubleValue = parseToDouble(value(), nan);
+        return isfinite(doubleValue) && doubleValue >  maximum();
+    }
+    case BUTTON:
+    case CHECKBOX:
+    case COLOR:
+    case DATETIME:
+    case DATETIMELOCAL:
+    case EMAIL:
+    case FILE:
+    case HIDDEN:
+    case IMAGE:
+    case ISINDEX:
+    case MONTH:
+    case PASSWORD:
+    case RADIO:
+    case RESET:
+    case SEARCH:
+    case SUBMIT:
+    case TELEPHONE:
+    case TEXT:
+    case TIME:
+    case URL:
+    case WEEK:
+        break;
     }
     return false;
 }
 
 double HTMLInputElement::minimum() const
 {
-    ASSERT(inputType() == NUMBER || inputType() == RANGE);
-    double min = inputType() == RANGE ? rangeDefaultMinimum : numberDefaultMinimum;
-    formStringToDouble(getAttribute(minAttr), &min);
-    return min;
+    switch (inputType()) {
+    case DATE:
+        return parseToDouble(getAttribute(minAttr), dateDefaultMinimum);
+    case NUMBER:
+        return parseToDouble(getAttribute(minAttr), numberDefaultMinimum);
+    case RANGE:
+        return parseToDouble(getAttribute(minAttr), rangeDefaultMinimum);
+    case BUTTON:
+    case CHECKBOX:
+    case COLOR:
+    case DATETIME:
+    case DATETIMELOCAL:
+    case EMAIL:
+    case FILE:
+    case HIDDEN:
+    case IMAGE:
+    case ISINDEX:
+    case MONTH:
+    case PASSWORD:
+    case RADIO:
+    case RESET:
+    case SEARCH:
+    case SUBMIT:
+    case TELEPHONE:
+    case TEXT:
+    case TIME:
+    case URL:
+    case WEEK:
+        break;
+    }
+    ASSERT_NOT_REACHED();
+    return 0;
 }
 
 double HTMLInputElement::maximum() const
 {
-    ASSERT(inputType() == NUMBER || inputType() == RANGE);
-    double defaultMaximum = inputType() == RANGE ? rangeDefaultMaximum : numberDefaultMaximum;
-    double max = defaultMaximum;
-    formStringToDouble(getAttribute(maxAttr), &max);
-    if (inputType() == RANGE) {
+    switch (inputType()) {
+    case DATE:
+        return parseToDouble(getAttribute(maxAttr), dateDefaultMaximum);
+    case NUMBER:
+        return parseToDouble(getAttribute(maxAttr), numberDefaultMaximum);
+    case RANGE: {
+        double max = parseToDouble(getAttribute(maxAttr), rangeDefaultMaximum);
         // A remedy for the inconsistent min/max values for RANGE.
         // Sets the maximum to the default or the minimum value.
         double min = minimum();
         if (max < min)
-            max = std::max(min, defaultMaximum);
+            max = std::max(min, rangeDefaultMaximum);
+        return max;
+    }
+    case BUTTON:
+    case CHECKBOX:
+    case COLOR:
+    case DATETIME:
+    case DATETIMELOCAL:
+    case EMAIL:
+    case FILE:
+    case HIDDEN:
+    case IMAGE:
+    case ISINDEX:
+    case MONTH:
+    case PASSWORD:
+    case RADIO:
+    case RESET:
+    case SEARCH:
+    case SUBMIT:
+    case TELEPHONE:
+    case TEXT:
+    case TIME:
+    case URL:
+    case WEEK:
+        break;
     }
-    return max;
+    ASSERT_NOT_REACHED();
+    return 0;
 }
 
 double HTMLInputElement::stepBase() const
@@ -1374,19 +1483,63 @@ void HTMLInputElement::setValue(const String& value, bool sendChangeEvent)
     updateValidity();
 }
 
-double HTMLInputElement::valueAsDate() const
+double HTMLInputElement::parseToDouble(const String& src, double defaultValue) const
 {
     switch (inputType()) {
     case DATE:
     case DATETIME:
+    case DATETIMELOCAL:
     case MONTH:
     case TIME:
     case WEEK: {
         ISODateTime dateTime;
-        if (!formStringToISODateTime(inputType(), value(), &dateTime))
-            return ISODateTime::invalidMilliseconds();
-        return dateTime.millisecondsSinceEpoch();
+        if (!formStringToISODateTime(inputType(), src, &dateTime))
+            return defaultValue;
+        double msec = dateTime.millisecondsSinceEpoch();
+        ASSERT(isfinite(msec));
+        return msec;
+    }
+    case NUMBER:
+    case RANGE: {
+        double numberValue;
+        if (!formStringToDouble(src, &numberValue))
+            return defaultValue;
+        ASSERT(isfinite(numberValue));
+        return numberValue;
     }
+
+    case BUTTON:
+    case CHECKBOX:
+    case COLOR:
+    case EMAIL:
+    case FILE:
+    case HIDDEN:
+    case IMAGE:
+    case ISINDEX:
+    case PASSWORD:
+    case RADIO:
+    case RESET:
+    case SEARCH:
+    case SUBMIT:
+    case TELEPHONE:
+    case TEXT:
+    case URL:
+        return defaultValue;
+    }
+    ASSERT_NOT_REACHED();
+    return defaultValue;
+}
+
+double HTMLInputElement::valueAsDate() const
+{
+    switch (inputType()) {
+    case DATE:
+    case DATETIME:
+    case MONTH:
+    case TIME:
+    case WEEK:
+        return parseToDouble(value(), ISODateTime::invalidMilliseconds());
+
     case BUTTON:
     case CHECKBOX:
     case COLOR:
@@ -1475,20 +1628,11 @@ double HTMLInputElement::valueAsNumber() const
     case DATETIME:
     case DATETIMELOCAL:
     case MONTH:
-    case TIME:
-    case WEEK: {
-        ISODateTime dateTime;
-        if (!formStringToISODateTime(inputType(), value(), &dateTime))
-            return nan;
-        return dateTime.millisecondsSinceEpoch();
-    }
     case NUMBER:
-    case RANGE: {
-        double numberValue;
-        if (!formStringToDouble(value(), &numberValue))
-            return nan;
-        return numberValue;
-    }
+    case RANGE:
+    case TIME:
+    case WEEK:
+        return parseToDouble(value(), nan);
 
     case BUTTON:
     case CHECKBOX:
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index 2cd08c9..8e20e75 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -106,9 +106,9 @@ public:
     // For ValidityState
     bool rangeUnderflow() const;
     bool rangeOverflow() const;
-    // Returns the minimum value for type=number or range.  Don't call this for other types.
+    // Returns the minimum value for type=date, number, or range.  Don't call this for other types.
     double minimum() const;
-    // Returns the maximum value for type=number or range.  Don't call this for other types.
+    // Returns the maximum value for type=date, number, or range.  Don't call this for other types.
     // This always returns a value which is >= minimum().
     double maximum() const;
     // Sets the "allowed value step" defined in the HTML spec to the specified double pointer.
@@ -300,6 +300,12 @@ private:
     // Helper for applyStepForNumberOrRange().
     double stepBase() const;
 
+    // Parses the specified string for the current type, and return
+    // the double value for the parsing result if the parsing
+    // succeeds; Returns defaultValue otherwise. This function can
+    // return NaN or Infinity only if defaultValue is NaN or Infinity.
+    double parseToDouble(const String&, double defaultValue) const;
+
 #if ENABLE(DATALIST)
     HTMLDataListElement* dataList() const;
 #endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list