[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:21:48 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 71d0af4985f00b063d034cf25d6db19f9b9a42ef
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 20 17:38:36 2010 +0000

    2010-01-20  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            HTMLInputElement::valueAsDate setter support for type=time.
            https://bugs.webkit.org/show_bug.cgi?id=33825
    
            Add setter tests to input-valueasdate-time.js, and update the
            expectation.
    
            Note: the expectation file contains some FAIL lines. They are
            intentional because they test a unimplemented feature.
    
            * fast/forms/input-valueasdate-time-expected.txt:
            * fast/forms/script-tests/input-valueasdate-time.js:
    
    2010-01-20  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            HTMLInputElement::valueAsDate setter support for type=time.
            https://bugs.webkit.org/show_bug.cgi?id=33825
    
            Introduce ISODateTime::setMillisecondsSinceMidnight() and add a
            SecondFormat parameter to ISODateTime::toString(). The main code
            logic for type=time is implemented in
            setMillisecondsSinceMidnightInternal() and toStringForTime()
            because the logic is going to be used for other types.
    
            * html/HTMLInputElement.cpp:
            (WebCore::HTMLInputElement::setValueAsDate):
            * html/ISODateTime.cpp:
            (WebCore::positiveFmod):
            (WebCore::ISODateTime::setMillisecondsSinceMidnightInternal):
            (WebCore::ISODateTime::setMillisecondsSinceMidnight):
            (WebCore::ISODateTime::toStringForTime):
            (WebCore::ISODateTime::toString):
            * html/ISODateTime.h:
            (WebCore::ISODateTime::):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53551 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 27e2e0f..894264a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2010-01-20  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        HTMLInputElement::valueAsDate setter support for type=time.
+        https://bugs.webkit.org/show_bug.cgi?id=33825
+
+        Add setter tests to input-valueasdate-time.js, and update the
+        expectation.
+
+        Note: the expectation file contains some FAIL lines. They are
+        intentional because they test a unimplemented feature.
+
+        * fast/forms/input-valueasdate-time-expected.txt:
+        * fast/forms/script-tests/input-valueasdate-time.js:
+
 2010-01-20  Philippe Normand  <pnormand at igalia.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/forms/input-valueasdate-time-expected.txt b/LayoutTests/fast/forms/input-valueasdate-time-expected.txt
index 189e8ca..9d02aaf 100644
--- a/LayoutTests/fast/forms/input-valueasdate-time-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasdate-time-expected.txt
@@ -7,6 +7,23 @@ PASS valueAsDateFor("") is null
 PASS valueAsDateFor("00:00:00.000").getTime() is Date.UTC(1970, 0, 1, 0, 0, 0, 0)
 PASS valueAsDateFor("04:35").getTime() is Date.UTC(1970, 0, 1, 4, 35, 0, 0)
 PASS valueAsDateFor("23:59:59.999").getTime() is Date.UTC(1970, 0, 1, 23, 59, 59, 999)
+PASS setValueAsDateAndGetValue(0, 0, 0, 0) is "00:00"
+PASS setValueAsDateAndGetValue(0, 0, 1, 0) is "00:00:01"
+PASS setValueAsDateAndGetValue(0, 0, 0, 2) is "00:00:00.002"
+PASS setValueAsDateAndGetValue(11, 59, 59, 999) is "11:59:59.999"
+PASS setValueAsDateAndGetValue(12, 0, 0, 0) is "12:00"
+PASS setValueAsDateAndGetValue(23, 59, 59, 999) is "23:59:59.999"
+PASS setValueAsDateAndGetValue(24, 0, 0, 0) is "00:00"
+PASS setValueAsDateAndGetValue(48, 0, 13, 0) is "00:00:13"
+PASS setValueAsDateAndGetValue(-23, -59, -59, 0) is "00:00:01"
+Invalid Date:
+PASS var date = new Date(); date.setTime(8.65E15); input.valueAsDate = date; input.value is ""
+Invalid objects:
+PASS input.value = "00:00"; input.valueAsDate = document; input.value is ""
+PASS input.value = "00:00"; input.valueAsDate = null; input.value is ""
+Step attribute value and string representation:
+FAIL input.step = "1"; setValueAsDateAndGetValue(0, 0, 0, 0) should be 00:00:00. Was 00:00.
+FAIL input.step = "0.001"; setValueAsDateAndGetValue(0, 0, 0, 0) should be 00:00:00.000. Was 00:00.
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasdate-time.js b/LayoutTests/fast/forms/script-tests/input-valueasdate-time.js
index 59144cb..583b3a0 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasdate-time.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasdate-time.js
@@ -8,9 +8,39 @@ function valueAsDateFor(stringValue) {
     return input.valueAsDate;
 }
 
+function setValueAsDateAndGetValue(hour, minute, second, ms) {
+    var date = new Date();
+    date.setTime(((hour * 60 + minute) * 60 + second) * 1000 + ms);
+    input.valueAsDate = date;
+    return input.value;
+}
+
 shouldBe('valueAsDateFor("")', 'null');
 shouldBe('valueAsDateFor("00:00:00.000").getTime()', 'Date.UTC(1970, 0, 1, 0, 0, 0, 0)');
 shouldBe('valueAsDateFor("04:35").getTime()', 'Date.UTC(1970, 0, 1, 4, 35, 0, 0)');
 shouldBe('valueAsDateFor("23:59:59.999").getTime()', 'Date.UTC(1970, 0, 1, 23, 59, 59, 999)');
 
+shouldBe('setValueAsDateAndGetValue(0, 0, 0, 0)', '"00:00"');
+shouldBe('setValueAsDateAndGetValue(0, 0, 1, 0)', '"00:00:01"');
+shouldBe('setValueAsDateAndGetValue(0, 0, 0, 2)', '"00:00:00.002"');
+shouldBe('setValueAsDateAndGetValue(11, 59, 59, 999)', '"11:59:59.999"');
+shouldBe('setValueAsDateAndGetValue(12, 0, 0, 0)', '"12:00"');
+shouldBe('setValueAsDateAndGetValue(23, 59, 59, 999)', '"23:59:59.999"');
+shouldBe('setValueAsDateAndGetValue(24, 0, 0, 0)', '"00:00"');
+shouldBe('setValueAsDateAndGetValue(48, 0, 13, 0)', '"00:00:13"');
+shouldBe('setValueAsDateAndGetValue(-23, -59, -59, 0)', '"00:00:01"');
+
+debug('Invalid Date:');
+// Date of JavaScript can't represent 8.65E15.
+shouldBe('var date = new Date(); date.setTime(8.65E15); input.valueAsDate = date; input.value', '""');
+debug('Invalid objects:');
+shouldBe('input.value = "00:00"; input.valueAsDate = document; input.value', '""');
+shouldBe('input.value = "00:00"; input.valueAsDate = null; input.value', '""');
+
+debug('Step attribute value and string representation:');
+// If the step attribute value is 1 second and the second part is 0, we should show the second part.
+shouldBe('input.step = "1"; setValueAsDateAndGetValue(0, 0, 0, 0)', '"00:00:00"');
+// If the step attribute value is 0.001 second and the millisecond part is 0, we should show the millisecond part.
+shouldBe('input.step = "0.001"; setValueAsDateAndGetValue(0, 0, 0, 0)', '"00:00:00.000"');
+
 var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d5eae7b..d05699e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,27 @@
+2010-01-20  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        HTMLInputElement::valueAsDate setter support for type=time.
+        https://bugs.webkit.org/show_bug.cgi?id=33825
+
+        Introduce ISODateTime::setMillisecondsSinceMidnight() and add a
+        SecondFormat parameter to ISODateTime::toString(). The main code
+        logic for type=time is implemented in
+        setMillisecondsSinceMidnightInternal() and toStringForTime()
+        because the logic is going to be used for other types.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::setValueAsDate):
+        * html/ISODateTime.cpp:
+        (WebCore::positiveFmod):
+        (WebCore::ISODateTime::setMillisecondsSinceMidnightInternal):
+        (WebCore::ISODateTime::setMillisecondsSinceMidnight):
+        (WebCore::ISODateTime::toStringForTime):
+        (WebCore::ISODateTime::toString):
+        * html/ISODateTime.h:
+        (WebCore::ISODateTime::):
+
 2010-01-20  Csaba Osztrogonác  <ossy at webkit.org>
 
         [Qt] Unreviewed buildfix for r53547.
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index 27116b6..b18aa35 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -1401,6 +1401,9 @@ void HTMLInputElement::setValueAsDate(double value, ExceptionCode& ec)
     case MONTH:
         success = dateTime.setMillisecondsSinceEpochForMonth(value);
         break;
+    case TIME:
+        success = dateTime.setMillisecondsSinceMidnight(value);
+        break;
     // FIXME: implementations for other supported types.
     default:
         ec = INVALID_STATE_ERR;
@@ -1410,6 +1413,9 @@ void HTMLInputElement::setValueAsDate(double value, ExceptionCode& ec)
         setValue(String());
         return;
     }
+    // FIXME: We should specify SecondFormat.
+    // e.g. If the step value is 60, use SecondFormat::None.
+    //      If the step value is 1, use SecondFormat::Second.
     setValue(dateTime.toString());
 }
 
diff --git a/WebCore/html/ISODateTime.cpp b/WebCore/html/ISODateTime.cpp
index adcc189..6fbc64a 100644
--- a/WebCore/html/ISODateTime.cpp
+++ b/WebCore/html/ISODateTime.cpp
@@ -450,6 +450,23 @@ bool ISODateTime::parseDateTime(const UChar* src, unsigned length, unsigned star
     return true;
 }
 
+static inline double positiveFmod(double value, double divider)
+{
+    double remainder = fmod(value, divider);
+    return remainder < 0 ? remainder + divider : remainder;
+}
+
+void ISODateTime::setMillisecondsSinceMidnightInternal(double msInDay)
+{
+    ASSERT(msInDay >= 0 && msInDay < msPerDay);
+    m_millisecond = static_cast<int>(fmod(msInDay, msPerSecond));
+    double value = floor(msInDay / msPerSecond);
+    m_second = static_cast<int>(fmod(value, secondsPerMinute));
+    value = floor(value / secondsPerMinute);
+    m_minute = static_cast<int>(fmod(value, minutesPerHour));
+    m_hour = static_cast<int>(value / minutesPerHour);
+}
+
 bool ISODateTime::setMillisecondsSinceEpochForDateInternal(double ms)
 {
     m_year = msToYear(ms);
@@ -472,6 +489,15 @@ bool ISODateTime::setMillisecondsSinceEpochForMonth(double ms)
     return true;
 }
 
+bool ISODateTime::setMillisecondsSinceMidnight(double ms)
+{
+    if (!isfinite(ms))
+        return false;
+    setMillisecondsSinceMidnightInternal(positiveFmod(round(ms), msPerDay));
+    m_type = Time;
+    return true;
+}
+
 double ISODateTime::millisecondsSinceEpochForTime() const
 {
     ASSERT(m_type == Time || m_type == DateTime);
@@ -505,11 +531,35 @@ double ISODateTime::millisecondsSinceEpoch() const
     return invalidMilliseconds();
 }
 
-String ISODateTime::toString() const
+String ISODateTime::toStringForTime(SecondFormat format) const
+{
+    ASSERT(m_type == DateTime || m_type == DateTimeLocal || m_type == Time);
+    SecondFormat effectiveFormat = format;
+    if (m_millisecond)
+        effectiveFormat = Millisecond;
+    else if (format == None && m_second)
+        effectiveFormat = Second;
+
+    switch (effectiveFormat) {
+    default:
+        ASSERT_NOT_REACHED();
+        // Fallback to None.
+    case None:
+        return String::format("%02d:%02d", m_hour, m_minute);
+    case Second:
+        return String::format("%02d:%02d:%02d", m_hour, m_minute, m_second);
+    case Millisecond:
+        return String::format("%02d:%02d:%02d.%03d", m_hour, m_minute, m_second, m_millisecond);
+    }
+}
+
+String ISODateTime::toString(SecondFormat format) const
 {
     switch (m_type) {
     case Month:
         return String::format("%04d-%02d", m_year, m_month + 1);
+    case Time:
+        return toStringForTime(format);
 
     // FIXME: implementations for other types.
     default:
diff --git a/WebCore/html/ISODateTime.h b/WebCore/html/ISODateTime.h
index aee20a0..f0dc25f 100644
--- a/WebCore/html/ISODateTime.h
+++ b/WebCore/html/ISODateTime.h
@@ -68,8 +68,15 @@ public:
     int fullYear() const { return m_year; }
     int week() const { return m_week; }
 
+    enum SecondFormat {
+        None, // Suppress the second part and the millisecond part if they are 0.
+        Second, // Always show the second part, and suppress the millisecond part if it is 0.
+        Millisecond // Always show the second part and the millisecond part.
+    };
+
     // Returns an ISO 8601 representation for this instance.
-    String toString() const;
+    // The format argument is valid for DateTime, DateTimeLocal, and Time types.
+    String toString(SecondFormat format = None) const;
 
     // The following six functions parse the input 'src' whose length is
     // 'length', and updates some fields of this instance. The parsing starts at
@@ -99,10 +106,13 @@ public:
     // ISODateTime type. The function returns true if it succeeds, and
     // false if it fails.
 
-    // For Month type.  Updates m_year and m_month.
+    // For Month type. Updates m_year and m_month.
     bool setMillisecondsSinceEpochForMonth(double ms);
     // FIXME: Add setMillisecondsSinceEpochFor*() for other types.
 
+    // For Time type. Updates m_hour, m_minute, m_second and m_millisecond.
+    bool setMillisecondsSinceMidnight(double ms);
+
     // Returns the number of milliseconds from 1970-01-01 00:00:00 UTC.
     // For an ISODateTime initialized with parseDateTimeLocal(),
     // millisecondsSinceEpoch() returns a value for UTC timezone.
@@ -119,8 +129,11 @@ private:
     bool parseTimeZone(const UChar* src, unsigned length, unsigned start, unsigned& end);
     // Helper for millisecondsSinceEpoch().
     double millisecondsSinceEpochForTime() const;
-    // Helper for setMillisecondsSinceEpochFor*().
+    // Helpers for setMillisecondsSinceEpochFor*().
     bool setMillisecondsSinceEpochForDateInternal(double ms);
+    void setMillisecondsSinceMidnightInternal(double ms);
+    // Helper for toString().
+    String toStringForTime(SecondFormat) const;
 
     // m_weekDay values
     enum {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list