[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

tkent at chromium.org tkent at chromium.org
Wed Dec 22 14:05:09 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 34b5151e9bc58b858ae9cbf73854c487a1c8fe81
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Oct 4 05:59:15 2010 +0000

    2010-10-03  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Dimitri Glazkov.
    
            Refactor HTMLInputElement: Move parseToDouble() and
            parseToDateComponents() to InputType.
            https://bugs.webkit.org/show_bug.cgi?id=46965
    
            Introduce BaseDateAndTimeInputType, which is a super class of
            date, datetime, datetime-local, month, time, and week types.
    
            No new tests. Just a refactoring.
    
            * Android.mk: Add BaseDateAndTimeInputType.
            * CMakeLists.txt: ditto.
            * GNUmakefile.am: ditto.
            * WebCore.gypi: ditto.
            * WebCore.pro: ditto.
            * WebCore.vcproj/WebCore.vcproj: ditto.
            * WebCore.xcodeproj/project.pbxproj: ditto.
            * html/BaseDateAndTimeInputType.cpp: Added.
            (WebCore::BaseDateAndTimeInputType::parseToDouble):
            (WebCore::BaseDateAndTimeInputType::parseToDateComponents):
            * html/BaseDateAndTimeInputType.h: Added.
            (WebCore::BaseDateAndTimeInputType::BaseDateAndTimeInputType):
            * html/DateInputType.cpp:
            (WebCore::DateInputType::parseToDateComponentsInternal):
            * html/DateInputType.h:
            (WebCore::DateInputType::DateInputType):
            * html/DateTimeInputType.cpp:
            (WebCore::DateTimeInputType::parseToDateComponentsInternal):
            * html/DateTimeInputType.h:
            (WebCore::DateTimeInputType::DateTimeInputType):
            * html/DateTimeLocalInputType.cpp:
            (WebCore::DateTimeLocalInputType::parseToDateComponentsInternal):
            * html/DateTimeLocalInputType.h:
            (WebCore::DateTimeLocalInputType::DateTimeLocalInputType):
            * html/HTMLInputElement.cpp: Replace parseToD* calls with m_inputType->parseToD*.
            (WebCore::HTMLInputElement::typeMismatch):
            (WebCore::HTMLInputElement::rangeUnderflow):
            (WebCore::HTMLInputElement::rangeOverflow):
            (WebCore::HTMLInputElement::minimum):
            (WebCore::HTMLInputElement::maximum):
            (WebCore::HTMLInputElement::stepBase):
            (WebCore::HTMLInputElement::stepMismatch):
            (WebCore::HTMLInputElement::applyStep):
            (WebCore::HTMLInputElement::valueAsDate):
            (WebCore::HTMLInputElement::valueAsNumber):
            (WebCore::HTMLInputElement::handleKeyEventForRange):
            (WebCore::HTMLInputElement::stepUpFromRenderer):
            * html/HTMLInputElement.h:
            * html/InputType.cpp:
            (WebCore::InputType::parseToDouble):
            (WebCore::InputType::parseToDateComponents):
            * html/InputType.h:
            * html/MonthInputType.cpp:
            (WebCore::MonthInputType::parseToDouble):
            (WebCore::MonthInputType::parseToDateComponentsInternal):
            * html/MonthInputType.h:
            (WebCore::MonthInputType::MonthInputType):
            * html/NumberInputType.cpp:
            (WebCore::NumberInputType::parseToDouble):
            * html/NumberInputType.h:
            * html/RangeInputType.cpp:
            (WebCore::RangeInputType::parseToDouble):
            * html/RangeInputType.h:
            * html/TimeInputType.cpp:
            (WebCore::TimeInputType::parseToDateComponentsInternal):
            * html/TimeInputType.h:
            (WebCore::TimeInputType::TimeInputType):
            * html/WeekInputType.cpp:
            (WebCore::WeekInputType::parseToDateComponentsInternal):
            * html/WeekInputType.h:
            (WebCore::WeekInputType::WeekInputType):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68996 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index 98c6515..d151b27 100644
--- a/WebCore/Android.mk
+++ b/WebCore/Android.mk
@@ -261,6 +261,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
 	history/android/HistoryItemAndroid.cpp \
 	\
 	html/AsyncImageResizer.cpp \
+	html/BaseDateAndTimeInputType.cpp \
 	html/BaseTextInputType.cpp \
 	html/ButtonInputType.cpp \
 	html/CheckboxInputType.cpp \
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 3c4a1e0..217252e 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -944,6 +944,7 @@ SET(WebCore_SOURCES
     history/PageCache.cpp
 
     html/AsyncImageResizer.cpp
+    html/BaseDateAndTimeInputType.cpp
     html/BaseTextInputType.cpp
     html/ButtonInputType.cpp
     html/CheckboxInputType.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 05b9775..10ddf97 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,78 @@
+2010-10-03  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Refactor HTMLInputElement: Move parseToDouble() and
+        parseToDateComponents() to InputType.
+        https://bugs.webkit.org/show_bug.cgi?id=46965
+
+        Introduce BaseDateAndTimeInputType, which is a super class of
+        date, datetime, datetime-local, month, time, and week types.
+
+        No new tests. Just a refactoring.
+
+        * Android.mk: Add BaseDateAndTimeInputType.
+        * CMakeLists.txt: ditto.
+        * GNUmakefile.am: ditto.
+        * WebCore.gypi: ditto.
+        * WebCore.pro: ditto.
+        * WebCore.vcproj/WebCore.vcproj: ditto.
+        * WebCore.xcodeproj/project.pbxproj: ditto.
+        * html/BaseDateAndTimeInputType.cpp: Added.
+        (WebCore::BaseDateAndTimeInputType::parseToDouble):
+        (WebCore::BaseDateAndTimeInputType::parseToDateComponents):
+        * html/BaseDateAndTimeInputType.h: Added.
+        (WebCore::BaseDateAndTimeInputType::BaseDateAndTimeInputType):
+        * html/DateInputType.cpp:
+        (WebCore::DateInputType::parseToDateComponentsInternal):
+        * html/DateInputType.h:
+        (WebCore::DateInputType::DateInputType):
+        * html/DateTimeInputType.cpp:
+        (WebCore::DateTimeInputType::parseToDateComponentsInternal):
+        * html/DateTimeInputType.h:
+        (WebCore::DateTimeInputType::DateTimeInputType):
+        * html/DateTimeLocalInputType.cpp:
+        (WebCore::DateTimeLocalInputType::parseToDateComponentsInternal):
+        * html/DateTimeLocalInputType.h:
+        (WebCore::DateTimeLocalInputType::DateTimeLocalInputType):
+        * html/HTMLInputElement.cpp: Replace parseToD* calls with m_inputType->parseToD*.
+        (WebCore::HTMLInputElement::typeMismatch):
+        (WebCore::HTMLInputElement::rangeUnderflow):
+        (WebCore::HTMLInputElement::rangeOverflow):
+        (WebCore::HTMLInputElement::minimum):
+        (WebCore::HTMLInputElement::maximum):
+        (WebCore::HTMLInputElement::stepBase):
+        (WebCore::HTMLInputElement::stepMismatch):
+        (WebCore::HTMLInputElement::applyStep):
+        (WebCore::HTMLInputElement::valueAsDate):
+        (WebCore::HTMLInputElement::valueAsNumber):
+        (WebCore::HTMLInputElement::handleKeyEventForRange):
+        (WebCore::HTMLInputElement::stepUpFromRenderer):
+        * html/HTMLInputElement.h:
+        * html/InputType.cpp:
+        (WebCore::InputType::parseToDouble):
+        (WebCore::InputType::parseToDateComponents):
+        * html/InputType.h:
+        * html/MonthInputType.cpp:
+        (WebCore::MonthInputType::parseToDouble):
+        (WebCore::MonthInputType::parseToDateComponentsInternal):
+        * html/MonthInputType.h:
+        (WebCore::MonthInputType::MonthInputType):
+        * html/NumberInputType.cpp:
+        (WebCore::NumberInputType::parseToDouble):
+        * html/NumberInputType.h:
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::parseToDouble):
+        * html/RangeInputType.h:
+        * html/TimeInputType.cpp:
+        (WebCore::TimeInputType::parseToDateComponentsInternal):
+        * html/TimeInputType.h:
+        (WebCore::TimeInputType::TimeInputType):
+        * html/WeekInputType.cpp:
+        (WebCore::WeekInputType::parseToDateComponentsInternal):
+        * html/WeekInputType.h:
+        (WebCore::WeekInputType::WeekInputType):
+
 2010-10-03  Adam Barth  <abarth at webkit.org>
 
         Reviewed by Holger Freyther.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 795c926..789a90c 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1427,6 +1427,8 @@ webcore_sources += \
 	WebCore/history/PageCache.h \
 	WebCore/html/AsyncImageResizer.cpp \
 	WebCore/html/AsyncImageResizer.h \
+	WebCore/html/BaseDateAndTimeInputType.cpp \
+	WebCore/html/BaseDateAndTimeInputType.h \
 	WebCore/html/BaseTextInputType.cpp \
 	WebCore/html/BaseTextInputType.h \
 	WebCore/html/ButtonInputType.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 6e0c396..a17f61c 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1513,6 +1513,8 @@
             'history/PageCache.h',
             'html/AsyncImageResizer.cpp',
             'html/AsyncImageResizer.h',
+            'html/BaseDateAndTimeInputType.cpp',
+            'html/BaseDateAndTimeInputType.h',
             'html/BaseTextInputType.cpp',
             'html/BaseTextInputType.h',
             'html/ButtonInputType.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index a8452e4..d769921 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -836,6 +836,7 @@ SOURCES += \
     history/qt/HistoryItemQt.cpp \
     history/PageCache.cpp \
     html/AsyncImageResizer.cpp \
+    html/BaseDateAndTimeInputType.cpp \
     html/BaseTextInputType.cpp \
     html/ButtonInputType.cpp \
     html/CheckboxInputType.cpp \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 659bbf7..4f847a3 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -37411,6 +37411,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\html\BaseDateAndTimeInputType.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\html\BaseDateAndTimeInputType.h"
+				>
+			</File>
+			<File
 				RelativePath="..\html\BaseTextInputType.cpp"
 				>
 			</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 98830cd..b868408 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -5468,6 +5468,8 @@
 		F55B3DDE1251F12D003EF269 /* URLInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = F55B3DAA1251F12D003EF269 /* URLInputType.h */; };
 		F55B3DDF1251F12D003EF269 /* WeekInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F55B3DAB1251F12D003EF269 /* WeekInputType.cpp */; };
 		F55B3DE01251F12D003EF269 /* WeekInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = F55B3DAC1251F12D003EF269 /* WeekInputType.h */; };
+		F59C95FF1255B23F000623C0 /* BaseDateAndTimeInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F59C95FD1255B23F000623C0 /* BaseDateAndTimeInputType.cpp */; };
+		F59C96001255B23F000623C0 /* BaseDateAndTimeInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = F59C95FE1255B23F000623C0 /* BaseDateAndTimeInputType.h */; };
 		F5C041DA0FFCA7CE00839D4A /* HTMLDataListElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5C041D70FFCA7CE00839D4A /* HTMLDataListElement.cpp */; };
 		F5C041DB0FFCA7CE00839D4A /* HTMLDataListElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F5C041D80FFCA7CE00839D4A /* HTMLDataListElement.h */; };
 		F5C041E30FFCA96D00839D4A /* DOMHTMLDataListElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F5C041DE0FFCA96D00839D4A /* DOMHTMLDataListElement.h */; };
@@ -11466,6 +11468,8 @@
 		F587866202DE3B1101EA4122 /* SSLKeyGenerator.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = SSLKeyGenerator.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		F587868402DE3B8601EA4122 /* Cursor.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Cursor.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		F587869902DE3B8601EA4122 /* DeprecatedPtrList.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = DeprecatedPtrList.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+		F59C95FD1255B23F000623C0 /* BaseDateAndTimeInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseDateAndTimeInputType.cpp; sourceTree = "<group>"; };
+		F59C95FE1255B23F000623C0 /* BaseDateAndTimeInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseDateAndTimeInputType.h; sourceTree = "<group>"; };
 		F5C041D70FFCA7CE00839D4A /* HTMLDataListElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLDataListElement.cpp; sourceTree = "<group>"; };
 		F5C041D80FFCA7CE00839D4A /* HTMLDataListElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLDataListElement.h; sourceTree = "<group>"; };
 		F5C041D90FFCA7CE00839D4A /* HTMLDataListElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLDataListElement.idl; sourceTree = "<group>"; };
@@ -14412,6 +14416,8 @@
 				97C1F5511228558800EDE616 /* parser */,
 				B0149E7911A4B21500196A7B /* AsyncImageResizer.cpp */,
 				B0149E7A11A4B21500196A7B /* AsyncImageResizer.h */,
+				F59C95FD1255B23F000623C0 /* BaseDateAndTimeInputType.cpp */,
+				F59C95FE1255B23F000623C0 /* BaseDateAndTimeInputType.h */,
 				F55B3D791251F12D003EF269 /* BaseTextInputType.cpp */,
 				F55B3D7A1251F12D003EF269 /* BaseTextInputType.h */,
 				F55B3D7B1251F12D003EF269 /* ButtonInputType.cpp */,
@@ -18216,6 +18222,7 @@
 				BCA8CA6011E4E6D100812FB7 /* BackForwardListImpl.h in Headers */,
 				BC124EE80C2641CD009E2349 /* BarInfo.h in Headers */,
 				B2C3DA220D006C1D00EF6F26 /* Base64.h in Headers */,
+				F59C96001255B23F000623C0 /* BaseDateAndTimeInputType.h in Headers */,
 				F55B3DAE1251F12D003EF269 /* BaseTextInputType.h in Headers */,
 				BC9462D8107A7B4C00857193 /* BeforeLoadEvent.h in Headers */,
 				51721FBB11D2790700638B42 /* BeforeProcessEvent.h in Headers */,
@@ -21317,6 +21324,7 @@
 				BCA8CA5F11E4E6D100812FB7 /* BackForwardListImpl.cpp in Sources */,
 				BC124EE70C2641CD009E2349 /* BarInfo.cpp in Sources */,
 				B2C3DA210D006C1D00EF6F26 /* Base64.cpp in Sources */,
+				F59C95FF1255B23F000623C0 /* BaseDateAndTimeInputType.cpp in Sources */,
 				F55B3DAD1251F12D003EF269 /* BaseTextInputType.cpp in Sources */,
 				5172204B11D2960500638B42 /* BeforeProcessEvent.cpp in Sources */,
 				AB23A32709BBA7D00067CC53 /* BeforeTextInsertedEvent.cpp in Sources */,
diff --git a/WebCore/html/BaseDateAndTimeInputType.cpp b/WebCore/html/BaseDateAndTimeInputType.cpp
new file mode 100644
index 0000000..1bdece2
--- /dev/null
+++ b/WebCore/html/BaseDateAndTimeInputType.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BaseDateAndTimeInputType.h"
+
+#include "DateComponents.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+double BaseDateAndTimeInputType::parseToDouble(const String& src, double defaultValue) const
+{
+    DateComponents date;
+    if (!parseToDateComponents(src, &date))
+        return defaultValue;
+    double msec = date.millisecondsSinceEpoch();
+    ASSERT(isfinite(msec));
+    return msec;
+}
+
+bool BaseDateAndTimeInputType::parseToDateComponents(const String& source, DateComponents* out) const
+{
+    if (source.isEmpty())
+        return false;
+    DateComponents ignoredResult;
+    if (!out)
+        out = &ignoredResult;
+    return parseToDateComponentsInternal(source.characters(), source.length(), out);
+}
+
+} // namespace WebCore
diff --git a/WebCore/html/BaseDateAndTimeInputType.h b/WebCore/html/BaseDateAndTimeInputType.h
new file mode 100644
index 0000000..336cd83
--- /dev/null
+++ b/WebCore/html/BaseDateAndTimeInputType.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BaseDateAndTimeInputType_h
+#define BaseDateAndTimeInputType_h
+
+#include "TextFieldInputType.h"
+#include <wtf/unicode/Unicode.h>
+
+namespace WebCore {
+
+// A super class of date, datetime, datetime-local, month, time, and week types.
+class BaseDateAndTimeInputType : public TextFieldInputType {
+protected:
+    BaseDateAndTimeInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
+    virtual bool parseToDateComponents(const String&, DateComponents*) const;
+    // A helper for parseToDateComponents().
+    virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const = 0;
+private:
+    virtual double parseToDouble(const String&, double) const;
+};
+
+} // namespace WebCore
+
+#endif // BaseDateAndTimeInputType_h
diff --git a/WebCore/html/DateInputType.cpp b/WebCore/html/DateInputType.cpp
index 0605846..3cb959d 100644
--- a/WebCore/html/DateInputType.cpp
+++ b/WebCore/html/DateInputType.cpp
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "DateInputType.h"
 
+#include "DateComponents.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -45,4 +46,11 @@ const AtomicString& DateInputType::formControlType() const
     return InputTypeNames::date();
 }
 
+bool DateInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const
+{
+    ASSERT(out);
+    unsigned end;
+    return out->parseDate(characters, length, 0, end) && end == length;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/DateInputType.h b/WebCore/html/DateInputType.h
index e6f60d7..e37682e 100644
--- a/WebCore/html/DateInputType.h
+++ b/WebCore/html/DateInputType.h
@@ -31,17 +31,18 @@
 #ifndef DateInputType_h
 #define DateInputType_h
 
-#include "TextFieldInputType.h"
+#include "BaseDateAndTimeInputType.h"
 
 namespace WebCore {
 
-class DateInputType : public TextFieldInputType {
+class DateInputType : public BaseDateAndTimeInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    DateInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
+    DateInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/DateTimeInputType.cpp b/WebCore/html/DateTimeInputType.cpp
index 0bf5e04..75bf1da 100644
--- a/WebCore/html/DateTimeInputType.cpp
+++ b/WebCore/html/DateTimeInputType.cpp
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "DateTimeInputType.h"
 
+#include "DateComponents.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -45,4 +46,11 @@ const AtomicString& DateTimeInputType::formControlType() const
     return InputTypeNames::datetime();
 }
 
+bool DateTimeInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const
+{
+    ASSERT(out);
+    unsigned end;
+    return out->parseDateTime(characters, length, 0, end) && end == length;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/DateTimeInputType.h b/WebCore/html/DateTimeInputType.h
index f24ebfb..92ebc41 100644
--- a/WebCore/html/DateTimeInputType.h
+++ b/WebCore/html/DateTimeInputType.h
@@ -31,17 +31,18 @@
 #ifndef DateTimeInputType_h
 #define DateTimeInputType_h
 
-#include "TextFieldInputType.h"
+#include "BaseDateAndTimeInputType.h"
 
 namespace WebCore {
 
-class DateTimeInputType : public TextFieldInputType {
+class DateTimeInputType : public BaseDateAndTimeInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    DateTimeInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
+    DateTimeInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/DateTimeLocalInputType.cpp b/WebCore/html/DateTimeLocalInputType.cpp
index 33c6cfa..916a386 100644
--- a/WebCore/html/DateTimeLocalInputType.cpp
+++ b/WebCore/html/DateTimeLocalInputType.cpp
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "DateTimeLocalInputType.h"
 
+#include "DateComponents.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -45,4 +46,11 @@ const AtomicString& DateTimeLocalInputType::formControlType() const
     return InputTypeNames::datetimelocal();
 }
 
+bool DateTimeLocalInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const
+{
+    ASSERT(out);
+    unsigned end;
+    return out->parseDateTimeLocal(characters, length, 0, end) && end == length;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/DateTimeLocalInputType.h b/WebCore/html/DateTimeLocalInputType.h
index 1a3d866..3ec841d 100644
--- a/WebCore/html/DateTimeLocalInputType.h
+++ b/WebCore/html/DateTimeLocalInputType.h
@@ -31,17 +31,18 @@
 #ifndef DateTimeLocalInputType_h
 #define DateTimeLocalInputType_h
 
-#include "TextFieldInputType.h"
+#include "BaseDateAndTimeInputType.h"
 
 namespace WebCore {
 
-class DateTimeLocalInputType : public TextFieldInputType {
+class DateTimeLocalInputType : public BaseDateAndTimeInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    DateTimeLocalInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
+    DateTimeLocalInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index 4790ac6..dff895a 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -283,7 +283,7 @@ bool HTMLInputElement::typeMismatch(const String& value) const
     case MONTH:
     case TIME:
     case WEEK:
-        return !parseToDateComponents(deprecatedInputType(), value, 0);
+        return !m_inputType->parseToDateComponents(value, 0);
     case BUTTON:
     case CHECKBOX:
     case FILE:
@@ -379,11 +379,11 @@ bool HTMLInputElement::rangeUnderflow(const String& value) const
     case NUMBER:
     case TIME:
     case WEEK: {
-        double doubleValue = parseToDouble(value, nan);
+        double doubleValue = m_inputType->parseToDouble(value, nan);
         return isfinite(doubleValue) && doubleValue < minimum();
     }
     case RANGE: // Guaranteed by sanitization.
-        ASSERT(parseToDouble(value, nan) >= minimum());
+        ASSERT(m_inputType->parseToDouble(value, nan) >= minimum());
     case BUTTON:
     case CHECKBOX:
     case COLOR:
@@ -416,11 +416,11 @@ bool HTMLInputElement::rangeOverflow(const String& value) const
     case NUMBER:
     case TIME:
     case WEEK: {
-        double doubleValue = parseToDouble(value, nan);
+        double doubleValue = m_inputType->parseToDouble(value, nan);
         return isfinite(doubleValue) && doubleValue > maximum();
     }
     case RANGE: // Guaranteed by sanitization.
-        ASSERT(parseToDouble(value, nan) <= maximum());
+        ASSERT(m_inputType->parseToDouble(value, nan) <= maximum());
     case BUTTON:
     case CHECKBOX:
     case COLOR:
@@ -446,20 +446,20 @@ double HTMLInputElement::minimum() const
 {
     switch (deprecatedInputType()) {
     case DATE:
-        return parseToDouble(getAttribute(minAttr), DateComponents::minimumDate());
+        return m_inputType->parseToDouble(getAttribute(minAttr), DateComponents::minimumDate());
     case DATETIME:
     case DATETIMELOCAL:
-        return parseToDouble(getAttribute(minAttr), DateComponents::minimumDateTime());
+        return m_inputType->parseToDouble(getAttribute(minAttr), DateComponents::minimumDateTime());
     case MONTH:
-        return parseToDouble(getAttribute(minAttr), DateComponents::minimumMonth());
+        return m_inputType->parseToDouble(getAttribute(minAttr), DateComponents::minimumMonth());
     case NUMBER:
-        return parseToDouble(getAttribute(minAttr), numberDefaultMinimum);
+        return m_inputType->parseToDouble(getAttribute(minAttr), numberDefaultMinimum);
     case RANGE:
-        return parseToDouble(getAttribute(minAttr), rangeDefaultMinimum);
+        return m_inputType->parseToDouble(getAttribute(minAttr), rangeDefaultMinimum);
     case TIME:
-        return parseToDouble(getAttribute(minAttr), DateComponents::minimumTime());
+        return m_inputType->parseToDouble(getAttribute(minAttr), DateComponents::minimumTime());
     case WEEK:
-        return parseToDouble(getAttribute(minAttr), DateComponents::minimumWeek());
+        return m_inputType->parseToDouble(getAttribute(minAttr), DateComponents::minimumWeek());
     case BUTTON:
     case CHECKBOX:
     case COLOR:
@@ -486,16 +486,16 @@ double HTMLInputElement::maximum() const
 {
     switch (deprecatedInputType()) {
     case DATE:
-        return parseToDouble(getAttribute(maxAttr), DateComponents::maximumDate());
+        return m_inputType->parseToDouble(getAttribute(maxAttr), DateComponents::maximumDate());
     case DATETIME:
     case DATETIMELOCAL:
-        return parseToDouble(getAttribute(maxAttr), DateComponents::maximumDateTime());
+        return m_inputType->parseToDouble(getAttribute(maxAttr), DateComponents::maximumDateTime());
     case MONTH:
-        return parseToDouble(getAttribute(maxAttr), DateComponents::maximumMonth());
+        return m_inputType->parseToDouble(getAttribute(maxAttr), DateComponents::maximumMonth());
     case NUMBER:
-        return parseToDouble(getAttribute(maxAttr), numberDefaultMaximum);
+        return m_inputType->parseToDouble(getAttribute(maxAttr), numberDefaultMaximum);
     case RANGE: {
-        double max = parseToDouble(getAttribute(maxAttr), rangeDefaultMaximum);
+        double max = m_inputType->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();
@@ -504,9 +504,9 @@ double HTMLInputElement::maximum() const
         return max;
     }
     case TIME:
-        return parseToDouble(getAttribute(maxAttr), DateComponents::maximumTime());
+        return m_inputType->parseToDouble(getAttribute(maxAttr), DateComponents::maximumTime());
     case WEEK:
-        return parseToDouble(getAttribute(maxAttr), DateComponents::maximumWeek());
+        return m_inputType->parseToDouble(getAttribute(maxAttr), DateComponents::maximumWeek());
     case BUTTON:
     case CHECKBOX:
     case COLOR:
@@ -540,9 +540,9 @@ double HTMLInputElement::stepBase() const
     case MONTH:
     case NUMBER:
     case TIME:
-        return parseToDouble(getAttribute(minAttr), defaultStepBase);
+        return m_inputType->parseToDouble(getAttribute(minAttr), defaultStepBase);
     case WEEK:
-        return parseToDouble(getAttribute(minAttr), weekDefaultStepBase);
+        return m_inputType->parseToDouble(getAttribute(minAttr), weekDefaultStepBase);
     case BUTTON:
     case CHECKBOX:
     case COLOR:
@@ -600,7 +600,7 @@ bool HTMLInputElement::stepMismatch(const String& value) const
     case TIME:
     case WEEK: {
         const double nan = numeric_limits<double>::quiet_NaN();
-        double doubleValue = parseToDouble(value, nan);
+        double doubleValue = m_inputType->parseToDouble(value, nan);
         doubleValue = fabs(doubleValue - stepBase());
         if (!isfinite(doubleValue))
             return false;
@@ -723,7 +723,7 @@ void HTMLInputElement::applyStep(double count, ExceptionCode& ec)
         return;
     }
     const double nan = numeric_limits<double>::quiet_NaN();
-    double current = parseToDouble(value(), nan);
+    double current = m_inputType->parseToDouble(value(), nan);
     if (!isfinite(current)) {
         ec = INVALID_STATE_ERR;
         return;
@@ -1643,60 +1643,6 @@ void HTMLInputElement::setValue(const String& value, bool sendChangeEvent)
     InputElement::notifyFormStateChanged(this);
 }
 
-double HTMLInputElement::parseToDouble(const String& src, double defaultValue) const
-{
-    switch (deprecatedInputType()) {
-    case DATE:
-    case DATETIME:
-    case DATETIMELOCAL:
-    case TIME:
-    case WEEK: {
-        DateComponents date;
-        if (!parseToDateComponents(deprecatedInputType(), src, &date))
-            return defaultValue;
-        double msec = date.millisecondsSinceEpoch();
-        ASSERT(isfinite(msec));
-        return msec;
-    }
-    case MONTH: {
-        DateComponents date;
-        if (!parseToDateComponents(deprecatedInputType(), src, &date))
-            return defaultValue;
-        double months = date.monthsSinceEpoch();
-        ASSERT(isfinite(months));
-        return months;
-    }
-    case NUMBER:
-    case RANGE: {
-        double numberValue;
-        if (!parseToDoubleForNumberType(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 (deprecatedInputType()) {
@@ -1704,10 +1650,10 @@ double HTMLInputElement::valueAsDate() const
     case DATETIME:
     case TIME:
     case WEEK:
-        return parseToDouble(value(), DateComponents::invalidMilliseconds());
+        return m_inputType->parseToDouble(value(), DateComponents::invalidMilliseconds());
     case MONTH: {
         DateComponents date;
-        if (!parseToDateComponents(deprecatedInputType(), value(), &date))
+        if (!m_inputType->parseToDateComponents(value(), &date))
             return DateComponents::invalidMilliseconds();
         double msec = date.millisecondsSinceEpoch();
         ASSERT(isfinite(msec));
@@ -1794,7 +1740,7 @@ double HTMLInputElement::valueAsNumber() const
     case RANGE:
     case TIME:
     case WEEK:
-        return parseToDouble(value(), nan);
+        return m_inputType->parseToDouble(value(), nan);
 
     case BUTTON:
     case CHECKBOX:
@@ -2492,7 +2438,7 @@ void HTMLInputElement::handleKeyEventForRange(KeyboardEvent* event)
         double max = maximum();
         // FIXME: Is 1/100 reasonable?
         double step = (max - min) / 100;
-        double current = parseToDouble(value(), numeric_limits<double>::quiet_NaN());
+        double current = m_inputType->parseToDouble(value(), numeric_limits<double>::quiet_NaN());
         ASSERT(isfinite(current));
         double newValue;
         if (key == "Up" || key == "Right") {
@@ -2791,36 +2737,6 @@ bool HTMLInputElement::recalcWillValidate() const
     return false;
 }
 
-bool HTMLInputElement::parseToDateComponents(DeprecatedInputType type, const String& formString, DateComponents* out)
-{
-    if (formString.isEmpty())
-        return false;
-    DateComponents ignoredResult;
-    if (!out)
-        out = &ignoredResult;
-    const UChar* characters = formString.characters();
-    unsigned length = formString.length();
-    unsigned end;
-
-    switch (type) {
-    case DATE:
-        return out->parseDate(characters, length, 0, end) && end == length;
-    case DATETIME:
-        return out->parseDateTime(characters, length, 0, end) && end == length;
-    case DATETIMELOCAL:
-        return out->parseDateTimeLocal(characters, length, 0, end) && end == length;
-    case MONTH:
-        return out->parseMonth(characters, length, 0, end) && end == length;
-    case WEEK:
-        return out->parseWeek(characters, length, 0, end) && end == length;
-    case TIME:
-        return out->parseTime(characters, length, 0, end) && end == length;
-    default:
-        ASSERT_NOT_REACHED();
-        return false;
-    }
-}
-
 #if ENABLE(DATALIST)
 
 HTMLElement* HTMLInputElement::list() const
@@ -2912,7 +2828,7 @@ void HTMLInputElement::stepUpFromRenderer(int n)
 
     const double nan = numeric_limits<double>::quiet_NaN();
     String currentStringValue = value();
-    double current = parseToDouble(currentStringValue, nan);
+    double current = m_inputType->parseToDouble(currentStringValue, nan);
     if (!isfinite(current) || (n > 0 && current < minimum()) || (n < 0 && current > maximum()))
         setValue(serialize(n > 0 ? minimum() : maximum()));
     else {
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index d2e23fa..cd98a1d 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -330,16 +330,6 @@ private:
     // Helper for applyStepForNumberOrRange().
     double stepBase() const;
 
-    // Parses the specified string as the DeprecatedInputType, and returns true if it is successfully parsed.
-    // An instance pointed by the DateComponents* parameter will have parsed values and be
-    // modified even if the parsing fails.  The DateComponents* parameter may be 0.
-    static bool parseToDateComponents(DeprecatedInputType, const String&, DateComponents*);
-
-    // 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;
     // Create a string representation of the specified double value for the
     // current input type. If NaN or Infinity is specified, this returns an
     // emtpy string. This should not be called for types without valueAsNumber.
diff --git a/WebCore/html/InputType.cpp b/WebCore/html/InputType.cpp
index c3435f7..7b83ca4 100644
--- a/WebCore/html/InputType.cpp
+++ b/WebCore/html/InputType.cpp
@@ -122,6 +122,18 @@ bool InputType::patternMismatch(const String&) const
     return false;
 }
 
+double InputType::parseToDouble(const String&, double defaultValue) const
+{
+    return defaultValue;
+}
+
+bool InputType::parseToDateComponents(const String&, DateComponents*) const
+{
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
+
 namespace InputTypeNames {
 
 // The type names must be lowercased because they will be the return values of
diff --git a/WebCore/html/InputType.h b/WebCore/html/InputType.h
index 3141f34..9ce7648 100644
--- a/WebCore/html/InputType.h
+++ b/WebCore/html/InputType.h
@@ -36,6 +36,7 @@
 
 namespace WebCore {
 
+class DateComponents;
 class HTMLInputElement;
 
 class InputType : public Noncopyable {
@@ -50,6 +51,17 @@ public:
 
     virtual bool patternMismatch(const String&) const;
 
+    // Parses the specified string for the 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.
+    virtual double parseToDouble(const String&, double defaultValue) const;
+    // Parses the specified string for this InputType, and returns true if it
+    // is successfully parsed. An instance pointed by the DateComponents*
+    // parameter will have parsed values and be modified even if the parsing
+    // fails. The DateComponents* parameter may be 0.
+    virtual bool parseToDateComponents(const String&, DateComponents*) const;
+
 protected:
     InputType(HTMLInputElement* element) : m_element(element) { }
     HTMLInputElement* element() const { return m_element; }
diff --git a/WebCore/html/MonthInputType.cpp b/WebCore/html/MonthInputType.cpp
index 54f78c6..501bdc7 100644
--- a/WebCore/html/MonthInputType.cpp
+++ b/WebCore/html/MonthInputType.cpp
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "MonthInputType.h"
 
+#include "DateComponents.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -45,4 +46,21 @@ const AtomicString& MonthInputType::formControlType() const
     return InputTypeNames::month();
 }
 
+double MonthInputType::parseToDouble(const String& src, double defaultValue) const
+{
+    DateComponents date;
+    if (!parseToDateComponents(src, &date))
+        return defaultValue;
+    double months = date.monthsSinceEpoch();
+    ASSERT(isfinite(months));
+    return months;
+}
+
+bool MonthInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const
+{
+    ASSERT(out);
+    unsigned end;
+    return out->parseMonth(characters, length, 0, end) && end == length;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/MonthInputType.h b/WebCore/html/MonthInputType.h
index d605ffa..a7ea550 100644
--- a/WebCore/html/MonthInputType.h
+++ b/WebCore/html/MonthInputType.h
@@ -31,17 +31,19 @@
 #ifndef MonthInputType_h
 #define MonthInputType_h
 
-#include "TextFieldInputType.h"
+#include "BaseDateAndTimeInputType.h"
 
 namespace WebCore {
 
-class MonthInputType : public TextFieldInputType {
+class MonthInputType : public BaseDateAndTimeInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    MonthInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
+    MonthInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual double parseToDouble(const String&, double) const;
+    virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/NumberInputType.cpp b/WebCore/html/NumberInputType.cpp
index 9aba5c3..230ea6f 100644
--- a/WebCore/html/NumberInputType.cpp
+++ b/WebCore/html/NumberInputType.cpp
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "NumberInputType.h"
 
+#include "HTMLParserIdioms.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -45,4 +46,13 @@ const AtomicString& NumberInputType::formControlType() const
     return InputTypeNames::number();
 }
 
+double NumberInputType::parseToDouble(const String& src, double defaultValue) const
+{
+    double numberValue;
+    if (!parseToDoubleForNumberType(src, &numberValue))
+        return defaultValue;
+    ASSERT(isfinite(numberValue));
+    return numberValue;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/NumberInputType.h b/WebCore/html/NumberInputType.h
index 5347249..9a2e9cd 100644
--- a/WebCore/html/NumberInputType.h
+++ b/WebCore/html/NumberInputType.h
@@ -42,6 +42,7 @@ public:
 private:
     NumberInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual double parseToDouble(const String&, double) const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/RangeInputType.cpp b/WebCore/html/RangeInputType.cpp
index f5f7322..1b07ac3 100644
--- a/WebCore/html/RangeInputType.cpp
+++ b/WebCore/html/RangeInputType.cpp
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "RangeInputType.h"
 
+#include "HTMLParserIdioms.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -45,4 +46,13 @@ const AtomicString& RangeInputType::formControlType() const
     return InputTypeNames::range();
 }
 
+double RangeInputType::parseToDouble(const String& src, double defaultValue) const
+{
+    double numberValue;
+    if (!parseToDoubleForNumberType(src, &numberValue))
+        return defaultValue;
+    ASSERT(isfinite(numberValue));
+    return numberValue;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/RangeInputType.h b/WebCore/html/RangeInputType.h
index d42c617..e681e5a 100644
--- a/WebCore/html/RangeInputType.h
+++ b/WebCore/html/RangeInputType.h
@@ -42,6 +42,7 @@ public:
 private:
     RangeInputType(HTMLInputElement* element) : InputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual double parseToDouble(const String&, double) const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/TimeInputType.cpp b/WebCore/html/TimeInputType.cpp
index 1564bc5..535ab04 100644
--- a/WebCore/html/TimeInputType.cpp
+++ b/WebCore/html/TimeInputType.cpp
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "TimeInputType.h"
 
+#include "DateComponents.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -45,4 +46,11 @@ const AtomicString& TimeInputType::formControlType() const
     return InputTypeNames::time();
 }
 
+bool TimeInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const
+{
+    ASSERT(out);
+    unsigned end;
+    return out->parseTime(characters, length, 0, end) && end == length;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/TimeInputType.h b/WebCore/html/TimeInputType.h
index 9530f7d..5f1256d 100644
--- a/WebCore/html/TimeInputType.h
+++ b/WebCore/html/TimeInputType.h
@@ -31,17 +31,18 @@
 #ifndef TimeInputType_h
 #define TimeInputType_h
 
-#include "TextFieldInputType.h"
+#include "BaseDateAndTimeInputType.h"
 
 namespace WebCore {
 
-class TimeInputType : public TextFieldInputType {
+class TimeInputType : public BaseDateAndTimeInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    TimeInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
+    TimeInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/WeekInputType.cpp b/WebCore/html/WeekInputType.cpp
index 0b4ab30..1bdabe0 100644
--- a/WebCore/html/WeekInputType.cpp
+++ b/WebCore/html/WeekInputType.cpp
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "WeekInputType.h"
 
+#include "DateComponents.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -45,4 +46,11 @@ const AtomicString& WeekInputType::formControlType() const
     return InputTypeNames::week();
 }
 
+bool WeekInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const
+{
+    ASSERT(out);
+    unsigned end;
+    return out->parseWeek(characters, length, 0, end) && end == length;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/WeekInputType.h b/WebCore/html/WeekInputType.h
index 7b6ee23..a190ca8 100644
--- a/WebCore/html/WeekInputType.h
+++ b/WebCore/html/WeekInputType.h
@@ -31,17 +31,18 @@
 #ifndef WeekInputType_h
 #define WeekInputType_h
 
-#include "TextFieldInputType.h"
+#include "BaseDateAndTimeInputType.h"
 
 namespace WebCore {
 
-class WeekInputType : public TextFieldInputType {
+class WeekInputType : public BaseDateAndTimeInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    WeekInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
+    WeekInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const;
 };
 
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list