Changeset 70511 in webkit


Ignore:
Timestamp:
Oct 25, 2010 7:27:22 PM (14 years ago)
Author:
tkent@chromium.org
Message:

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:
Location:
trunk/WebCore
Files:
30 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/CMakeLists.txt

    r70300 r70511  
    950950
    951951    html/AsyncImageResizer.cpp
     952    html/BaseButtonInputType.cpp
     953    html/BaseCheckableInputType.cpp
    952954    html/BaseDateAndTimeInputType.cpp
    953955    html/BaseTextInputType.cpp
  • trunk/WebCore/ChangeLog

    r70509 r70511  
     12010-10-25  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Refactor HTMLInputElement: Move createRender(), appendFormData(),
     6        saveFormControlState() and restoreFormControlState() to InputTypes.
     7        https://bugs.webkit.org/show_bug.cgi?id=47834
     8
     9        This change adds BaseButtonInputType and BaseCheckableInputType. They
     10        are super classes of some concrete InputType classes.
     11
     12        No new tests. Just a code refactoring.
     13
     14        * CMakeLists.txt: Add BaseButtonInputType and BaseCheckableInputType files.
     15        * GNUmakefile.am: ditto.
     16        * WebCore.gypi: ditto.
     17        * WebCore.pro: ditto.
     18        * WebCore.vcproj/WebCore.vcproj: ditto.
     19        * WebCore.xcodeproj/project.pbxproj: ditto.
     20        * html/BaseButtonInputType.cpp: Added.
     21        (WebCore::BaseButtonInputType::appendFormData):
     22        (WebCore::BaseButtonInputType::createRenderer):
     23        * html/BaseButtonInputType.h: Added.
     24        (WebCore::BaseButtonInputType::BaseButtonInputType):
     25        * html/BaseCheckableInputType.cpp: Added.
     26        (WebCore::BaseCheckableInputType::saveFormControlState):
     27        (WebCore::BaseCheckableInputType::restoreFormControlState):
     28        (WebCore::BaseCheckableInputType::appendFormData):
     29        * html/BaseCheckableInputType.h: Added.
     30        (WebCore::BaseCheckableInputType::BaseCheckableInputType):
     31        * html/ButtonInputType.h: Change the super class.
     32        (WebCore::ButtonInputType::ButtonInputType):
     33        * html/CheckboxInputType.h: Change the super class.
     34        (WebCore::CheckboxInputType::CheckboxInputType):
     35        * html/FileInputType.cpp:
     36        (WebCore::FileInputType::appendFormData):
     37        (WebCore::FileInputType::createRenderer):
     38        * html/FileInputType.h: Change the super class.
     39        (WebCore::FileInputType::FileInputType):
     40        * html/HTMLFormControlElement.h:
     41          Make placeholderShouldBeVisible() public for access from TextFieldInputType.
     42        * html/HTMLInputElement.cpp:
     43        (WebCore::HTMLInputElement::saveFormControlState):
     44        (WebCore::HTMLInputElement::restoreFormControlState):
     45        (WebCore::HTMLInputElement::createRenderer):
     46        (WebCore::HTMLInputElement::appendFormData):
     47        * html/HTMLInputElement.h:
     48          Add the following functions for ImageInputType and SubmitInputType.
     49        (WebCore::HTMLInputElement::xPosition):
     50        (WebCore::HTMLInputElement::yPosition):
     51        * html/HiddenInputType.cpp:
     52        (WebCore::HiddenInputType::createRenderer):
     53        * html/HiddenInputType.h:
     54        * html/ImageInputType.cpp:
     55        (WebCore::ImageInputType::isFormDataAppendable):
     56        (WebCore::ImageInputType::appendFormData):
     57        (WebCore::ImageInputType::createRenderer):
     58        * html/ImageInputType.h: Change the super class.
     59        (WebCore::ImageInputType::ImageInputType):
     60        * html/InputType.cpp:
     61        (WebCore::InputType::saveFormControlState):
     62        (WebCore::InputType::restoreFormControlState):
     63        (WebCore::InputType::isFormDataAppendable):
     64        (WebCore::InputType::appendFormData):
     65        (WebCore::InputType::createRenderer):
     66        * html/InputType.h:
     67        * html/PasswordInputType.cpp:
     68        (WebCore::PasswordInputType::saveFormControlState):
     69        (WebCore::PasswordInputType::restoreFormControlState):
     70        * html/PasswordInputType.h:
     71        * html/RadioInputType.h: Change the super class.
     72        (WebCore::RadioInputType::RadioInputType):
     73        * html/RangeInputType.cpp:
     74        (WebCore::RangeInputType::createRenderer):
     75        * html/RangeInputType.h:
     76        * html/ResetInputType.h:
     77        (WebCore::ResetInputType::ResetInputType):
     78        * html/SubmitInputType.cpp:
     79        (WebCore::SubmitInputType::appendFormData):
     80        * html/SubmitInputType.h: Change the super class.
     81        (WebCore::SubmitInputType::SubmitInputType):
     82        * html/TextFieldInputType.cpp:
     83        (WebCore::TextFieldInputType::createRenderer):
     84        * html/TextFieldInputType.h:
     85
    1862010-10-25  Simon Fraser  <simon.fraser@apple.com>
    287
  • trunk/WebCore/GNUmakefile.am

    r70490 r70511  
    14541454        WebCore/html/AsyncImageResizer.cpp \
    14551455        WebCore/html/AsyncImageResizer.h \
     1456        WebCore/html/BaseButtonInputType.cpp \
     1457        WebCore/html/BaseButtonInputType.h \
     1458        WebCore/html/BaseCheckableInputType.cpp \
     1459        WebCore/html/BaseCheckableInputType.h \
    14561460        WebCore/html/BaseDateAndTimeInputType.cpp \
    14571461        WebCore/html/BaseDateAndTimeInputType.h \
  • trunk/WebCore/WebCore.gypi

    r70490 r70511  
    15441544            'html/AsyncImageResizer.cpp',
    15451545            'html/AsyncImageResizer.h',
     1546            'html/BaseButtonInputType.cpp',
     1547            'html/BaseButtonInputType.h',
     1548            'html/BaseCheckableInputType.cpp',
     1549            'html/BaseCheckableInputType.h',
    15461550            'html/BaseDateAndTimeInputType.cpp',
    15471551            'html/BaseDateAndTimeInputType.h',
  • trunk/WebCore/WebCore.pro

    r70490 r70511  
    840840    history/PageCache.cpp \
    841841    html/AsyncImageResizer.cpp \
     842    html/BaseButtonInputType.cpp \
     843    html/BaseCheckableInputType.cpp \
    842844    html/BaseDateAndTimeInputType.cpp \
    843845    html/BaseTextInputType.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r70410 r70511  
    4800848008                        </File>
    4800948009                        <File
     48010                                RelativePath="..\html\BaseButtonInputType.cpp"
     48011                                >
     48012                        </File>
     48013                        <File
     48014                                RelativePath="..\html\BaseButtonInputType.h"
     48015                                >
     48016                        </File>
     48017                        <File
     48018                                RelativePath="..\html\BaseCheckableInputType.cpp"
     48019                                >
     48020                        </File>
     48021                        <File
     48022                                RelativePath="..\html\BaseCheckableInputType.h"
     48023                                >
     48024                        </File>
     48025                        <File
    4801048026                                RelativePath="..\html\BaseDateAndTimeInputType.cpp"
    4801148027                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r70490 r70511  
    858858                379919971200DDF400EA041C /* WOFFFileFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 379919951200DDF400EA041C /* WOFFFileFormat.h */; };
    859859                379919B21200DE5000EA041C /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 379919B11200DE5000EA041C /* libz.dylib */; };
     860                379E61C9126CA5C300B63E8D /* BaseButtonInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379E61C5126CA5C300B63E8D /* BaseButtonInputType.cpp */; };
     861                379E61CA126CA5C400B63E8D /* BaseButtonInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = 379E61C6126CA5C300B63E8D /* BaseButtonInputType.h */; };
     862                379E61CB126CA5C400B63E8D /* BaseCheckableInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379E61C7126CA5C300B63E8D /* BaseCheckableInputType.cpp */; };
     863                379E61CC126CA5C400B63E8D /* BaseCheckableInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = 379E61C8126CA5C300B63E8D /* BaseCheckableInputType.h */; };
    860864                37ACCE420DA2980F0089E602 /* FontRenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 37ACCE410DA2980F0089E602 /* FontRenderingMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    861865                37ACCF690DA414E70089E602 /* FontDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37ACCE620DA2AA960089E602 /* FontDescription.cpp */; };
     
    69016905                379919951200DDF400EA041C /* WOFFFileFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOFFFileFormat.h; sourceTree = "<group>"; };
    69026906                379919B11200DE5000EA041C /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = "<absolute>"; };
     6907                379E61C5126CA5C300B63E8D /* BaseButtonInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseButtonInputType.cpp; sourceTree = "<group>"; };
     6908                379E61C6126CA5C300B63E8D /* BaseButtonInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseButtonInputType.h; sourceTree = "<group>"; };
     6909                379E61C7126CA5C300B63E8D /* BaseCheckableInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseCheckableInputType.cpp; sourceTree = "<group>"; };
     6910                379E61C8126CA5C300B63E8D /* BaseCheckableInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseCheckableInputType.h; sourceTree = "<group>"; };
    69036911                37ACCE410DA2980F0089E602 /* FontRenderingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontRenderingMode.h; sourceTree = "<group>"; };
    69046912                37ACCE620DA2AA960089E602 /* FontDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontDescription.cpp; sourceTree = "<group>"; };
     
    1456814576                                B0149E7911A4B21500196A7B /* AsyncImageResizer.cpp */,
    1456914577                                B0149E7A11A4B21500196A7B /* AsyncImageResizer.h */,
     14578                                379E61C5126CA5C300B63E8D /* BaseButtonInputType.cpp */,
     14579                                379E61C6126CA5C300B63E8D /* BaseButtonInputType.h */,
     14580                                379E61C7126CA5C300B63E8D /* BaseCheckableInputType.cpp */,
     14581                                379E61C8126CA5C300B63E8D /* BaseCheckableInputType.h */,
    1457014582                                F59C95FD1255B23F000623C0 /* BaseDateAndTimeInputType.cpp */,
    1457114583                                F59C95FE1255B23F000623C0 /* BaseDateAndTimeInputType.h */,
     
    1839318405                                BC124EE80C2641CD009E2349 /* BarInfo.h in Headers */,
    1839418406                                B2C3DA220D006C1D00EF6F26 /* Base64.h in Headers */,
     18407                                379E61CA126CA5C400B63E8D /* BaseButtonInputType.h in Headers */,
     18408                                379E61CC126CA5C400B63E8D /* BaseCheckableInputType.h in Headers */,
    1839518409                                F59C96001255B23F000623C0 /* BaseDateAndTimeInputType.h in Headers */,
    1839618410                                F55B3DAE1251F12D003EF269 /* BaseTextInputType.h in Headers */,
     
    2152421538                                BC124EE70C2641CD009E2349 /* BarInfo.cpp in Sources */,
    2152521539                                B2C3DA210D006C1D00EF6F26 /* Base64.cpp in Sources */,
     21540                                379E61C9126CA5C300B63E8D /* BaseButtonInputType.cpp in Sources */,
     21541                                379E61CB126CA5C400B63E8D /* BaseCheckableInputType.cpp in Sources */,
    2152621542                                F59C95FF1255B23F000623C0 /* BaseDateAndTimeInputType.cpp in Sources */,
    2152721543                                F55B3DAD1251F12D003EF269 /* BaseTextInputType.cpp in Sources */,
  • trunk/WebCore/html/BaseButtonInputType.cpp

    r70510 r70511  
    3030
    3131#include "config.h"
    32 #include "ImageInputType.h"
     32#include "BaseButtonInputType.h"
    3333
    34 #include <wtf/PassOwnPtr.h>
     34#include "HTMLInputElement.h"
     35#include "RenderButton.h"
    3536
    3637namespace WebCore {
    3738
    38 PassOwnPtr<InputType> ImageInputType::create(HTMLInputElement* element)
     39bool BaseButtonInputType::appendFormData(FormDataList&, bool) const
    3940{
    40     return adoptPtr(new ImageInputType(element));
    41 }
    42 
    43 const AtomicString& ImageInputType::formControlType() const
    44 {
    45     return InputTypeNames::image();
    46 }
    47 
    48 bool ImageInputType::supportsValidation() const
    49 {
     41    // Buttons except overridden types are never successful.
    5042    return false;
    5143}
    5244
     45RenderObject* BaseButtonInputType::createRenderer(RenderArena* arena, RenderStyle*) const
     46{
     47    return new (arena) RenderButton(element());
     48}
     49
    5350} // namespace WebCore
  • trunk/WebCore/html/BaseButtonInputType.h

    r70510 r70511  
    2929 */
    3030
    31 #ifndef ButtonInputType_h
    32 #define ButtonInputType_h
     31#ifndef BaseButtonInputType_h
     32#define BaseButtonInputType_h
    3333
    3434#include "InputType.h"
     
    3636namespace WebCore {
    3737
    38 class ButtonInputType : public InputType {
    39 public:
    40     static PassOwnPtr<InputType> create(HTMLInputElement*);
     38// Base of button, file, image, reset, and submit types.
     39class BaseButtonInputType : public InputType {
     40protected:
     41    BaseButtonInputType(HTMLInputElement* element) : InputType(element) { }
    4142
    4243private:
    43     ButtonInputType(HTMLInputElement* element) : InputType(element) { }
    44     virtual const AtomicString& formControlType() const;
    45     virtual bool supportsValidation() const;
     44    virtual bool appendFormData(FormDataList&, bool) const;
     45    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
    4646};
    4747
    4848} // namespace WebCore
    4949
    50 #endif // ButtonInputType_h
     50#endif // BaseButtonInputType_h
  • trunk/WebCore/html/BaseCheckableInputType.cpp

    r70510 r70511  
    3030
    3131#include "config.h"
    32 #include "TextFieldInputType.h"
     32#include "BaseCheckableInputType.h"
    3333
    34 #include <wtf/text/WTFString.h>
     34#include "FormDataList.h"
     35#include "HTMLInputElement.h"
     36#include "HTMLNames.h"
     37#include "RegularExpression.h"
    3538
    3639namespace WebCore {
    3740
    38 bool TextFieldInputType::isTextField() const
     41bool BaseCheckableInputType::saveFormControlState(String& result) const
    3942{
     43    result = element()->checked() ? "on" : "off";
    4044    return true;
    4145}
    4246
    43 bool TextFieldInputType::valueMissing(const String& value) const
     47void BaseCheckableInputType::restoreFormControlState(const String& state) const
    4448{
    45     return value.isEmpty();
     49    element()->setChecked(state == "on");
     50}
     51
     52bool BaseCheckableInputType::appendFormData(FormDataList& encoding, bool) const
     53{
     54    if (!element()->checked())
     55        return false;
     56    encoding.appendData(element()->name(), element()->value());
     57    return true;
    4658}
    4759
  • trunk/WebCore/html/BaseCheckableInputType.h

    r70510 r70511  
    2929 */
    3030
    31 #ifndef TextFieldInputType_h
    32 #define TextFieldInputType_h
     31#ifndef BaseCheckableInputType_h
     32#define BaseCheckableInputType_h
    3333
    3434#include "InputType.h"
     
    3636namespace WebCore {
    3737
    38 // The class represents types of which UI contain text fields.
    39 // It supports not only the types for BaseTextInputType but also type=number.
    40 class TextFieldInputType : public InputType {
     38// Base of checkbox and radio types.
     39class BaseCheckableInputType : public InputType {
    4140protected:
    42     TextFieldInputType(HTMLInputElement* element) : InputType(element) { }
    43     virtual bool isTextField() const;
    44     virtual bool valueMissing(const String&) const;
     41    BaseCheckableInputType(HTMLInputElement* element) : InputType(element) { }
     42
     43private:
     44    virtual bool saveFormControlState(String&) const;
     45    virtual void restoreFormControlState(const String&) const;
     46    virtual bool appendFormData(FormDataList&, bool) const;
    4547};
    4648
    4749} // namespace WebCore
    4850
    49 #endif // TextFieldInputType_h
     51#endif // BaseCheckableInputType_h
  • trunk/WebCore/html/ButtonInputType.h

    r69445 r70511  
    3232#define ButtonInputType_h
    3333
    34 #include "InputType.h"
     34#include "BaseButtonInputType.h"
    3535
    3636namespace WebCore {
    3737
    38 class ButtonInputType : public InputType {
     38class ButtonInputType : public BaseButtonInputType {
    3939public:
    4040    static PassOwnPtr<InputType> create(HTMLInputElement*);
    4141
    4242private:
    43     ButtonInputType(HTMLInputElement* element) : InputType(element) { }
     43    ButtonInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
    4444    virtual const AtomicString& formControlType() const;
    4545    virtual bool supportsValidation() const;
  • trunk/WebCore/html/CheckboxInputType.h

    r69445 r70511  
    3232#define CheckboxInputType_h
    3333
    34 #include "InputType.h"
     34#include "BaseCheckableInputType.h"
    3535
    3636namespace WebCore {
    3737
    38 class CheckboxInputType : public InputType {
     38class CheckboxInputType : public BaseCheckableInputType {
    3939public:
    4040    static PassOwnPtr<InputType> create(HTMLInputElement*);
    4141
    4242private:
    43     CheckboxInputType(HTMLInputElement* element) : InputType(element) { }
     43    CheckboxInputType(HTMLInputElement* element) : BaseCheckableInputType(element) { }
    4444    virtual const AtomicString& formControlType() const;
    4545    virtual bool valueMissing(const String&) const;
  • trunk/WebCore/html/FileInputType.cpp

    r69445 r70511  
    11/*
     2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    23 * Copyright (C) 2010 Google Inc. All rights reserved.
    34 *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions are
    6  * met:
     5 * This library is free software; you can redistribute it and/or
     6 * modify it under the terms of the GNU Library General Public
     7 * License as published by the Free Software Foundation; either
     8 * version 2 of the License, or (at your option) any later version.
    79 *
    8  *     * Redistributions of source code must retain the above copyright
    9  * notice, this list of conditions and the following disclaimer.
    10  *     * Redistributions in binary form must reproduce the above
    11  * copyright notice, this list of conditions and the following disclaimer
    12  * in the documentation and/or other materials provided with the
    13  * distribution.
    14  *     * Neither the name of Google Inc. nor the names of its
    15  * contributors may be used to endorse or promote products derived from
    16  * this software without specific prior written permission.
     10 * This library is distributed in the hope that it will be useful,
     11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13 * Library General Public License for more details.
    1714 *
    18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     15 * You should have received a copy of the GNU Library General Public License
     16 * along with this library; see the file COPYING.LIB.  If not, write to
     17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     18 * Boston, MA 02110-1301, USA.
     19 *
    2920 */
    3021
     
    3223#include "FileInputType.h"
    3324
     25#include "File.h"
     26#include "FileList.h"
     27#include "FormDataList.h"
     28#include "HTMLInputElement.h"
     29#include "RenderFileUploadControl.h"
    3430#include <wtf/PassOwnPtr.h>
    3531#include <wtf/text/WTFString.h>
     
    4743}
    4844
     45bool FileInputType::appendFormData(FormDataList& encoding, bool multipart) const
     46{
     47    FileList* fileList = element()->files();
     48    unsigned numFiles = fileList->length();
     49    if (!multipart) {
     50        // Send only the basenames.
     51        // 4.10.16.4 and 4.10.16.6 sections in HTML5.
     52
     53        // Unlike the multipart case, we have no special handling for the empty
     54        // fileList because Netscape doesn't support for non-multipart
     55        // submission of file inputs, and Firefox doesn't add "name=" query
     56        // parameter.
     57        for (unsigned i = 0; i < numFiles; ++i)
     58            encoding.appendData(element()->name(), fileList->item(i)->fileName());
     59        return true;
     60    }
     61
     62    // If no filename at all is entered, return successful but empty.
     63    // Null would be more logical, but Netscape posts an empty file. Argh.
     64    if (!numFiles) {
     65        encoding.appendBlob(element()->name(), File::create(""));
     66        return true;
     67    }
     68
     69    for (unsigned i = 0; i < numFiles; ++i)
     70        encoding.appendBlob(element()->name(), fileList->item(i));
     71    return true;
     72}
     73
    4974bool FileInputType::valueMissing(const String& value) const
    5075{
     
    5277}
    5378
     79RenderObject* FileInputType::createRenderer(RenderArena* arena, RenderStyle*) const
     80{
     81    return new (arena) RenderFileUploadControl(element());
     82}
     83
    5484} // namespace WebCore
  • trunk/WebCore/html/FileInputType.h

    r69445 r70511  
    3232#define FileInputType_h
    3333
    34 #include "InputType.h"
     34#include "BaseButtonInputType.h"
    3535
    3636namespace WebCore {
    3737
    38 class FileInputType : public InputType {
     38class FileInputType : public BaseButtonInputType {
    3939public:
    4040    static PassOwnPtr<InputType> create(HTMLInputElement*);
    4141
    4242private:
    43     FileInputType(HTMLInputElement* element) : InputType(element) { }
     43    FileInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
    4444    virtual const AtomicString& formControlType() const;
     45    virtual bool appendFormData(FormDataList&, bool) const;
    4546    virtual bool valueMissing(const String&) const;
     47    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
    4648};
    4749
  • trunk/WebCore/html/HTMLFormControlElement.h

    r69831 r70511  
    181181    virtual bool supportsPlaceholder() const = 0;
    182182    String strippedPlaceholder() const;
     183    bool placeholderShouldBeVisible() const;
    183184
    184185    int selectionStart();
     
    193194    HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*);
    194195
    195     bool placeholderShouldBeVisible() const;
    196196    void updatePlaceholderVisibility(bool);
    197197
  • trunk/WebCore/html/HTMLInputElement.cpp

    r69445 r70511  
    5757#include "MouseEvent.h"
    5858#include "Page.h"
    59 #include "RenderButton.h"
    6059#include "RenderFileUploadControl.h"
    6160#include "RenderImage.h"
    6261#include "RenderSlider.h"
    63 #include "RenderText.h"
    6462#include "RenderTextControlSingleLine.h"
    6563#include "RenderTheme.h"
     
    530528bool HTMLInputElement::saveFormControlState(String& result) const
    531529{
    532     switch (deprecatedInputType()) {
    533     case BUTTON:
    534     case COLOR:
    535     case DATE:
    536     case DATETIME:
    537     case DATETIMELOCAL:
    538     case EMAIL:
    539     case FILE:
    540     case HIDDEN:
    541     case IMAGE:
    542     case ISINDEX:
    543     case MONTH:
    544     case NUMBER:
    545     case RANGE:
    546     case RESET:
    547     case SEARCH:
    548     case SUBMIT:
    549     case TELEPHONE:
    550     case TEXT:
    551     case TIME:
    552     case URL:
    553     case WEEK: {
    554         String currentValue = value();
    555         if (currentValue == defaultValue())
    556             return false;
    557         result = currentValue;
    558         return true;
    559     }
    560     case CHECKBOX:
    561     case RADIO:
    562         result = checked() ? "on" : "off";
    563         return true;
    564     case PASSWORD:
    565         return false;
    566     }
    567     ASSERT_NOT_REACHED();
    568     return false;
     530    return m_inputType->saveFormControlState(result);
    569531}
    570532
    571533void HTMLInputElement::restoreFormControlState(const String& state)
    572534{
    573     ASSERT(deprecatedInputType() != PASSWORD); // should never save/restore password fields
    574     switch (deprecatedInputType()) {
    575     case BUTTON:
    576     case COLOR:
    577     case DATE:
    578     case DATETIME:
    579     case DATETIMELOCAL:
    580     case EMAIL:
    581     case FILE:
    582     case HIDDEN:
    583     case IMAGE:
    584     case ISINDEX:
    585     case MONTH:
    586     case NUMBER:
    587     case RANGE:
    588     case RESET:
    589     case SEARCH:
    590     case SUBMIT:
    591     case TELEPHONE:
    592     case TEXT:
    593     case TIME:
    594     case URL:
    595     case WEEK:
    596         setValue(state);
    597         break;
    598     case CHECKBOX:
    599     case RADIO:
    600         setChecked(state == "on");
    601         break;
    602     case PASSWORD:
    603         break;
    604     }
     535    m_inputType->restoreFormControlState(state);
    605536}
    606537
     
    797728}
    798729
    799 RenderObject* HTMLInputElement::createRenderer(RenderArena *arena, RenderStyle *style)
    800 {
    801     switch (deprecatedInputType()) {
    802     case BUTTON:
    803     case RESET:
    804     case SUBMIT:
    805         return new (arena) RenderButton(this);
    806     case CHECKBOX:
    807     case RADIO:
    808         return RenderObject::createObject(this, style);
    809     case FILE:
    810         return new (arena) RenderFileUploadControl(this);
    811     case HIDDEN:
    812         break;
    813     case IMAGE: {
    814         RenderImage* image = new (arena) RenderImage(this);
    815         image->setImageResource(RenderImageResource::create());
    816         return image;
    817     }
    818     case RANGE:
    819         return new (arena) RenderSlider(this);
    820     case COLOR:
    821     case DATE:
    822     case DATETIME:
    823     case DATETIMELOCAL:
    824     case EMAIL:
    825     case ISINDEX:
    826     case MONTH:
    827     case NUMBER:
    828     case PASSWORD:
    829     case SEARCH:
    830     case TELEPHONE:
    831     case TEXT:
    832     case TIME:
    833     case URL:
    834     case WEEK:
    835         return new (arena) RenderTextControlSingleLine(this, placeholderShouldBeVisible());
    836     }
    837     ASSERT(false);
    838     return 0;
     730RenderObject* HTMLInputElement::createRenderer(RenderArena* arena, RenderStyle* style)
     731{
     732    return m_inputType->createRenderer(arena, style);
    839733}
    840734
     
    913807bool HTMLInputElement::appendFormData(FormDataList& encoding, bool multipart)
    914808{
    915     // image generates its own names, but for other types there is no form data unless there's a name
    916     if (name().isEmpty() && deprecatedInputType() != IMAGE)
    917         return false;
    918 
    919     switch (deprecatedInputType()) {
    920     case COLOR:
    921     case DATE:
    922     case DATETIME:
    923     case DATETIMELOCAL:
    924     case EMAIL:
    925     case HIDDEN:
    926     case ISINDEX:
    927     case MONTH:
    928     case NUMBER:
    929     case PASSWORD:
    930     case RANGE:
    931     case SEARCH:
    932     case TELEPHONE:
    933     case TEXT:
    934     case TIME:
    935     case URL:
    936     case WEEK:
    937         // always successful
    938         encoding.appendData(name(), value());
    939         return true;
    940 
    941     case CHECKBOX:
    942     case RADIO:
    943         if (checked()) {
    944             encoding.appendData(name(), value());
    945             return true;
    946         }
    947         break;
    948 
    949     case BUTTON:
    950     case RESET:
    951         // these types of buttons are never successful
    952         return false;
    953 
    954     case IMAGE:
    955         if (m_activeSubmit) {
    956             encoding.appendData(name().isEmpty() ? "x" : (name() + ".x"), m_xPos);
    957             encoding.appendData(name().isEmpty() ? "y" : (name() + ".y"), m_yPos);
    958             if (!name().isEmpty() && !value().isEmpty())
    959                 encoding.appendData(name(), value());
    960             return true;
    961         }
    962         break;
    963 
    964     case SUBMIT:
    965         if (m_activeSubmit) {
    966             String encstr = valueWithDefault();
    967             encoding.appendData(name(), encstr);
    968             return true;
    969         }
    970         break;
    971 
    972     case FILE: {
    973         unsigned numFiles = m_fileList->length();
    974         if (!multipart) {
    975             // Send only the basenames.
    976             // 4.10.16.4 and 4.10.16.6 sections in HTML5.
    977    
    978             // Unlike the multipart case, we have no special
    979             // handling for the empty fileList because Netscape
    980             // doesn't support for non-multipart submission of
    981             // file inputs, and Firefox doesn't add "name=" query
    982             // parameter.
    983 
    984             for (unsigned i = 0; i < numFiles; ++i)
    985                 encoding.appendData(name(), m_fileList->item(i)->fileName());
    986             return true;
    987         }
    988 
    989         // If no filename at all is entered, return successful but empty.
    990         // Null would be more logical, but Netscape posts an empty file. Argh.
    991         if (!numFiles) {
    992             encoding.appendBlob(name(), File::create(""));
    993             return true;
    994         }
    995 
    996         for (unsigned i = 0; i < numFiles; ++i)
    997             encoding.appendBlob(name(), m_fileList->item(i));
    998         return true;
    999         }
    1000     }
    1001     return false;
     809    return m_inputType->isFormDataAppendable() && m_inputType->appendFormData(encoding, multipart);
    1002810}
    1003811
  • trunk/WebCore/html/HTMLInputElement.h

    r69445 r70511  
    203203        return document()->checkedRadioButtons();
    204204    }
     205
     206    // FIXME: We should move m_xPos and m_yPos to ImageInputType class.
     207    int xPosition() const { return m_xPos; }
     208    int yPosition() const { return m_yPos; }
    205209
    206210protected:
  • trunk/WebCore/html/HiddenInputType.cpp

    r69445 r70511  
    5050}
    5151
     52RenderObject* HiddenInputType::createRenderer(RenderArena*, RenderStyle*) const
     53{
     54    ASSERT_NOT_REACHED();
     55    return 0;
     56}
     57
    5258} // namespace WebCore
  • trunk/WebCore/html/HiddenInputType.h

    r69445 r70511  
    4444    virtual const AtomicString& formControlType() const;
    4545    virtual bool supportsValidation() const;
     46    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
    4647};
    4748
  • trunk/WebCore/html/ImageInputType.cpp

    r69445 r70511  
    11/*
     2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    23 * Copyright (C) 2010 Google Inc. All rights reserved.
    34 *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions are
    6  * met:
     5 * This library is free software; you can redistribute it and/or
     6 * modify it under the terms of the GNU Library General Public
     7 * License as published by the Free Software Foundation; either
     8 * version 2 of the License, or (at your option) any later version.
    79 *
    8  *     * Redistributions of source code must retain the above copyright
    9  * notice, this list of conditions and the following disclaimer.
    10  *     * Redistributions in binary form must reproduce the above
    11  * copyright notice, this list of conditions and the following disclaimer
    12  * in the documentation and/or other materials provided with the
    13  * distribution.
    14  *     * Neither the name of Google Inc. nor the names of its
    15  * contributors may be used to endorse or promote products derived from
    16  * this software without specific prior written permission.
     10 * This library is distributed in the hope that it will be useful,
     11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13 * Library General Public License for more details.
    1714 *
    18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     15 * You should have received a copy of the GNU Library General Public License
     16 * along with this library; see the file COPYING.LIB.  If not, write to
     17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     18 * Boston, MA 02110-1301, USA.
     19 *
    2920 */
    3021
     
    3223#include "ImageInputType.h"
    3324
     25#include "FormDataList.h"
     26#include "HTMLInputElement.h"
     27#include "RenderImage.h"
    3428#include <wtf/PassOwnPtr.h>
    3529
     
    4640}
    4741
     42bool ImageInputType::isFormDataAppendable() const
     43{
     44    return true;
     45}
     46
     47bool ImageInputType::appendFormData(FormDataList& encoding, bool) const
     48{
     49    if (!element()->isActivatedSubmit())
     50        return false;
     51    const AtomicString& name = element()->name();
     52    encoding.appendData(name.isEmpty() ? "x" : (name + ".x"), element()->xPosition());
     53    encoding.appendData(name.isEmpty() ? "y" : (name + ".y"), element()->yPosition());
     54    if (!name.isEmpty() && !element()->value().isEmpty())
     55        encoding.appendData(name, element()->value());
     56    return true;
     57}
     58
    4859bool ImageInputType::supportsValidation() const
    4960{
     
    5162}
    5263
     64RenderObject* ImageInputType::createRenderer(RenderArena* arena, RenderStyle*) const
     65{
     66    RenderImage* image = new (arena) RenderImage(element());
     67    image->setImageResource(RenderImageResource::create());
     68    return image;
     69}
     70
    5371} // namespace WebCore
  • trunk/WebCore/html/ImageInputType.h

    r69445 r70511  
    3232#define ImageInputType_h
    3333
    34 #include "InputType.h"
     34#include "BaseButtonInputType.h"
    3535
    3636namespace WebCore {
    3737
    38 class ImageInputType : public InputType {
     38class ImageInputType : public BaseButtonInputType {
    3939public:
    4040    static PassOwnPtr<InputType> create(HTMLInputElement*);
    4141
    4242private:
    43     ImageInputType(HTMLInputElement* element) : InputType(element) { }
     43    ImageInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
    4444    virtual const AtomicString& formControlType() const;
     45    virtual bool isFormDataAppendable() const;
     46    virtual bool appendFormData(FormDataList&, bool) const;
    4547    virtual bool supportsValidation() const;
     48    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
    4649};
    4750
  • trunk/WebCore/html/InputType.cpp

    r69445 r70511  
    3737#include "EmailInputType.h"
    3838#include "FileInputType.h"
     39#include "FormDataList.h"
    3940#include "HTMLInputElement.h"
    4041#include "HiddenInputType.h"
     
    4748#include "RangeInputType.h"
    4849#include "RegularExpression.h"
     50#include "RenderObject.h"
    4951#include "ResetInputType.h"
    5052#include "SearchInputType.h"
     
    123125}
    124126
     127bool InputType::saveFormControlState(String& result) const
     128{
     129    String currentValue = element()->value();
     130    if (currentValue == element()->defaultValue())
     131        return false;
     132    result = currentValue;
     133    return true;
     134}
     135
     136void InputType::restoreFormControlState(const String& state) const
     137{
     138    element()->setValue(state);
     139}
     140
     141bool InputType::isFormDataAppendable() const
     142{
     143    // There is no form data unless there's a name for non-image types.
     144    return !element()->name().isEmpty();
     145}
     146
     147bool InputType::appendFormData(FormDataList& encoding, bool) const
     148{
     149    // Always successful.
     150    encoding.appendData(element()->name(), element()->value());
     151    return true;
     152}
     153
    125154double InputType::valueAsDate() const
    126155{
     
    229258}
    230259
     260RenderObject* InputType::createRenderer(RenderArena*, RenderStyle* style) const
     261{
     262    return RenderObject::createObject(element(), style);
     263}
     264
    231265double InputType::parseToDouble(const String&, double defaultValue) const
    232266{
  • trunk/WebCore/html/InputType.h

    r69445 r70511  
    3939
    4040class DateComponents;
     41class FormDataList;
    4142class HTMLInputElement;
     43class RenderArena;
     44class RenderObject;
     45class RenderStyle;
    4246
     47// An InputType object represents the type-specific part of an HTMLInputElement.
     48// Do not expose instances of InputType and classes derived from it to classes
     49// other than HTMLInputElement.
    4350class InputType : public Noncopyable {
    4451public:
     
    4754    virtual ~InputType();
    4855
     56    // Type query functions
     57
    4958    virtual bool isTextField() const;
    5059    virtual bool isTextType() const;
    5160    virtual const AtomicString& formControlType() const = 0;
     61
     62    // Form value functions
     63
     64    virtual bool saveFormControlState(String&) const;
     65    virtual void restoreFormControlState(const String&) const;
     66    virtual bool isFormDataAppendable() const;
     67    virtual bool appendFormData(FormDataList&, bool multipart) const;
     68
     69    // DOM property functions
    5270
    5371    virtual double valueAsDate() const;
     
    5674    virtual void setValueAsNumber(double, ExceptionCode&) const;
    5775
    58     // Validation-related functions
     76    // Validation functions
    5977
    6078    virtual bool supportsValidation() const;
     
    7795    virtual bool parsedStepValueShouldBeInteger() const;
    7896    virtual bool scaledStepValeuShouldBeInteger() const;
     97
     98    // Miscellaneous functions
     99
     100    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
    79101
    80102    // Parses the specified string for the type, and return
  • trunk/WebCore/html/PasswordInputType.cpp

    r68629 r70511  
    3232#include "PasswordInputType.h"
    3333
     34#include <wtf/Assertions.h>
    3435#include <wtf/PassOwnPtr.h>
    3536
     
    4647}
    4748
     49bool PasswordInputType::saveFormControlState(String&) const
     50{
     51    // Should never save/restore password fields.
     52    return false;
     53}
     54
     55void PasswordInputType::restoreFormControlState(const String&) const
     56{
     57    // Should never save/restore password fields.
     58    ASSERT_NOT_REACHED();
     59}
     60
    4861} // namespace WebCore
  • trunk/WebCore/html/PasswordInputType.h

    r68629 r70511  
    4343    PasswordInputType(HTMLInputElement* element) : BaseTextInputType(element) { }
    4444    virtual const AtomicString& formControlType() const;
     45    virtual bool saveFormControlState(String&) const;
     46    virtual void restoreFormControlState(const String&) const;
    4547};
    4648
  • trunk/WebCore/html/RadioInputType.h

    r69445 r70511  
    3232#define RadioInputType_h
    3333
    34 #include "InputType.h"
     34#include "BaseCheckableInputType.h"
    3535
    3636namespace WebCore {
    3737
    38 class RadioInputType : public InputType {
     38class RadioInputType : public BaseCheckableInputType {
    3939public:
    4040    static PassOwnPtr<InputType> create(HTMLInputElement*);
    4141
    4242private:
    43     RadioInputType(HTMLInputElement* element) : InputType(element) { }
     43    RadioInputType(HTMLInputElement* element) : BaseCheckableInputType(element) { }
    4444    virtual const AtomicString& formControlType() const;
    4545    virtual bool valueMissing(const String&) const;
  • trunk/WebCore/html/RangeInputType.cpp

    r69446 r70511  
    3535#include "HTMLNames.h"
    3636#include "HTMLParserIdioms.h"
     37#include "RenderSlider.h"
    3738#include <limits>
    3839#include <wtf/MathExtras.h>
     
    127128}
    128129
     130RenderObject* RangeInputType::createRenderer(RenderArena* arena, RenderStyle*) const
     131{
     132    return new (arena) RenderSlider(element());
     133}
     134
    129135double RangeInputType::parseToDouble(const String& src, double defaultValue) const
    130136{
  • trunk/WebCore/html/RangeInputType.h

    r69446 r70511  
    5454    virtual double defaultStep() const;
    5555    virtual double stepScaleFactor() const;
     56    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
    5657    virtual double parseToDouble(const String&, double) const;
    5758    virtual String serialize(double) const;
  • trunk/WebCore/html/ResetInputType.h

    r69445 r70511  
    3232#define ResetInputType_h
    3333
    34 #include "InputType.h"
     34#include "BaseButtonInputType.h"
    3535
    3636namespace WebCore {
    3737
    38 class ResetInputType : public InputType {
     38class ResetInputType : public BaseButtonInputType {
    3939public:
    4040    static PassOwnPtr<InputType> create(HTMLInputElement*);
    4141
    4242private:
    43     ResetInputType(HTMLInputElement* element) : InputType(element) { }
     43    ResetInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
    4444    virtual const AtomicString& formControlType() const;
    4545    virtual bool supportsValidation() const;
  • trunk/WebCore/html/SubmitInputType.cpp

    r69445 r70511  
    3232#include "SubmitInputType.h"
    3333
     34#include "FormDataList.h"
     35#include "HTMLInputElement.h"
    3436#include <wtf/PassOwnPtr.h>
    3537
     
    4648}
    4749
     50bool SubmitInputType::appendFormData(FormDataList& encoding, bool) const
     51{
     52    if (!element()->isActivatedSubmit())
     53        return false;
     54    encoding.appendData(element()->name(), element()->valueWithDefault());
     55    return true;
     56}
     57
    4858bool SubmitInputType::supportsValidation() const
    4959{
  • trunk/WebCore/html/SubmitInputType.h

    r69445 r70511  
    3232#define SubmitInputType_h
    3333
    34 #include "InputType.h"
     34#include "BaseButtonInputType.h"
    3535
    3636namespace WebCore {
    3737
    38 class SubmitInputType : public InputType {
     38class SubmitInputType : public BaseButtonInputType {
    3939public:
    4040    static PassOwnPtr<InputType> create(HTMLInputElement*);
    4141
    4242private:
    43     SubmitInputType(HTMLInputElement* element) : InputType(element) { }
     43    SubmitInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
    4444    virtual const AtomicString& formControlType() const;
     45    virtual bool appendFormData(FormDataList&, bool) const;
    4546    virtual bool supportsValidation() const;
    4647};
  • trunk/WebCore/html/TextFieldInputType.cpp

    r69445 r70511  
    3232#include "TextFieldInputType.h"
    3333
     34#include "HTMLInputElement.h"
     35#include "RenderTextControlSingleLine.h"
    3436#include <wtf/text/WTFString.h>
    3537
     
    4648}
    4749
     50RenderObject* TextFieldInputType::createRenderer(RenderArena* arena, RenderStyle*) const
     51{
     52    return new (arena) RenderTextControlSingleLine(element(), element()->placeholderShouldBeVisible());
     53}
     54
    4855} // namespace WebCore
  • trunk/WebCore/html/TextFieldInputType.h

    r69445 r70511  
    4343    virtual bool isTextField() const;
    4444    virtual bool valueMissing(const String&) const;
     45    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
    4546};
    4647
Note: See TracChangeset for help on using the changeset viewer.