Commit 61684f1a authored by tkent@chromium.org's avatar tkent@chromium.org

2010-10-25 Kent Tamura <tkent@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
parent 18936ecb
......@@ -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
......
2010-10-25 Kent Tamura <tkent@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@apple.com>
Reviewed by Dan Bernstein.
......@@ -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 \
......
......@@ -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',
......
......@@ -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 \
......
......@@ -48006,6 +48006,22 @@
RelativePath="..\html\AsyncImageResizer.h"
>
</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"
>
......@@ -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 */,
/*
* 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
/*
* 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
/*
* 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
/*
* 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
......@@ -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;
};
......
......@@ -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;
};
......
/*
* 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
......@@ -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
......
......@@ -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*);
......
......@@ -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: {