[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:57:25 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 61684f1a9d16e55714c6eddaf371a3478d273be4
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 26 02:27:22 2010 +0000

    2010-10-25  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            Refactor HTMLInputElement: Move createRender(), appendFormData(),
            saveFormControlState() and restoreFormControlState() to InputTypes.
            https://bugs.webkit.org/show_bug.cgi?id=47834
    
            This change adds BaseButtonInputType and BaseCheckableInputType. They
            are super classes of some concrete InputType classes.
    
            No new tests. Just a code refactoring.
    
            * CMakeLists.txt: Add BaseButtonInputType and BaseCheckableInputType files.
            * GNUmakefile.am: ditto.
            * WebCore.gypi: ditto.
            * WebCore.pro: ditto.
            * WebCore.vcproj/WebCore.vcproj: ditto.
            * WebCore.xcodeproj/project.pbxproj: ditto.
            * html/BaseButtonInputType.cpp: Added.
            (WebCore::BaseButtonInputType::appendFormData):
            (WebCore::BaseButtonInputType::createRenderer):
            * html/BaseButtonInputType.h: Added.
            (WebCore::BaseButtonInputType::BaseButtonInputType):
            * html/BaseCheckableInputType.cpp: Added.
            (WebCore::BaseCheckableInputType::saveFormControlState):
            (WebCore::BaseCheckableInputType::restoreFormControlState):
            (WebCore::BaseCheckableInputType::appendFormData):
            * html/BaseCheckableInputType.h: Added.
            (WebCore::BaseCheckableInputType::BaseCheckableInputType):
            * html/ButtonInputType.h: Change the super class.
            (WebCore::ButtonInputType::ButtonInputType):
            * html/CheckboxInputType.h: Change the super class.
            (WebCore::CheckboxInputType::CheckboxInputType):
            * html/FileInputType.cpp:
            (WebCore::FileInputType::appendFormData):
            (WebCore::FileInputType::createRenderer):
            * html/FileInputType.h: Change the super class.
            (WebCore::FileInputType::FileInputType):
            * html/HTMLFormControlElement.h:
              Make placeholderShouldBeVisible() public for access from TextFieldInputType.
            * html/HTMLInputElement.cpp:
            (WebCore::HTMLInputElement::saveFormControlState):
            (WebCore::HTMLInputElement::restoreFormControlState):
            (WebCore::HTMLInputElement::createRenderer):
            (WebCore::HTMLInputElement::appendFormData):
            * html/HTMLInputElement.h:
              Add the following functions for ImageInputType and SubmitInputType.
            (WebCore::HTMLInputElement::xPosition):
            (WebCore::HTMLInputElement::yPosition):
            * html/HiddenInputType.cpp:
            (WebCore::HiddenInputType::createRenderer):
            * html/HiddenInputType.h:
            * html/ImageInputType.cpp:
            (WebCore::ImageInputType::isFormDataAppendable):
            (WebCore::ImageInputType::appendFormData):
            (WebCore::ImageInputType::createRenderer):
            * html/ImageInputType.h: Change the super class.
            (WebCore::ImageInputType::ImageInputType):
            * html/InputType.cpp:
            (WebCore::InputType::saveFormControlState):
            (WebCore::InputType::restoreFormControlState):
            (WebCore::InputType::isFormDataAppendable):
            (WebCore::InputType::appendFormData):
            (WebCore::InputType::createRenderer):
            * html/InputType.h:
            * html/PasswordInputType.cpp:
            (WebCore::PasswordInputType::saveFormControlState):
            (WebCore::PasswordInputType::restoreFormControlState):
            * html/PasswordInputType.h:
            * html/RadioInputType.h: Change the super class.
            (WebCore::RadioInputType::RadioInputType):
            * html/RangeInputType.cpp:
            (WebCore::RangeInputType::createRenderer):
            * html/RangeInputType.h:
            * html/ResetInputType.h:
            (WebCore::ResetInputType::ResetInputType):
            * html/SubmitInputType.cpp:
            (WebCore::SubmitInputType::appendFormData):
            * html/SubmitInputType.h: Change the super class.
            (WebCore::SubmitInputType::SubmitInputType):
            * html/TextFieldInputType.cpp:
            (WebCore::TextFieldInputType::createRenderer):
            * html/TextFieldInputType.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70511 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 42e344a..58b0720 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -949,6 +949,8 @@ SET(WebCore_SOURCES
     history/PageCache.cpp
 
     html/AsyncImageResizer.cpp
+    html/BaseButtonInputType.cpp
+    html/BaseCheckableInputType.cpp
     html/BaseDateAndTimeInputType.cpp
     html/BaseTextInputType.cpp
     html/ButtonInputType.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ac8fd2d..f2594be 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,88 @@
+2010-10-25  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Refactor HTMLInputElement: Move createRender(), appendFormData(),
+        saveFormControlState() and restoreFormControlState() to InputTypes.
+        https://bugs.webkit.org/show_bug.cgi?id=47834
+
+        This change adds BaseButtonInputType and BaseCheckableInputType. They
+        are super classes of some concrete InputType classes.
+
+        No new tests. Just a code refactoring.
+
+        * CMakeLists.txt: Add BaseButtonInputType and BaseCheckableInputType files.
+        * GNUmakefile.am: ditto.
+        * WebCore.gypi: ditto.
+        * WebCore.pro: ditto.
+        * WebCore.vcproj/WebCore.vcproj: ditto.
+        * WebCore.xcodeproj/project.pbxproj: ditto.
+        * html/BaseButtonInputType.cpp: Added.
+        (WebCore::BaseButtonInputType::appendFormData):
+        (WebCore::BaseButtonInputType::createRenderer):
+        * html/BaseButtonInputType.h: Added.
+        (WebCore::BaseButtonInputType::BaseButtonInputType):
+        * html/BaseCheckableInputType.cpp: Added.
+        (WebCore::BaseCheckableInputType::saveFormControlState):
+        (WebCore::BaseCheckableInputType::restoreFormControlState):
+        (WebCore::BaseCheckableInputType::appendFormData):
+        * html/BaseCheckableInputType.h: Added.
+        (WebCore::BaseCheckableInputType::BaseCheckableInputType):
+        * html/ButtonInputType.h: Change the super class.
+        (WebCore::ButtonInputType::ButtonInputType):
+        * html/CheckboxInputType.h: Change the super class.
+        (WebCore::CheckboxInputType::CheckboxInputType):
+        * html/FileInputType.cpp:
+        (WebCore::FileInputType::appendFormData):
+        (WebCore::FileInputType::createRenderer):
+        * html/FileInputType.h: Change the super class.
+        (WebCore::FileInputType::FileInputType):
+        * html/HTMLFormControlElement.h:
+          Make placeholderShouldBeVisible() public for access from TextFieldInputType.
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::saveFormControlState):
+        (WebCore::HTMLInputElement::restoreFormControlState):
+        (WebCore::HTMLInputElement::createRenderer):
+        (WebCore::HTMLInputElement::appendFormData):
+        * html/HTMLInputElement.h:
+          Add the following functions for ImageInputType and SubmitInputType.
+        (WebCore::HTMLInputElement::xPosition):
+        (WebCore::HTMLInputElement::yPosition):
+        * html/HiddenInputType.cpp:
+        (WebCore::HiddenInputType::createRenderer):
+        * html/HiddenInputType.h:
+        * html/ImageInputType.cpp:
+        (WebCore::ImageInputType::isFormDataAppendable):
+        (WebCore::ImageInputType::appendFormData):
+        (WebCore::ImageInputType::createRenderer):
+        * html/ImageInputType.h: Change the super class.
+        (WebCore::ImageInputType::ImageInputType):
+        * html/InputType.cpp:
+        (WebCore::InputType::saveFormControlState):
+        (WebCore::InputType::restoreFormControlState):
+        (WebCore::InputType::isFormDataAppendable):
+        (WebCore::InputType::appendFormData):
+        (WebCore::InputType::createRenderer):
+        * html/InputType.h:
+        * html/PasswordInputType.cpp:
+        (WebCore::PasswordInputType::saveFormControlState):
+        (WebCore::PasswordInputType::restoreFormControlState):
+        * html/PasswordInputType.h:
+        * html/RadioInputType.h: Change the super class.
+        (WebCore::RadioInputType::RadioInputType):
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::createRenderer):
+        * html/RangeInputType.h:
+        * html/ResetInputType.h:
+        (WebCore::ResetInputType::ResetInputType):
+        * html/SubmitInputType.cpp:
+        (WebCore::SubmitInputType::appendFormData):
+        * html/SubmitInputType.h: Change the super class.
+        (WebCore::SubmitInputType::SubmitInputType):
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::createRenderer):
+        * html/TextFieldInputType.h:
+
 2010-10-25  Simon Fraser  <simon.fraser at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index c6e3978..8c204aa 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1453,6 +1453,10 @@ webcore_sources += \
 	WebCore/history/PageCache.h \
 	WebCore/html/AsyncImageResizer.cpp \
 	WebCore/html/AsyncImageResizer.h \
+	WebCore/html/BaseButtonInputType.cpp \
+	WebCore/html/BaseButtonInputType.h \
+	WebCore/html/BaseCheckableInputType.cpp \
+	WebCore/html/BaseCheckableInputType.h \
 	WebCore/html/BaseDateAndTimeInputType.cpp \
 	WebCore/html/BaseDateAndTimeInputType.h \
 	WebCore/html/BaseTextInputType.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index fba1c33..1b8cabe 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1543,6 +1543,10 @@
             'history/PageCache.h',
             'html/AsyncImageResizer.cpp',
             'html/AsyncImageResizer.h',
+            'html/BaseButtonInputType.cpp',
+            'html/BaseButtonInputType.h',
+            'html/BaseCheckableInputType.cpp',
+            'html/BaseCheckableInputType.h',
             'html/BaseDateAndTimeInputType.cpp',
             'html/BaseDateAndTimeInputType.h',
             'html/BaseTextInputType.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 84869b4..9fb2fdd 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -839,6 +839,8 @@ SOURCES += \
     history/qt/HistoryItemQt.cpp \
     history/PageCache.cpp \
     html/AsyncImageResizer.cpp \
+    html/BaseButtonInputType.cpp \
+    html/BaseCheckableInputType.cpp \
     html/BaseDateAndTimeInputType.cpp \
     html/BaseTextInputType.cpp \
     html/ButtonInputType.cpp \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index c700074..dc7d2d0 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -48007,6 +48007,22 @@
 				>
 			</File>
 			<File
+				RelativePath="..\html\BaseButtonInputType.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\html\BaseButtonInputType.h"
+				>
+			</File>
+			<File
+				RelativePath="..\html\BaseCheckableInputType.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\html\BaseCheckableInputType.h"
+				>
+			</File>
+			<File
 				RelativePath="..\html\BaseDateAndTimeInputType.cpp"
 				>
 			</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 0cbd7f0..336c786 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -857,6 +857,10 @@
 		379919961200DDF400EA041C /* WOFFFileFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379919941200DDF400EA041C /* WOFFFileFormat.cpp */; };
 		379919971200DDF400EA041C /* WOFFFileFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 379919951200DDF400EA041C /* WOFFFileFormat.h */; };
 		379919B21200DE5000EA041C /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 379919B11200DE5000EA041C /* libz.dylib */; };
+		379E61C9126CA5C300B63E8D /* BaseButtonInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379E61C5126CA5C300B63E8D /* BaseButtonInputType.cpp */; };
+		379E61CA126CA5C400B63E8D /* BaseButtonInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = 379E61C6126CA5C300B63E8D /* BaseButtonInputType.h */; };
+		379E61CB126CA5C400B63E8D /* BaseCheckableInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379E61C7126CA5C300B63E8D /* BaseCheckableInputType.cpp */; };
+		379E61CC126CA5C400B63E8D /* BaseCheckableInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = 379E61C8126CA5C300B63E8D /* BaseCheckableInputType.h */; };
 		37ACCE420DA2980F0089E602 /* FontRenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 37ACCE410DA2980F0089E602 /* FontRenderingMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		37ACCF690DA414E70089E602 /* FontDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37ACCE620DA2AA960089E602 /* FontDescription.cpp */; };
 		37C2360B1097EDED00EF9F72 /* FontComplexTextMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C2360A1097EDED00EF9F72 /* FontComplexTextMac.cpp */; };
@@ -6900,6 +6904,10 @@
 		379919941200DDF400EA041C /* WOFFFileFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WOFFFileFormat.cpp; sourceTree = "<group>"; };
 		379919951200DDF400EA041C /* WOFFFileFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOFFFileFormat.h; sourceTree = "<group>"; };
 		379919B11200DE5000EA041C /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = "<absolute>"; };
+		379E61C5126CA5C300B63E8D /* BaseButtonInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseButtonInputType.cpp; sourceTree = "<group>"; };
+		379E61C6126CA5C300B63E8D /* BaseButtonInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseButtonInputType.h; sourceTree = "<group>"; };
+		379E61C7126CA5C300B63E8D /* BaseCheckableInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseCheckableInputType.cpp; sourceTree = "<group>"; };
+		379E61C8126CA5C300B63E8D /* BaseCheckableInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseCheckableInputType.h; sourceTree = "<group>"; };
 		37ACCE410DA2980F0089E602 /* FontRenderingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontRenderingMode.h; sourceTree = "<group>"; };
 		37ACCE620DA2AA960089E602 /* FontDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontDescription.cpp; sourceTree = "<group>"; };
 		37C2360A1097EDED00EF9F72 /* FontComplexTextMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontComplexTextMac.cpp; sourceTree = "<group>"; };
@@ -14567,6 +14575,10 @@
 				97C1F5511228558800EDE616 /* parser */,
 				B0149E7911A4B21500196A7B /* AsyncImageResizer.cpp */,
 				B0149E7A11A4B21500196A7B /* AsyncImageResizer.h */,
+				379E61C5126CA5C300B63E8D /* BaseButtonInputType.cpp */,
+				379E61C6126CA5C300B63E8D /* BaseButtonInputType.h */,
+				379E61C7126CA5C300B63E8D /* BaseCheckableInputType.cpp */,
+				379E61C8126CA5C300B63E8D /* BaseCheckableInputType.h */,
 				F59C95FD1255B23F000623C0 /* BaseDateAndTimeInputType.cpp */,
 				F59C95FE1255B23F000623C0 /* BaseDateAndTimeInputType.h */,
 				F55B3D791251F12D003EF269 /* BaseTextInputType.cpp */,
@@ -18392,6 +18404,8 @@
 				BCA8CA6011E4E6D100812FB7 /* BackForwardListImpl.h in Headers */,
 				BC124EE80C2641CD009E2349 /* BarInfo.h in Headers */,
 				B2C3DA220D006C1D00EF6F26 /* Base64.h in Headers */,
+				379E61CA126CA5C400B63E8D /* BaseButtonInputType.h in Headers */,
+				379E61CC126CA5C400B63E8D /* BaseCheckableInputType.h in Headers */,
 				F59C96001255B23F000623C0 /* BaseDateAndTimeInputType.h in Headers */,
 				F55B3DAE1251F12D003EF269 /* BaseTextInputType.h in Headers */,
 				BC9462D8107A7B4C00857193 /* BeforeLoadEvent.h in Headers */,
@@ -21523,6 +21537,8 @@
 				BCA8CA5F11E4E6D100812FB7 /* BackForwardListImpl.cpp in Sources */,
 				BC124EE70C2641CD009E2349 /* BarInfo.cpp in Sources */,
 				B2C3DA210D006C1D00EF6F26 /* Base64.cpp in Sources */,
+				379E61C9126CA5C300B63E8D /* BaseButtonInputType.cpp in Sources */,
+				379E61CB126CA5C400B63E8D /* BaseCheckableInputType.cpp in Sources */,
 				F59C95FF1255B23F000623C0 /* BaseDateAndTimeInputType.cpp in Sources */,
 				F55B3DAD1251F12D003EF269 /* BaseTextInputType.cpp in Sources */,
 				5172204B11D2960500638B42 /* BeforeProcessEvent.cpp in Sources */,
diff --git a/WebCore/html/BaseButtonInputType.cpp b/WebCore/html/BaseButtonInputType.cpp
new file mode 100644
index 0000000..fd6a8ff
--- /dev/null
+++ b/WebCore/html/BaseButtonInputType.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "BaseButtonInputType.h"
+
+#include "HTMLInputElement.h"
+#include "RenderButton.h"
+
+namespace WebCore {
+
+bool BaseButtonInputType::appendFormData(FormDataList&, bool) const
+{
+    // Buttons except overridden types are never successful.
+    return false;
+}
+
+RenderObject* BaseButtonInputType::createRenderer(RenderArena* arena, RenderStyle*) const
+{
+    return new (arena) RenderButton(element());
+}
+
+} // namespace WebCore
diff --git a/WebCore/html/BaseButtonInputType.h b/WebCore/html/BaseButtonInputType.h
new file mode 100644
index 0000000..e7f683b
--- /dev/null
+++ b/WebCore/html/BaseButtonInputType.h
@@ -0,0 +1,50 @@
+/*
+ * 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 BaseButtonInputType_h
+#define BaseButtonInputType_h
+
+#include "InputType.h"
+
+namespace WebCore {
+
+// Base of button, file, image, reset, and submit types.
+class BaseButtonInputType : public InputType {
+protected:
+    BaseButtonInputType(HTMLInputElement* element) : InputType(element) { }
+
+private:
+    virtual bool appendFormData(FormDataList&, bool) const;
+    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
+};
+
+} // namespace WebCore
+
+#endif // BaseButtonInputType_h
diff --git a/WebCore/html/BaseCheckableInputType.cpp b/WebCore/html/BaseCheckableInputType.cpp
new file mode 100644
index 0000000..009e8e4
--- /dev/null
+++ b/WebCore/html/BaseCheckableInputType.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 "BaseCheckableInputType.h"
+
+#include "FormDataList.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "RegularExpression.h"
+
+namespace WebCore {
+
+bool BaseCheckableInputType::saveFormControlState(String& result) const
+{
+    result = element()->checked() ? "on" : "off";
+    return true;
+}
+
+void BaseCheckableInputType::restoreFormControlState(const String& state) const
+{
+    element()->setChecked(state == "on");
+}
+
+bool BaseCheckableInputType::appendFormData(FormDataList& encoding, bool) const
+{
+    if (!element()->checked())
+        return false;
+    encoding.appendData(element()->name(), element()->value());
+    return true;
+}
+
+} // namespace WebCore
diff --git a/WebCore/html/BaseCheckableInputType.h b/WebCore/html/BaseCheckableInputType.h
new file mode 100644
index 0000000..02edf29
--- /dev/null
+++ b/WebCore/html/BaseCheckableInputType.h
@@ -0,0 +1,51 @@
+/*
+ * 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 BaseCheckableInputType_h
+#define BaseCheckableInputType_h
+
+#include "InputType.h"
+
+namespace WebCore {
+
+// Base of checkbox and radio types.
+class BaseCheckableInputType : public InputType {
+protected:
+    BaseCheckableInputType(HTMLInputElement* element) : InputType(element) { }
+
+private:
+    virtual bool saveFormControlState(String&) const;
+    virtual void restoreFormControlState(const String&) const;
+    virtual bool appendFormData(FormDataList&, bool) const;
+};
+
+} // namespace WebCore
+
+#endif // BaseCheckableInputType_h
diff --git a/WebCore/html/ButtonInputType.h b/WebCore/html/ButtonInputType.h
index 7efbad2..f016114 100644
--- a/WebCore/html/ButtonInputType.h
+++ b/WebCore/html/ButtonInputType.h
@@ -31,16 +31,16 @@
 #ifndef ButtonInputType_h
 #define ButtonInputType_h
 
-#include "InputType.h"
+#include "BaseButtonInputType.h"
 
 namespace WebCore {
 
-class ButtonInputType : public InputType {
+class ButtonInputType : public BaseButtonInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    ButtonInputType(HTMLInputElement* element) : InputType(element) { }
+    ButtonInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
     virtual const AtomicString& formControlType() const;
     virtual bool supportsValidation() const;
 };
diff --git a/WebCore/html/CheckboxInputType.h b/WebCore/html/CheckboxInputType.h
index e041a07..b68e14d 100644
--- a/WebCore/html/CheckboxInputType.h
+++ b/WebCore/html/CheckboxInputType.h
@@ -31,16 +31,16 @@
 #ifndef CheckboxInputType_h
 #define CheckboxInputType_h
 
-#include "InputType.h"
+#include "BaseCheckableInputType.h"
 
 namespace WebCore {
 
-class CheckboxInputType : public InputType {
+class CheckboxInputType : public BaseCheckableInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    CheckboxInputType(HTMLInputElement* element) : InputType(element) { }
+    CheckboxInputType(HTMLInputElement* element) : BaseCheckableInputType(element) { }
     virtual const AtomicString& formControlType() const;
     virtual bool valueMissing(const String&) const;
 };
diff --git a/WebCore/html/FileInputType.cpp b/WebCore/html/FileInputType.cpp
index 6cb17f2..d98d3b6 100644
--- a/WebCore/html/FileInputType.cpp
+++ b/WebCore/html/FileInputType.cpp
@@ -1,36 +1,32 @@
 /*
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  * 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:
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
  *
- *     * 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 library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  *
- * 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 "FileInputType.h"
 
+#include "File.h"
+#include "FileList.h"
+#include "FormDataList.h"
+#include "HTMLInputElement.h"
+#include "RenderFileUploadControl.h"
 #include <wtf/PassOwnPtr.h>
 #include <wtf/text/WTFString.h>
 
@@ -46,9 +42,43 @@ const AtomicString& FileInputType::formControlType() const
     return InputTypeNames::file();
 }
 
+bool FileInputType::appendFormData(FormDataList& encoding, bool multipart) const
+{
+    FileList* fileList = element()->files();
+    unsigned numFiles = fileList->length();
+    if (!multipart) {
+        // Send only the basenames.
+        // 4.10.16.4 and 4.10.16.6 sections in HTML5.
+
+        // Unlike the multipart case, we have no special handling for the empty
+        // fileList because Netscape doesn't support for non-multipart
+        // submission of file inputs, and Firefox doesn't add "name=" query
+        // parameter.
+        for (unsigned i = 0; i < numFiles; ++i)
+            encoding.appendData(element()->name(), fileList->item(i)->fileName());
+        return true;
+    }
+
+    // If no filename at all is entered, return successful but empty.
+    // Null would be more logical, but Netscape posts an empty file. Argh.
+    if (!numFiles) {
+        encoding.appendBlob(element()->name(), File::create(""));
+        return true;
+    }
+
+    for (unsigned i = 0; i < numFiles; ++i)
+        encoding.appendBlob(element()->name(), fileList->item(i));
+    return true;
+}
+
 bool FileInputType::valueMissing(const String& value) const
 {
     return value.isEmpty();
 }
 
+RenderObject* FileInputType::createRenderer(RenderArena* arena, RenderStyle*) const
+{
+    return new (arena) RenderFileUploadControl(element());
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/FileInputType.h b/WebCore/html/FileInputType.h
index 2cbfe67..24430fb 100644
--- a/WebCore/html/FileInputType.h
+++ b/WebCore/html/FileInputType.h
@@ -31,18 +31,20 @@
 #ifndef FileInputType_h
 #define FileInputType_h
 
-#include "InputType.h"
+#include "BaseButtonInputType.h"
 
 namespace WebCore {
 
-class FileInputType : public InputType {
+class FileInputType : public BaseButtonInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    FileInputType(HTMLInputElement* element) : InputType(element) { }
+    FileInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual bool appendFormData(FormDataList&, bool) const;
     virtual bool valueMissing(const String&) const;
+    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/HTMLFormControlElement.h b/WebCore/html/HTMLFormControlElement.h
index 4792dba..8b721d8 100644
--- a/WebCore/html/HTMLFormControlElement.h
+++ b/WebCore/html/HTMLFormControlElement.h
@@ -180,6 +180,7 @@ public:
     // The derived class should return true if placeholder processing is needed.
     virtual bool supportsPlaceholder() const = 0;
     String strippedPlaceholder() const;
+    bool placeholderShouldBeVisible() const;
 
     int selectionStart();
     int selectionEnd();
@@ -192,7 +193,6 @@ public:
 protected:
     HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*);
 
-    bool placeholderShouldBeVisible() const;
     void updatePlaceholderVisibility(bool);
 
     virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index 378dde4..2ff8ec5 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -56,11 +56,9 @@
 #include "LocalizedStrings.h"
 #include "MouseEvent.h"
 #include "Page.h"
-#include "RenderButton.h"
 #include "RenderFileUploadControl.h"
 #include "RenderImage.h"
 #include "RenderSlider.h"
-#include "RenderText.h"
 #include "RenderTextControlSingleLine.h"
 #include "RenderTheme.h"
 #include "ScriptEventListener.h"
@@ -529,79 +527,12 @@ const AtomicString& HTMLInputElement::formControlType() const
 
 bool HTMLInputElement::saveFormControlState(String& result) const
 {
-    switch (deprecatedInputType()) {
-    case BUTTON:
-    case COLOR:
-    case DATE:
-    case DATETIME:
-    case DATETIMELOCAL:
-    case EMAIL:
-    case FILE:
-    case HIDDEN:
-    case IMAGE:
-    case ISINDEX:
-    case MONTH:
-    case NUMBER:
-    case RANGE:
-    case RESET:
-    case SEARCH:
-    case SUBMIT:
-    case TELEPHONE:
-    case TEXT:
-    case TIME:
-    case URL:
-    case WEEK: {
-        String currentValue = value();
-        if (currentValue == defaultValue())
-            return false;
-        result = currentValue;
-        return true;
-    }
-    case CHECKBOX:
-    case RADIO:
-        result = checked() ? "on" : "off";
-        return true;
-    case PASSWORD:
-        return false;
-    }
-    ASSERT_NOT_REACHED();
-    return false;
+    return m_inputType->saveFormControlState(result);
 }
 
 void HTMLInputElement::restoreFormControlState(const String& state)
 {
-    ASSERT(deprecatedInputType() != PASSWORD); // should never save/restore password fields
-    switch (deprecatedInputType()) {
-    case BUTTON:
-    case COLOR:
-    case DATE:
-    case DATETIME:
-    case DATETIMELOCAL:
-    case EMAIL:
-    case FILE:
-    case HIDDEN:
-    case IMAGE:
-    case ISINDEX:
-    case MONTH:
-    case NUMBER:
-    case RANGE:
-    case RESET:
-    case SEARCH:
-    case SUBMIT:
-    case TELEPHONE:
-    case TEXT:
-    case TIME:
-    case URL:
-    case WEEK:
-        setValue(state);
-        break;
-    case CHECKBOX:
-    case RADIO:
-        setChecked(state == "on");
-        break;
-    case PASSWORD:
-        break;
-    }
+    m_inputType->restoreFormControlState(state);
 }
 
 bool HTMLInputElement::canStartSelection() const
@@ -796,46 +727,9 @@ bool HTMLInputElement::rendererIsNeeded(RenderStyle *style)
     return HTMLFormControlElementWithState::rendererIsNeeded(style);
 }
 
-RenderObject* HTMLInputElement::createRenderer(RenderArena *arena, RenderStyle *style)
+RenderObject* HTMLInputElement::createRenderer(RenderArena* arena, RenderStyle* style)
 {
-    switch (deprecatedInputType()) {
-    case BUTTON:
-    case RESET:
-    case SUBMIT:
-        return new (arena) RenderButton(this);
-    case CHECKBOX:
-    case RADIO:
-        return RenderObject::createObject(this, style);
-    case FILE:
-        return new (arena) RenderFileUploadControl(this);
-    case HIDDEN:
-        break;
-    case IMAGE: {
-        RenderImage* image = new (arena) RenderImage(this);
-        image->setImageResource(RenderImageResource::create());
-        return image;
-    }
-    case RANGE:
-        return new (arena) RenderSlider(this);
-    case COLOR:
-    case DATE:
-    case DATETIME:
-    case DATETIMELOCAL:
-    case EMAIL:
-    case ISINDEX:
-    case MONTH:
-    case NUMBER:
-    case PASSWORD:
-    case SEARCH:
-    case TELEPHONE:
-    case TEXT:
-    case TIME:
-    case URL:
-    case WEEK:
-        return new (arena) RenderTextControlSingleLine(this, placeholderShouldBeVisible());
-    }
-    ASSERT(false);
-    return 0;
+    return m_inputType->createRenderer(arena, style);
 }
 
 void HTMLInputElement::attach()
@@ -912,93 +806,7 @@ void HTMLInputElement::setActivatedSubmit(bool flag)
 
 bool HTMLInputElement::appendFormData(FormDataList& encoding, bool multipart)
 {
-    // image generates its own names, but for other types there is no form data unless there's a name
-    if (name().isEmpty() && deprecatedInputType() != IMAGE)
-        return false;
-
-    switch (deprecatedInputType()) {
-    case COLOR:
-    case DATE:
-    case DATETIME:
-    case DATETIMELOCAL:
-    case EMAIL:
-    case HIDDEN:
-    case ISINDEX:
-    case MONTH:
-    case NUMBER:
-    case PASSWORD:
-    case RANGE:
-    case SEARCH:
-    case TELEPHONE:
-    case TEXT:
-    case TIME:
-    case URL:
-    case WEEK:
-        // always successful
-        encoding.appendData(name(), value());
-        return true;
-
-    case CHECKBOX:
-    case RADIO:
-        if (checked()) {
-            encoding.appendData(name(), value());
-            return true;
-        }
-        break;
-
-    case BUTTON:
-    case RESET:
-        // these types of buttons are never successful
-        return false;
-
-    case IMAGE:
-        if (m_activeSubmit) {
-            encoding.appendData(name().isEmpty() ? "x" : (name() + ".x"), m_xPos);
-            encoding.appendData(name().isEmpty() ? "y" : (name() + ".y"), m_yPos);
-            if (!name().isEmpty() && !value().isEmpty())
-                encoding.appendData(name(), value());
-            return true;
-        }
-        break;
-
-    case SUBMIT:
-        if (m_activeSubmit) {
-            String encstr = valueWithDefault();
-            encoding.appendData(name(), encstr);
-            return true;
-        }
-        break;
-
-    case FILE: {
-        unsigned numFiles = m_fileList->length();
-        if (!multipart) {
-            // Send only the basenames.
-            // 4.10.16.4 and 4.10.16.6 sections in HTML5.
-    
-            // Unlike the multipart case, we have no special
-            // handling for the empty fileList because Netscape
-            // doesn't support for non-multipart submission of
-            // file inputs, and Firefox doesn't add "name=" query
-            // parameter.
-
-            for (unsigned i = 0; i < numFiles; ++i) 
-                encoding.appendData(name(), m_fileList->item(i)->fileName());
-            return true;
-        }
-
-        // If no filename at all is entered, return successful but empty.
-        // Null would be more logical, but Netscape posts an empty file. Argh.
-        if (!numFiles) {
-            encoding.appendBlob(name(), File::create(""));
-            return true;
-        }
-
-        for (unsigned i = 0; i < numFiles; ++i)
-            encoding.appendBlob(name(), m_fileList->item(i));
-        return true;
-        }
-    }
-    return false;
+    return m_inputType->isFormDataAppendable() && m_inputType->appendFormData(encoding, multipart);
 }
 
 void HTMLInputElement::reset()
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index e584a78..1a0490e 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -203,6 +203,10 @@ public:
         return document()->checkedRadioButtons();
     }
 
+    // FIXME: We should move m_xPos and m_yPos to ImageInputType class.
+    int xPosition() const { return m_xPos; }
+    int yPosition() const { return m_yPos; }
+
 protected:
     HTMLInputElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
 
diff --git a/WebCore/html/HiddenInputType.cpp b/WebCore/html/HiddenInputType.cpp
index 76742ae..6e083e6 100644
--- a/WebCore/html/HiddenInputType.cpp
+++ b/WebCore/html/HiddenInputType.cpp
@@ -49,4 +49,10 @@ bool HiddenInputType::supportsValidation() const
     return false;
 }
 
+RenderObject* HiddenInputType::createRenderer(RenderArena*, RenderStyle*) const
+{
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/HiddenInputType.h b/WebCore/html/HiddenInputType.h
index cc49f98..1617371 100644
--- a/WebCore/html/HiddenInputType.h
+++ b/WebCore/html/HiddenInputType.h
@@ -43,6 +43,7 @@ private:
     HiddenInputType(HTMLInputElement* element) : InputType(element) { }
     virtual const AtomicString& formControlType() const;
     virtual bool supportsValidation() const;
+    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/ImageInputType.cpp b/WebCore/html/ImageInputType.cpp
index 604b052..de24188 100644
--- a/WebCore/html/ImageInputType.cpp
+++ b/WebCore/html/ImageInputType.cpp
@@ -1,36 +1,30 @@
 /*
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  * 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:
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
  *
- *     * 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 library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  *
- * 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 "ImageInputType.h"
 
+#include "FormDataList.h"
+#include "HTMLInputElement.h"
+#include "RenderImage.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -45,9 +39,33 @@ const AtomicString& ImageInputType::formControlType() const
     return InputTypeNames::image();
 }
 
+bool ImageInputType::isFormDataAppendable() const
+{
+    return true;
+}
+
+bool ImageInputType::appendFormData(FormDataList& encoding, bool) const
+{
+    if (!element()->isActivatedSubmit())
+        return false;
+    const AtomicString& name = element()->name();
+    encoding.appendData(name.isEmpty() ? "x" : (name + ".x"), element()->xPosition());
+    encoding.appendData(name.isEmpty() ? "y" : (name + ".y"), element()->yPosition());
+    if (!name.isEmpty() && !element()->value().isEmpty())
+        encoding.appendData(name, element()->value());
+    return true;
+}
+
 bool ImageInputType::supportsValidation() const
 {
     return false;
 }
 
+RenderObject* ImageInputType::createRenderer(RenderArena* arena, RenderStyle*) const
+{
+    RenderImage* image = new (arena) RenderImage(element());
+    image->setImageResource(RenderImageResource::create());
+    return image;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/ImageInputType.h b/WebCore/html/ImageInputType.h
index be308b3..cd76e72 100644
--- a/WebCore/html/ImageInputType.h
+++ b/WebCore/html/ImageInputType.h
@@ -31,18 +31,21 @@
 #ifndef ImageInputType_h
 #define ImageInputType_h
 
-#include "InputType.h"
+#include "BaseButtonInputType.h"
 
 namespace WebCore {
 
-class ImageInputType : public InputType {
+class ImageInputType : public BaseButtonInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    ImageInputType(HTMLInputElement* element) : InputType(element) { }
+    ImageInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual bool isFormDataAppendable() const;
+    virtual bool appendFormData(FormDataList&, bool) const;
     virtual bool supportsValidation() const;
+    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/InputType.cpp b/WebCore/html/InputType.cpp
index 1b2303a..c870c69 100644
--- a/WebCore/html/InputType.cpp
+++ b/WebCore/html/InputType.cpp
@@ -36,6 +36,7 @@
 #include "DateTimeLocalInputType.h"
 #include "EmailInputType.h"
 #include "FileInputType.h"
+#include "FormDataList.h"
 #include "HTMLInputElement.h"
 #include "HiddenInputType.h"
 #include "ImageInputType.h"
@@ -46,6 +47,7 @@
 #include "RadioInputType.h"
 #include "RangeInputType.h"
 #include "RegularExpression.h"
+#include "RenderObject.h"
 #include "ResetInputType.h"
 #include "SearchInputType.h"
 #include "SubmitInputType.h"
@@ -122,6 +124,33 @@ bool InputType::isTextType() const
     return false;
 }
 
+bool InputType::saveFormControlState(String& result) const
+{
+    String currentValue = element()->value();
+    if (currentValue == element()->defaultValue())
+        return false;
+    result = currentValue;
+    return true;
+}
+
+void InputType::restoreFormControlState(const String& state) const
+{
+    element()->setValue(state);
+}
+
+bool InputType::isFormDataAppendable() const
+{
+    // There is no form data unless there's a name for non-image types.
+    return !element()->name().isEmpty();
+}
+
+bool InputType::appendFormData(FormDataList& encoding, bool) const
+{
+    // Always successful.
+    encoding.appendData(element()->name(), element()->value());
+    return true;
+}
+
 double InputType::valueAsDate() const
 {
     return DateComponents::invalidMilliseconds();
@@ -228,6 +257,11 @@ bool InputType::scaledStepValeuShouldBeInteger() const
     return false;
 }
 
+RenderObject* InputType::createRenderer(RenderArena*, RenderStyle* style) const
+{
+    return RenderObject::createObject(element(), style);
+}
+
 double InputType::parseToDouble(const String&, double defaultValue) const
 {
     return defaultValue;
diff --git a/WebCore/html/InputType.h b/WebCore/html/InputType.h
index 953b123..f601051 100644
--- a/WebCore/html/InputType.h
+++ b/WebCore/html/InputType.h
@@ -38,24 +38,42 @@
 namespace WebCore {
 
 class DateComponents;
+class FormDataList;
 class HTMLInputElement;
+class RenderArena;
+class RenderObject;
+class RenderStyle;
 
+// An InputType object represents the type-specific part of an HTMLInputElement.
+// Do not expose instances of InputType and classes derived from it to classes
+// other than HTMLInputElement.
 class InputType : public Noncopyable {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*, const AtomicString&);
     static PassOwnPtr<InputType> createText(HTMLInputElement*);
     virtual ~InputType();
 
+    // Type query functions
+
     virtual bool isTextField() const;
     virtual bool isTextType() const;
     virtual const AtomicString& formControlType() const = 0;
 
+    // Form value functions
+
+    virtual bool saveFormControlState(String&) const;
+    virtual void restoreFormControlState(const String&) const;
+    virtual bool isFormDataAppendable() const;
+    virtual bool appendFormData(FormDataList&, bool multipart) const;
+
+    // DOM property functions
+
     virtual double valueAsDate() const;
     virtual void setValueAsDate(double, ExceptionCode&) const;
     virtual double valueAsNumber() const;
     virtual void setValueAsNumber(double, ExceptionCode&) const;
 
-    // Validation-related functions
+    // Validation functions
 
     virtual bool supportsValidation() const;
     virtual bool typeMismatchFor(const String&) const;
@@ -77,6 +95,10 @@ public:
     virtual bool parsedStepValueShouldBeInteger() const;
     virtual bool scaledStepValeuShouldBeInteger() const;
 
+    // Miscellaneous functions
+
+    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) 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
diff --git a/WebCore/html/PasswordInputType.cpp b/WebCore/html/PasswordInputType.cpp
index a645f96..cda689b 100644
--- a/WebCore/html/PasswordInputType.cpp
+++ b/WebCore/html/PasswordInputType.cpp
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "PasswordInputType.h"
 
+#include <wtf/Assertions.h>
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -45,4 +46,16 @@ const AtomicString& PasswordInputType::formControlType() const
     return InputTypeNames::password();
 }
 
+bool PasswordInputType::saveFormControlState(String&) const
+{
+    // Should never save/restore password fields.
+    return false;
+}
+
+void PasswordInputType::restoreFormControlState(const String&) const
+{
+    // Should never save/restore password fields.
+    ASSERT_NOT_REACHED();
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/PasswordInputType.h b/WebCore/html/PasswordInputType.h
index db13449..cf25525 100644
--- a/WebCore/html/PasswordInputType.h
+++ b/WebCore/html/PasswordInputType.h
@@ -42,6 +42,8 @@ public:
 private:
     PasswordInputType(HTMLInputElement* element) : BaseTextInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual bool saveFormControlState(String&) const;
+    virtual void restoreFormControlState(const String&) const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/RadioInputType.h b/WebCore/html/RadioInputType.h
index 2ff2c41..9e7ab00 100644
--- a/WebCore/html/RadioInputType.h
+++ b/WebCore/html/RadioInputType.h
@@ -31,16 +31,16 @@
 #ifndef RadioInputType_h
 #define RadioInputType_h
 
-#include "InputType.h"
+#include "BaseCheckableInputType.h"
 
 namespace WebCore {
 
-class RadioInputType : public InputType {
+class RadioInputType : public BaseCheckableInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    RadioInputType(HTMLInputElement* element) : InputType(element) { }
+    RadioInputType(HTMLInputElement* element) : BaseCheckableInputType(element) { }
     virtual const AtomicString& formControlType() const;
     virtual bool valueMissing(const String&) const;
 };
diff --git a/WebCore/html/RangeInputType.cpp b/WebCore/html/RangeInputType.cpp
index 7448071..176d73b 100644
--- a/WebCore/html/RangeInputType.cpp
+++ b/WebCore/html/RangeInputType.cpp
@@ -34,6 +34,7 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
+#include "RenderSlider.h"
 #include <limits>
 #include <wtf/MathExtras.h>
 #include <wtf/PassOwnPtr.h>
@@ -126,6 +127,11 @@ double RangeInputType::stepScaleFactor() const
     return rangeStepScaleFactor;
 }
 
+RenderObject* RangeInputType::createRenderer(RenderArena* arena, RenderStyle*) const
+{
+    return new (arena) RenderSlider(element());
+}
+
 double RangeInputType::parseToDouble(const String& src, double defaultValue) const
 {
     double numberValue;
diff --git a/WebCore/html/RangeInputType.h b/WebCore/html/RangeInputType.h
index 0ff6f60..64548f6 100644
--- a/WebCore/html/RangeInputType.h
+++ b/WebCore/html/RangeInputType.h
@@ -53,6 +53,7 @@ private:
     virtual double stepBase() const;
     virtual double defaultStep() const;
     virtual double stepScaleFactor() const;
+    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
     virtual double parseToDouble(const String&, double) const;
     virtual String serialize(double) const;
 };
diff --git a/WebCore/html/ResetInputType.h b/WebCore/html/ResetInputType.h
index 3f883a3..ad940b4 100644
--- a/WebCore/html/ResetInputType.h
+++ b/WebCore/html/ResetInputType.h
@@ -31,16 +31,16 @@
 #ifndef ResetInputType_h
 #define ResetInputType_h
 
-#include "InputType.h"
+#include "BaseButtonInputType.h"
 
 namespace WebCore {
 
-class ResetInputType : public InputType {
+class ResetInputType : public BaseButtonInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    ResetInputType(HTMLInputElement* element) : InputType(element) { }
+    ResetInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
     virtual const AtomicString& formControlType() const;
     virtual bool supportsValidation() const;
 };
diff --git a/WebCore/html/SubmitInputType.cpp b/WebCore/html/SubmitInputType.cpp
index 65934f9..99c808e 100644
--- a/WebCore/html/SubmitInputType.cpp
+++ b/WebCore/html/SubmitInputType.cpp
@@ -31,6 +31,8 @@
 #include "config.h"
 #include "SubmitInputType.h"
 
+#include "FormDataList.h"
+#include "HTMLInputElement.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -45,6 +47,14 @@ const AtomicString& SubmitInputType::formControlType() const
     return InputTypeNames::submit();
 }
 
+bool SubmitInputType::appendFormData(FormDataList& encoding, bool) const
+{
+    if (!element()->isActivatedSubmit())
+        return false;
+    encoding.appendData(element()->name(), element()->valueWithDefault());
+    return true;
+}
+
 bool SubmitInputType::supportsValidation() const
 {
     return false;
diff --git a/WebCore/html/SubmitInputType.h b/WebCore/html/SubmitInputType.h
index 83fa5e5..2fe7ace 100644
--- a/WebCore/html/SubmitInputType.h
+++ b/WebCore/html/SubmitInputType.h
@@ -31,17 +31,18 @@
 #ifndef SubmitInputType_h
 #define SubmitInputType_h
 
-#include "InputType.h"
+#include "BaseButtonInputType.h"
 
 namespace WebCore {
 
-class SubmitInputType : public InputType {
+class SubmitInputType : public BaseButtonInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    SubmitInputType(HTMLInputElement* element) : InputType(element) { }
+    SubmitInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual bool appendFormData(FormDataList&, bool) const;
     virtual bool supportsValidation() const;
 };
 
diff --git a/WebCore/html/TextFieldInputType.cpp b/WebCore/html/TextFieldInputType.cpp
index 82382ef..926d0ac 100644
--- a/WebCore/html/TextFieldInputType.cpp
+++ b/WebCore/html/TextFieldInputType.cpp
@@ -31,6 +31,8 @@
 #include "config.h"
 #include "TextFieldInputType.h"
 
+#include "HTMLInputElement.h"
+#include "RenderTextControlSingleLine.h"
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -45,4 +47,9 @@ bool TextFieldInputType::valueMissing(const String& value) const
     return value.isEmpty();
 }
 
+RenderObject* TextFieldInputType::createRenderer(RenderArena* arena, RenderStyle*) const
+{
+    return new (arena) RenderTextControlSingleLine(element(), element()->placeholderShouldBeVisible());
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/TextFieldInputType.h b/WebCore/html/TextFieldInputType.h
index 9108c42..78bec1d 100644
--- a/WebCore/html/TextFieldInputType.h
+++ b/WebCore/html/TextFieldInputType.h
@@ -42,6 +42,7 @@ protected:
     TextFieldInputType(HTMLInputElement* element) : InputType(element) { }
     virtual bool isTextField() const;
     virtual bool valueMissing(const String&) const;
+    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
 };
 
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list