[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

darin at apple.com darin at apple.com
Fri Jan 21 14:51:50 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit 746c232ddf048b21720a7bac98273fea2d3e5076
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jan 3 17:21:43 2011 +0000

    2011-01-02  Darin Adler  <darin at apple.com>
    
            Reviewed by Kent Tamura.
    
            Eliminate HTMLInputElement::m_deprecatedTypeNumber, other input refactoring and renaming
            https://bugs.webkit.org/show_bug.cgi?id=51791
    
            * src/WebSearchableFormData.cpp:
            (HTMLNames::IsInDefaultState): Use hasAttribute(checkedAttr)
            to find out whether a button should be checked by default,
            rather than calling the defaultChecked function.
    2011-01-02  Darin Adler  <darin at apple.com>
    
            Reviewed by Kent Tamura.
    
            Eliminate HTMLInputElement::m_deprecatedTypeNumber, other input refactoring and renaming
            https://bugs.webkit.org/show_bug.cgi?id=51791
    
            * dom/InputElement.h: Make sanitizeValueForTextField public so it can
            be called by InputType.
    
            * html/BaseButtonInputType.cpp:
            (WebCore::BaseButtonInputType::accessKeyAction): Added.
            (WebCore::BaseButtonInputType::storesValueSeparateFromAttribute): Added.
            * html/BaseButtonInputType.h: Ditto.
    
            * html/BaseCheckableInputType.cpp:
            (WebCore::BaseCheckableInputType::canSetStringValue): Added.
            (WebCore::BaseCheckableInputType::accessKeyAction): Added.
            (WebCore::BaseCheckableInputType::fallbackValue): Added.
            (WebCore::BaseCheckableInputType::storesValueSeparateFromAttribute): Added.
            (WebCore::BaseCheckableInputType::isCheckable): Added.
            * html/BaseCheckableInputType.h: Ditto.
    
            * html/BaseDateAndTimeInputType.cpp:
            (WebCore::BaseDateAndTimeInputType::hasSpinButton): Added.
            * html/BaseDateAndTimeInputType.h: Ditto.
    
            * html/BaseTextInputType.h: Made more functions private.
    
            * html/ButtonInputType.cpp:
            (WebCore::ButtonInputType::isTextButton): Added.
            * html/ButtonInputType.h: Ditto.
    
            * html/CheckboxInputType.cpp:
            (WebCore::CheckboxInputType::willDispatchClick): Added.
            (WebCore::CheckboxInputType::didDispatchClick): Added.
            (WebCore::CheckboxInputType::isCheckbox): Added.
            * html/CheckboxInputType.h: Ditto.
    
            * html/DateTimeInputType.cpp:
            (WebCore::DateTimeInputType::scaledStepValueShouldBeInteger): Fixed
            typo in name of this function.
            * html/DateTimeInputType.h: Ditto.
            * html/DateTimeLocalInputType.cpp:
            (WebCore::DateTimeLocalInputType::scaledStepValueShouldBeInteger): Ditto.
            * html/DateTimeLocalInputType.h: Ditto.
    
            * html/EmailInputType.cpp:
            (WebCore::EmailInputType::isEmailField): Added.
            * html/EmailInputType.h: Ditto.
    
            * html/FileInputType.cpp:
            (WebCore::FileInputType::FileInputType): Added.
            (WebCore::FileInputType::canSetStringValue): Added.
            (WebCore::FileInputType::canChangeFromAnotherType): Added.
            (WebCore::FileInputType::files): Added.
            (WebCore::FileInputType::canSetValue): Added.
            (WebCore::FileInputType::getTypeSpecificValue): Added.
            (WebCore::FileInputType::storesValueSeparateFromAttribute): Added.
            (WebCore::FileInputType::setFileList): Added.
            (WebCore::FileInputType::isFileUpload): Added.
            * html/FileInputType.h: Ditto.
    
            * html/HTMLInputElement.cpp:
            (WebCore::HTMLInputElement::HTMLInputElement): Updated for data member
            renaming and removal.
            (WebCore::HTMLInputElement::isValidValue): Call canSetStringValue
            instead of checking specific type numbers.
            (WebCore::HTMLInputElement::getAllowedValueStepWithDecimalPlaces):
            Use fastGetAttribute and fixed typo in the name of the
            scaledStepValueShouldBeInteger function.
            (WebCore::HTMLInputElement::isKeyboardFocusable): Call
            InputType::isKeyboardFocusable; moved most of the type-specific
            logic there.
            (WebCore::HTMLInputElement::shouldUseInputMethod): Call
            InputType::shouldUseInputMethod; moved the type-specific logic there.
            (WebCore::HTMLInputElement::handleBlurEvent): Call
            InputType::handleBlurEvent; moved the type-specific logic there.
            (WebCore::HTMLInputElement::setType): Tweak the names and types
            in this function.
            (WebCore::HTMLInputElement::updateType): Removed the code that
            set m_deprecatedTypeNumber. Compare types by comparing the value
            from formControlType. Removed file-specific logic and instead call
            InputType::canChangeFromAnotherType. Streamlined the logic for
            activation callbacks.
            (WebCore::HTMLInputElement::accessKeyAction): Call
            InputType::accessKeyAction; moved the type-specific logic there.
            (WebCore::HTMLInputElement::mapToEntry): Call
            InputType::shouldRespectHeightAndWidthAttributes and
            InputType::shouldRespectAlignAttribute.
            (WebCore::HTMLInputElement::parseMappedAttribute): Updated
            for name changes and the removal of m_defaultChecked. Changed the
            alt attribute logic to be based on the class of the renderer.
            Call InputType::srcAttributeChanged and moved the type-specific
            logic there. Call shouldRespectAlignAttribute and
            shouldRespectHeightAndWidthAttributes rather than having
            type-specific logic here. Call minOrMaxAttributeChanged.
            (WebCore::HTMLInputElement::rendererIsNeeded): Call
            InputType::rendererIsNeeded; moved the type-specific logic there.
            (WebCore::HTMLInputElement::attach): Removed the unneeded m_inited
            flag, which was redundant with the m_haveType flag. Call
            InputType::attach; moved the type-specific logic there.
            (WebCore::HTMLInputElement::altText): Use fastGetAttribute.
            (WebCore::HTMLInputElement::isSuccessfulSubmitButton): Call
            InputType::canBeSuccessfulSubmitButton; moved the type-specific
            logic there.
            (WebCore::HTMLInputElement::isActivatedSubmit): Updated for
            name changes.
            (WebCore::HTMLInputElement::setActivatedSubmit): Ditto.
            (WebCore::HTMLInputElement::reset): Updated to use
            InputType::storesValueSeparateFromAttribute. Also use
            hasAttribute(checkedAttr) rather than m_defaultChecked,
            since both are the same. Also updated for name change.
            (WebCore::HTMLInputElement::setChecked): Updated for name
            changes. Also added call to
            InputType::shouldSendChangeEventAfterCheckedChanged and
            moved the type-specific logic there.
            (WebCore::HTMLInputElement::setIndeterminate): Call
            isCheckable to see if indeterminate is allowed.
            Also updated for name changes.
            (WebCore::HTMLInputElement::copyNonAttributeProperties):
            Updated for name changes and removed data members.
            (WebCore::HTMLInputElement::value): Call
            InputType::getTypeSpecificValue and InputType::fallbackValue.
            Moved the type-specific logic there.
            (WebCore::HTMLInputElement::valueWithDefault): Call
            InputType::defaultValue. Moved the type-specific logic there.
            (WebCore::HTMLInputElement::setSuggestedValue): Call
            InputType::canSetSuggestedValue. Moved the type-specific logic
            there.
            (WebCore::HTMLInputElement::setValue): Call
            InputType::canSetValue. Moved the type-specific logic there.
            Clear the file list if it exists rather than checking the
            type explicitly. We could probably do that a more elegant way.
            (WebCore::HTMLInputElement::placeholder): Use fastGetAttribute.
            (WebCore::HTMLInputElement::setValueFromRenderer): Use the
            isFileUpload function in the assertion.
            (WebCore::HTMLInputElement::setFileListFromRenderer): Put most
            of the code from this function into FileInputType::setFileList.
            (WebCore::HTMLInputElement::preDispatchEventHandler): Changed
            to call InputType::willDispatchClick, which does the type-specific
            work. Still need to use a single struct for all types, because
            the type of the element could change during the event handling.
            (WebCore::HTMLInputElement::postDispatchEventHandler): Changed
            to call InputType::didDispatchClick.
            (WebCore::HTMLInputElement::defaultValue): Use fastGetAttribute.
            (WebCore::HTMLInputElement::accept): Use fastGetAttribute.
            (WebCore::HTMLInputElement::alt): Use fastGetAttribute.
            (WebCore::HTMLInputElement::src): Use fastGetAttribute.
            (WebCore::HTMLInputElement::setAutofilled): Updated for name
            changes.
            (WebCore::HTMLInputElement::files): Use InputType::files.
            (WebCore::HTMLInputElement::isAcceptableValue): Use
            InputType::isAcceptableValue.
            (WebCore::HTMLInputElement::sanitizeValue): Use
            InputType::sanitizeValue.
            (WebCore::HTMLInputElement::hasUnacceptableValue): Use
            InputType::hasUnacceptableValue.
            (WebCore::HTMLInputElement::needsActivationCallback): Use
            InputType::shouldResetOnDocumentActivation.
            (WebCore::HTMLInputElement::willMoveToNewOwnerDocument): Use
            InputType::willMoveToNewOwnerDocument.
            (WebCore::HTMLInputElement::dataList): Use
            InputType::shouldRespectListAttribute.
            (WebCore::HTMLInputElement::selectedOption): Tweaked logic
            and naming a bit.
            (WebCore::HTMLInputElement::stepUpFromRenderer): Use
            fastGetAttribute.
            (WebCore::HTMLInputElement::isSpeechEnabled): Use
            InputType::shouldRespectSpeechAttribute.
            (WebCore::HTMLInputElement::isTextButton): No longer inline.
            Calls through to InputType.
            (WebCore::HTMLInputElement::isRadioButton): Ditto.
            (WebCore::HTMLInputElement::isSearchField): Ditto.
            (WebCore::HTMLInputElement::isInputTypeHidden): Ditto.
            (WebCore::HTMLInputElement::isPasswordField): Ditto.
            (WebCore::HTMLInputElement::isCheckbox): Ditto.
            (WebCore::HTMLInputElement::isText): Ditto.
            (WebCore::HTMLInputElement::isEmailField): Ditto.
            (WebCore::HTMLInputElement::isFileUpload): Ditto.
            (WebCore::HTMLInputElement::isImageButton): Ditto.
            (WebCore::HTMLInputElement::isNumberField): Ditto.
            (WebCore::HTMLInputElement::isSubmitButton): Ditto.
            (WebCore::HTMLInputElement::isTelephoneField): Ditto.
            (WebCore::HTMLInputElement::isURLField): Ditto.
            (WebCore::HTMLInputElement::isEnumeratable): Ditto.
            (WebCore::HTMLInputElement::isChecked): No longer inline.
            Calls InputType::isCheckable.
            (WebCore::HTMLInputElement::hasSpinButton): No longer inline.
            Calls through to InputType.
            (WebCore::HTMLInputElement::supportsPlaceholder): No longer
            inline. Calls isTextType as before, but with no special case
            for ISINDEX. That special case was unneeded since it returns
            true from isTextType.
            (WebCore::HTMLInputElement::checkedRadioButtons): No longer
            inline.
            (WebCore::HTMLInputElement::handleBeforeTextInsertedEvent):
            No longer inline.
    
            * html/HTMLInputElement.h: Removed multiple unneeded includes.
            The big one is probably InputType.h, but also HTMLFormElement.h.
            Removed unneeded forward declarations. Made many functions
            no longer inline since they now need to make virtual function
            dispatches. Removed the unneeded defaultChecked and
            webkitdirectory functions. Both are handled by HTML attribute
            reflection for DOM bindings, and the callers instead can get
            at the attribute. Made updateCheckedRadioButtons public so it
            can be called by an InputType class. Removed
            DeprecatedInputType, InputTypeMap, createTypeMap,
            deprecatedInputType, allowsIndeterminate,
            respectHeightAndWidthAttrs, storesValueSeparateFromAttribute,
            m_imageLoader, m_fileList, m_deprecatedTypeNumber,
            m_defaultChecked, and m_inited. Renamed m_checked to
            m_isChecked, m_useDefaultChecked to m_reflectsCheckedAttribute,
            m_indeterminate tom_isIndeterminate, m_haveType to m_hasType,
            m_activeSubmit to m_isActivatedSubmit, and m_autofilled to
            m_isAutofilled.
    
            * html/HiddenInputType.cpp:
            (WebCore::HiddenInputType::accessKeyAction): Added.
            (WebCore::HiddenInputType::rendererIsNeeded) Added.:
            (WebCore::HiddenInputType::storesValueSeparateFromAttribute): Added.
            (WebCore::HiddenInputType::isHiddenType): Added.
            (WebCore::HiddenInputType::shouldRespectHeightAndWidthAttributes): Added.
            * html/HiddenInputType.h: Ditto.
    
            * html/ImageInputType.cpp:
            (WebCore::ImageInputType::ImageInputType): Moved out of the header file.
            (WebCore::ImageInputType::srcAttributeChanged): Added.
            (WebCore::ImageInputType::attach): Added.
            (WebCore::ImageInputType::willMoveToNewOwnerDocument): Added.
            (WebCore::ImageInputType::shouldRespectAlignAttribute): Added.
            (WebCore::ImageInputType::canBeSuccessfulSubmitButton): Added.
            (WebCore::ImageInputType::isImageButton): Added.
            (WebCore::ImageInputType::isEnumeratable): Added.
            (WebCore::ImageInputType::shouldRespectHeightAndWidthAttributes): Added.
            * html/ImageInputType.h: Ditto.
    
            * html/InputType.cpp:
            (WebCore::InputType::create): Changed argument type to String. There
            is no value in taking an AtomicString here.
            (WebCore::InputType::scaledStepValueShouldBeInteger): Fixed typo in
            this function name.
            (WebCore::InputType::canSetStringValue): Added.
            (WebCore::InputType::isKeyboardFocusable): Added.
            (WebCore::InputType::shouldUseInputMethod): Added.
            (WebCore::InputType::handleBlurEvent): Added.
            (WebCore::InputType::accessKeyAction): Added.
            (WebCore::InputType::attach): Added.
            (WebCore::InputType::srcAttributeChanged): Added.
            (WebCore::InputType::willMoveToNewOwnerDocument): Added.
            (WebCore::InputType::shouldRespectAlignAttribute): Added.
            (WebCore::InputType::canChangeFromAnotherType): Added.
            (WebCore::InputType::minOrMaxAttributeChanged): Added.
            (WebCore::InputType::canBeSuccessfulSubmitButton): Added.
            (WebCore::InputType::rendererIsNeeded): Added.
            (WebCore::InputType::files): Added.
            (WebCore::InputType::getTypeSpecificValue): Added.
            (WebCore::InputType::fallbackValue): Added.
            (WebCore::InputType::defaultValue): Added.
            (WebCore::InputType::canSetSuggestedValue): Added.
            (WebCore::InputType::shouldSendChangeEventAfterCheckedChanged): Added.
            (WebCore::InputType::storesValueSeparateFromAttribute): Added.
            (WebCore::InputType::canSetValue): Added.
            (WebCore::InputType::willDispatchClick): Added.
            (WebCore::InputType::didDispatchClick): Added.
            (WebCore::InputType::isAcceptableValue): Added.
            (WebCore::InputType::sanitizeValue): Added.
            (WebCore::InputType::hasUnacceptableValue): Added.
            (WebCore::InputType::setFileList): Added.
            (WebCore::InputType::shouldResetOnDocumentActivation): Added.
            (WebCore::InputType::shouldRespectListAttribute): Added.
            (WebCore::InputType::shouldRespectSpeechAttribute): Added.
            (WebCore::InputType::isTextButton): Added.
            (WebCore::InputType::isRadioButton): Added.
            (WebCore::InputType::isSearchField): Added.
            (WebCore::InputType::isHiddenType): Added.
            (WebCore::InputType::isPasswordField): Added.
            (WebCore::InputType::isCheckbox): Added.
            (WebCore::InputType::isEmailField): Added.
            (WebCore::InputType::isFileUpload): Added.
            (WebCore::InputType::isImageButton): Added.
            (WebCore::InputType::isNumberField): Added.
            (WebCore::InputType::isSubmitButton): Added.
            (WebCore::InputType::isTelephoneField): Added.
            (WebCore::InputType::isURLField): Added.
            (WebCore::InputType::isEnumeratable): Added.
            (WebCore::InputType::isCheckable): Added.
            (WebCore::InputType::hasSpinButton): Added.
            (WebCore::InputType::shouldRespectHeightAndWidthAttributes): Added.
    
            * html/InputType.h: Removed unneeded ExceptionCode.h include and
            used a typedef instead as we do when we want for forward declare it.
            Added includes and forward declarations needed for new functions.
            Added ClickHandlingState structure. Changed the argument to create
            to a String rather than AtomicString. Added many virtual functions.
    
            * html/IsIndexInputType.cpp:
            (WebCore::IsIndexInputType::shouldRespectListAttribute): Added.
            * html/IsIndexInputType.h: Ditto.
    
            * html/NumberInputType.cpp:
            (WebCore::NumberInputType::handleBlurEvent): Added.
            (WebCore::NumberInputType::isAcceptableValue): Added.
            (WebCore::NumberInputType::sanitizeValue): Added.
            (WebCore::NumberInputType::hasUnacceptableValue): Added.
            (WebCore::NumberInputType::shouldRespectSpeechAttribute): Added.
            (WebCore::NumberInputType::isNumberField): Added.
            (WebCore::NumberInputType::hasSpinButton): Added.
            * html/NumberInputType.h: Ditto.
    
            * html/PasswordInputType.cpp:
            (WebCore::PasswordInputType::shouldUseInputMethod): Added.
            (WebCore::PasswordInputType::shouldResetOnDocumentActivation): Added.
            (WebCore::PasswordInputType::shouldRespectListAttribute): Added.
            (WebCore::PasswordInputType::shouldRespectSpeechAttribute): Added.
            (WebCore::PasswordInputType::isPasswordField): Added.
            * html/PasswordInputType.h: Ditto.
    
            * html/RadioInputType.cpp:
            (WebCore::RadioInputType::isKeyboardFocusable): Added.
            (WebCore::RadioInputType::attach): Added.
            (WebCore::RadioInputType::shouldSendChangeEventAfterCheckedChanged): Added.
            (WebCore::RadioInputType::willDispatchClick): Added.
            (WebCore::RadioInputType::didDispatchClick): Added.
            (WebCore::RadioInputType::isRadioButton): Added.
            * html/RadioInputType.h: Ditto.
    
            * html/RangeInputType.cpp:
            (WebCore::RangeInputType::accessKeyAction): Added.
            (WebCore::RangeInputType::minOrMaxAttributeChanged): Added.
            (WebCore::RangeInputType::fallbackValue): Added.
            (WebCore::RangeInputType::sanitizeValue): Added.
            (WebCore::RangeInputType::shouldRespectListAttribute): Added.
            * html/RangeInputType.h: Ditto.
    
            * html/ResetInputType.cpp:
            (WebCore::ResetInputType::defaultValue): Added.
            (WebCore::ResetInputType::isTextButton): Added.
            * html/ResetInputType.h: Ditto.
    
            * html/SearchInputType.cpp:
            (WebCore::SearchInputType::shouldRespectSpeechAttribute): Added.
            (WebCore::SearchInputType::isSearchField): Added.
            * html/SearchInputType.h: Ditto.
    
            * html/SubmitInputType.cpp:
            (WebCore::SubmitInputType::canBeSuccessfulSubmitButton): Added.
            (WebCore::SubmitInputType::defaultValue): Added.
            (WebCore::SubmitInputType::isSubmitButton): Added.
            (WebCore::SubmitInputType::isTextButton): Added.
            * html/SubmitInputType.h: Ditto.
    
            * html/TelephoneInputType.cpp:
            (WebCore::TelephoneInputType::shouldRespectSpeechAttribute): Added.
            (WebCore::TelephoneInputType::isTelephoneField): Added.
            * html/TelephoneInputType.h: Ditto.
    
            * html/TextFieldInputType.cpp:
            (WebCore::TextFieldInputType::shouldUseInputMethod): Added.
            (WebCore::TextFieldInputType::sanitizeValue): Added.
            (WebCore::TextFieldInputType::shouldRespectListAttribute): Added.
            * html/TextFieldInputType.h: Ditto.
    
            * html/TextInputType.cpp:
            (WebCore::TextInputType::canSetSuggestedValue): Added.
            (WebCore::TextInputType::shouldRespectSpeechAttribute): Added.
            * html/TextInputType.h: Ditto.
    
            * html/TimeInputType.cpp:
            (WebCore::TimeInputType::scaledStepValueShouldBeInteger): Fixed
            typo in the name of this function.
            * html/TimeInputType.h: Ditto.
    
            * html/URLInputType.cpp:
            (WebCore::URLInputType::isURLField): Added.
            * html/URLInputType.h: Ditto.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74895 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9c0a9d3..3fe7786 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,381 @@
+2011-01-02  Darin Adler  <darin at apple.com>
+
+        Reviewed by Kent Tamura.
+
+        Eliminate HTMLInputElement::m_deprecatedTypeNumber, other input refactoring and renaming
+        https://bugs.webkit.org/show_bug.cgi?id=51791
+
+        * dom/InputElement.h: Make sanitizeValueForTextField public so it can
+        be called by InputType.
+
+        * html/BaseButtonInputType.cpp:
+        (WebCore::BaseButtonInputType::accessKeyAction): Added.
+        (WebCore::BaseButtonInputType::storesValueSeparateFromAttribute): Added.
+        * html/BaseButtonInputType.h: Ditto.
+
+        * html/BaseCheckableInputType.cpp:
+        (WebCore::BaseCheckableInputType::canSetStringValue): Added.
+        (WebCore::BaseCheckableInputType::accessKeyAction): Added.
+        (WebCore::BaseCheckableInputType::fallbackValue): Added.
+        (WebCore::BaseCheckableInputType::storesValueSeparateFromAttribute): Added.
+        (WebCore::BaseCheckableInputType::isCheckable): Added.
+        * html/BaseCheckableInputType.h: Ditto.
+
+        * html/BaseDateAndTimeInputType.cpp:
+        (WebCore::BaseDateAndTimeInputType::hasSpinButton): Added.
+        * html/BaseDateAndTimeInputType.h: Ditto.
+
+        * html/BaseTextInputType.h: Made more functions private.
+
+        * html/ButtonInputType.cpp:
+        (WebCore::ButtonInputType::isTextButton): Added.
+        * html/ButtonInputType.h: Ditto.
+
+        * html/CheckboxInputType.cpp:
+        (WebCore::CheckboxInputType::willDispatchClick): Added.
+        (WebCore::CheckboxInputType::didDispatchClick): Added.
+        (WebCore::CheckboxInputType::isCheckbox): Added.
+        * html/CheckboxInputType.h: Ditto.
+
+        * html/DateTimeInputType.cpp:
+        (WebCore::DateTimeInputType::scaledStepValueShouldBeInteger): Fixed
+        typo in name of this function.
+        * html/DateTimeInputType.h: Ditto.
+        * html/DateTimeLocalInputType.cpp:
+        (WebCore::DateTimeLocalInputType::scaledStepValueShouldBeInteger): Ditto.
+        * html/DateTimeLocalInputType.h: Ditto.
+
+        * html/EmailInputType.cpp:
+        (WebCore::EmailInputType::isEmailField): Added.
+        * html/EmailInputType.h: Ditto.
+
+        * html/FileInputType.cpp:
+        (WebCore::FileInputType::FileInputType): Added.
+        (WebCore::FileInputType::canSetStringValue): Added.
+        (WebCore::FileInputType::canChangeFromAnotherType): Added.
+        (WebCore::FileInputType::files): Added.
+        (WebCore::FileInputType::canSetValue): Added.
+        (WebCore::FileInputType::getTypeSpecificValue): Added.
+        (WebCore::FileInputType::storesValueSeparateFromAttribute): Added.
+        (WebCore::FileInputType::setFileList): Added.
+        (WebCore::FileInputType::isFileUpload): Added.
+        * html/FileInputType.h: Ditto.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::HTMLInputElement): Updated for data member
+        renaming and removal.
+        (WebCore::HTMLInputElement::isValidValue): Call canSetStringValue
+        instead of checking specific type numbers.
+        (WebCore::HTMLInputElement::getAllowedValueStepWithDecimalPlaces):
+        Use fastGetAttribute and fixed typo in the name of the
+        scaledStepValueShouldBeInteger function.
+        (WebCore::HTMLInputElement::isKeyboardFocusable): Call
+        InputType::isKeyboardFocusable; moved most of the type-specific
+        logic there.
+        (WebCore::HTMLInputElement::shouldUseInputMethod): Call
+        InputType::shouldUseInputMethod; moved the type-specific logic there.
+        (WebCore::HTMLInputElement::handleBlurEvent): Call
+        InputType::handleBlurEvent; moved the type-specific logic there.
+        (WebCore::HTMLInputElement::setType): Tweak the names and types
+        in this function.
+        (WebCore::HTMLInputElement::updateType): Removed the code that
+        set m_deprecatedTypeNumber. Compare types by comparing the value
+        from formControlType. Removed file-specific logic and instead call
+        InputType::canChangeFromAnotherType. Streamlined the logic for
+        activation callbacks.
+        (WebCore::HTMLInputElement::accessKeyAction): Call
+        InputType::accessKeyAction; moved the type-specific logic there.
+        (WebCore::HTMLInputElement::mapToEntry): Call
+        InputType::shouldRespectHeightAndWidthAttributes and
+        InputType::shouldRespectAlignAttribute.
+        (WebCore::HTMLInputElement::parseMappedAttribute): Updated
+        for name changes and the removal of m_defaultChecked. Changed the
+        alt attribute logic to be based on the class of the renderer.
+        Call InputType::srcAttributeChanged and moved the type-specific
+        logic there. Call shouldRespectAlignAttribute and
+        shouldRespectHeightAndWidthAttributes rather than having
+        type-specific logic here. Call minOrMaxAttributeChanged.
+        (WebCore::HTMLInputElement::rendererIsNeeded): Call
+        InputType::rendererIsNeeded; moved the type-specific logic there.
+        (WebCore::HTMLInputElement::attach): Removed the unneeded m_inited
+        flag, which was redundant with the m_haveType flag. Call
+        InputType::attach; moved the type-specific logic there.
+        (WebCore::HTMLInputElement::altText): Use fastGetAttribute.
+        (WebCore::HTMLInputElement::isSuccessfulSubmitButton): Call
+        InputType::canBeSuccessfulSubmitButton; moved the type-specific
+        logic there.
+        (WebCore::HTMLInputElement::isActivatedSubmit): Updated for
+        name changes.
+        (WebCore::HTMLInputElement::setActivatedSubmit): Ditto.
+        (WebCore::HTMLInputElement::reset): Updated to use
+        InputType::storesValueSeparateFromAttribute. Also use
+        hasAttribute(checkedAttr) rather than m_defaultChecked,
+        since both are the same. Also updated for name change.
+        (WebCore::HTMLInputElement::setChecked): Updated for name
+        changes. Also added call to
+        InputType::shouldSendChangeEventAfterCheckedChanged and
+        moved the type-specific logic there.
+        (WebCore::HTMLInputElement::setIndeterminate): Call
+        isCheckable to see if indeterminate is allowed.
+        Also updated for name changes.
+        (WebCore::HTMLInputElement::copyNonAttributeProperties):
+        Updated for name changes and removed data members.
+        (WebCore::HTMLInputElement::value): Call
+        InputType::getTypeSpecificValue and InputType::fallbackValue.
+        Moved the type-specific logic there.
+        (WebCore::HTMLInputElement::valueWithDefault): Call
+        InputType::defaultValue. Moved the type-specific logic there.
+        (WebCore::HTMLInputElement::setSuggestedValue): Call
+        InputType::canSetSuggestedValue. Moved the type-specific logic
+        there.
+        (WebCore::HTMLInputElement::setValue): Call
+        InputType::canSetValue. Moved the type-specific logic there.
+        Clear the file list if it exists rather than checking the
+        type explicitly. We could probably do that a more elegant way.
+        (WebCore::HTMLInputElement::placeholder): Use fastGetAttribute.
+        (WebCore::HTMLInputElement::setValueFromRenderer): Use the
+        isFileUpload function in the assertion.
+        (WebCore::HTMLInputElement::setFileListFromRenderer): Put most
+        of the code from this function into FileInputType::setFileList.
+        (WebCore::HTMLInputElement::preDispatchEventHandler): Changed
+        to call InputType::willDispatchClick, which does the type-specific
+        work. Still need to use a single struct for all types, because
+        the type of the element could change during the event handling.
+        (WebCore::HTMLInputElement::postDispatchEventHandler): Changed
+        to call InputType::didDispatchClick.
+        (WebCore::HTMLInputElement::defaultValue): Use fastGetAttribute.
+        (WebCore::HTMLInputElement::accept): Use fastGetAttribute.
+        (WebCore::HTMLInputElement::alt): Use fastGetAttribute.
+        (WebCore::HTMLInputElement::src): Use fastGetAttribute.
+        (WebCore::HTMLInputElement::setAutofilled): Updated for name
+        changes.
+        (WebCore::HTMLInputElement::files): Use InputType::files.
+        (WebCore::HTMLInputElement::isAcceptableValue): Use
+        InputType::isAcceptableValue.
+        (WebCore::HTMLInputElement::sanitizeValue): Use
+        InputType::sanitizeValue.
+        (WebCore::HTMLInputElement::hasUnacceptableValue): Use
+        InputType::hasUnacceptableValue.
+        (WebCore::HTMLInputElement::needsActivationCallback): Use
+        InputType::shouldResetOnDocumentActivation.
+        (WebCore::HTMLInputElement::willMoveToNewOwnerDocument): Use
+        InputType::willMoveToNewOwnerDocument.
+        (WebCore::HTMLInputElement::dataList): Use
+        InputType::shouldRespectListAttribute.
+        (WebCore::HTMLInputElement::selectedOption): Tweaked logic
+        and naming a bit.
+        (WebCore::HTMLInputElement::stepUpFromRenderer): Use
+        fastGetAttribute.
+        (WebCore::HTMLInputElement::isSpeechEnabled): Use
+        InputType::shouldRespectSpeechAttribute.
+        (WebCore::HTMLInputElement::isTextButton): No longer inline.
+        Calls through to InputType.
+        (WebCore::HTMLInputElement::isRadioButton): Ditto.
+        (WebCore::HTMLInputElement::isSearchField): Ditto.
+        (WebCore::HTMLInputElement::isInputTypeHidden): Ditto.
+        (WebCore::HTMLInputElement::isPasswordField): Ditto.
+        (WebCore::HTMLInputElement::isCheckbox): Ditto.
+        (WebCore::HTMLInputElement::isText): Ditto.
+        (WebCore::HTMLInputElement::isEmailField): Ditto.
+        (WebCore::HTMLInputElement::isFileUpload): Ditto.
+        (WebCore::HTMLInputElement::isImageButton): Ditto.
+        (WebCore::HTMLInputElement::isNumberField): Ditto.
+        (WebCore::HTMLInputElement::isSubmitButton): Ditto.
+        (WebCore::HTMLInputElement::isTelephoneField): Ditto.
+        (WebCore::HTMLInputElement::isURLField): Ditto.
+        (WebCore::HTMLInputElement::isEnumeratable): Ditto.
+        (WebCore::HTMLInputElement::isChecked): No longer inline.
+        Calls InputType::isCheckable.
+        (WebCore::HTMLInputElement::hasSpinButton): No longer inline.
+        Calls through to InputType.
+        (WebCore::HTMLInputElement::supportsPlaceholder): No longer
+        inline. Calls isTextType as before, but with no special case
+        for ISINDEX. That special case was unneeded since it returns
+        true from isTextType.
+        (WebCore::HTMLInputElement::checkedRadioButtons): No longer
+        inline.
+        (WebCore::HTMLInputElement::handleBeforeTextInsertedEvent):
+        No longer inline.
+
+        * html/HTMLInputElement.h: Removed multiple unneeded includes.
+        The big one is probably InputType.h, but also HTMLFormElement.h.
+        Removed unneeded forward declarations. Made many functions
+        no longer inline since they now need to make virtual function
+        dispatches. Removed the unneeded defaultChecked and
+        webkitdirectory functions. Both are handled by HTML attribute
+        reflection for DOM bindings, and the callers instead can get
+        at the attribute. Made updateCheckedRadioButtons public so it
+        can be called by an InputType class. Removed
+        DeprecatedInputType, InputTypeMap, createTypeMap,
+        deprecatedInputType, allowsIndeterminate,
+        respectHeightAndWidthAttrs, storesValueSeparateFromAttribute,
+        m_imageLoader, m_fileList, m_deprecatedTypeNumber,
+        m_defaultChecked, and m_inited. Renamed m_checked to
+        m_isChecked, m_useDefaultChecked to m_reflectsCheckedAttribute,
+        m_indeterminate tom_isIndeterminate, m_haveType to m_hasType,
+        m_activeSubmit to m_isActivatedSubmit, and m_autofilled to
+        m_isAutofilled.
+        
+        * html/HiddenInputType.cpp:
+        (WebCore::HiddenInputType::accessKeyAction): Added.
+        (WebCore::HiddenInputType::rendererIsNeeded) Added.:
+        (WebCore::HiddenInputType::storesValueSeparateFromAttribute): Added.
+        (WebCore::HiddenInputType::isHiddenType): Added.
+        (WebCore::HiddenInputType::shouldRespectHeightAndWidthAttributes): Added.
+        * html/HiddenInputType.h: Ditto.
+
+        * html/ImageInputType.cpp:
+        (WebCore::ImageInputType::ImageInputType): Moved out of the header file.
+        (WebCore::ImageInputType::srcAttributeChanged): Added.
+        (WebCore::ImageInputType::attach): Added.
+        (WebCore::ImageInputType::willMoveToNewOwnerDocument): Added.
+        (WebCore::ImageInputType::shouldRespectAlignAttribute): Added.
+        (WebCore::ImageInputType::canBeSuccessfulSubmitButton): Added.
+        (WebCore::ImageInputType::isImageButton): Added.
+        (WebCore::ImageInputType::isEnumeratable): Added.
+        (WebCore::ImageInputType::shouldRespectHeightAndWidthAttributes): Added.
+        * html/ImageInputType.h: Ditto.
+
+        * html/InputType.cpp:
+        (WebCore::InputType::create): Changed argument type to String. There
+        is no value in taking an AtomicString here.
+        (WebCore::InputType::scaledStepValueShouldBeInteger): Fixed typo in
+        this function name.
+        (WebCore::InputType::canSetStringValue): Added.
+        (WebCore::InputType::isKeyboardFocusable): Added.
+        (WebCore::InputType::shouldUseInputMethod): Added.
+        (WebCore::InputType::handleBlurEvent): Added.
+        (WebCore::InputType::accessKeyAction): Added.
+        (WebCore::InputType::attach): Added.
+        (WebCore::InputType::srcAttributeChanged): Added.
+        (WebCore::InputType::willMoveToNewOwnerDocument): Added.
+        (WebCore::InputType::shouldRespectAlignAttribute): Added.
+        (WebCore::InputType::canChangeFromAnotherType): Added.
+        (WebCore::InputType::minOrMaxAttributeChanged): Added.
+        (WebCore::InputType::canBeSuccessfulSubmitButton): Added.
+        (WebCore::InputType::rendererIsNeeded): Added.
+        (WebCore::InputType::files): Added.
+        (WebCore::InputType::getTypeSpecificValue): Added.
+        (WebCore::InputType::fallbackValue): Added.
+        (WebCore::InputType::defaultValue): Added.
+        (WebCore::InputType::canSetSuggestedValue): Added.
+        (WebCore::InputType::shouldSendChangeEventAfterCheckedChanged): Added.
+        (WebCore::InputType::storesValueSeparateFromAttribute): Added.
+        (WebCore::InputType::canSetValue): Added.
+        (WebCore::InputType::willDispatchClick): Added.
+        (WebCore::InputType::didDispatchClick): Added.
+        (WebCore::InputType::isAcceptableValue): Added.
+        (WebCore::InputType::sanitizeValue): Added.
+        (WebCore::InputType::hasUnacceptableValue): Added.
+        (WebCore::InputType::setFileList): Added.
+        (WebCore::InputType::shouldResetOnDocumentActivation): Added.
+        (WebCore::InputType::shouldRespectListAttribute): Added.
+        (WebCore::InputType::shouldRespectSpeechAttribute): Added.
+        (WebCore::InputType::isTextButton): Added.
+        (WebCore::InputType::isRadioButton): Added.
+        (WebCore::InputType::isSearchField): Added.
+        (WebCore::InputType::isHiddenType): Added.
+        (WebCore::InputType::isPasswordField): Added.
+        (WebCore::InputType::isCheckbox): Added.
+        (WebCore::InputType::isEmailField): Added.
+        (WebCore::InputType::isFileUpload): Added.
+        (WebCore::InputType::isImageButton): Added.
+        (WebCore::InputType::isNumberField): Added.
+        (WebCore::InputType::isSubmitButton): Added.
+        (WebCore::InputType::isTelephoneField): Added.
+        (WebCore::InputType::isURLField): Added.
+        (WebCore::InputType::isEnumeratable): Added.
+        (WebCore::InputType::isCheckable): Added.
+        (WebCore::InputType::hasSpinButton): Added.
+        (WebCore::InputType::shouldRespectHeightAndWidthAttributes): Added.
+
+        * html/InputType.h: Removed unneeded ExceptionCode.h include and
+        used a typedef instead as we do when we want for forward declare it.
+        Added includes and forward declarations needed for new functions.
+        Added ClickHandlingState structure. Changed the argument to create
+        to a String rather than AtomicString. Added many virtual functions.
+        
+        * html/IsIndexInputType.cpp:
+        (WebCore::IsIndexInputType::shouldRespectListAttribute): Added.
+        * html/IsIndexInputType.h: Ditto.
+
+        * html/NumberInputType.cpp:
+        (WebCore::NumberInputType::handleBlurEvent): Added.
+        (WebCore::NumberInputType::isAcceptableValue): Added.
+        (WebCore::NumberInputType::sanitizeValue): Added.
+        (WebCore::NumberInputType::hasUnacceptableValue): Added.
+        (WebCore::NumberInputType::shouldRespectSpeechAttribute): Added.
+        (WebCore::NumberInputType::isNumberField): Added.
+        (WebCore::NumberInputType::hasSpinButton): Added.
+        * html/NumberInputType.h: Ditto.
+
+        * html/PasswordInputType.cpp:
+        (WebCore::PasswordInputType::shouldUseInputMethod): Added.
+        (WebCore::PasswordInputType::shouldResetOnDocumentActivation): Added.
+        (WebCore::PasswordInputType::shouldRespectListAttribute): Added.
+        (WebCore::PasswordInputType::shouldRespectSpeechAttribute): Added.
+        (WebCore::PasswordInputType::isPasswordField): Added.
+        * html/PasswordInputType.h: Ditto.
+
+        * html/RadioInputType.cpp:
+        (WebCore::RadioInputType::isKeyboardFocusable): Added.
+        (WebCore::RadioInputType::attach): Added.
+        (WebCore::RadioInputType::shouldSendChangeEventAfterCheckedChanged): Added.
+        (WebCore::RadioInputType::willDispatchClick): Added.
+        (WebCore::RadioInputType::didDispatchClick): Added.
+        (WebCore::RadioInputType::isRadioButton): Added.
+        * html/RadioInputType.h: Ditto.
+
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::accessKeyAction): Added.
+        (WebCore::RangeInputType::minOrMaxAttributeChanged): Added.
+        (WebCore::RangeInputType::fallbackValue): Added.
+        (WebCore::RangeInputType::sanitizeValue): Added.
+        (WebCore::RangeInputType::shouldRespectListAttribute): Added.
+        * html/RangeInputType.h: Ditto.
+
+        * html/ResetInputType.cpp:
+        (WebCore::ResetInputType::defaultValue): Added.
+        (WebCore::ResetInputType::isTextButton): Added.
+        * html/ResetInputType.h: Ditto.
+
+        * html/SearchInputType.cpp:
+        (WebCore::SearchInputType::shouldRespectSpeechAttribute): Added.
+        (WebCore::SearchInputType::isSearchField): Added.
+        * html/SearchInputType.h: Ditto.
+
+        * html/SubmitInputType.cpp:
+        (WebCore::SubmitInputType::canBeSuccessfulSubmitButton): Added.
+        (WebCore::SubmitInputType::defaultValue): Added.
+        (WebCore::SubmitInputType::isSubmitButton): Added.
+        (WebCore::SubmitInputType::isTextButton): Added.
+        * html/SubmitInputType.h: Ditto.
+
+        * html/TelephoneInputType.cpp:
+        (WebCore::TelephoneInputType::shouldRespectSpeechAttribute): Added.
+        (WebCore::TelephoneInputType::isTelephoneField): Added.
+        * html/TelephoneInputType.h: Ditto.
+
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::shouldUseInputMethod): Added.
+        (WebCore::TextFieldInputType::sanitizeValue): Added.
+        (WebCore::TextFieldInputType::shouldRespectListAttribute): Added.
+        * html/TextFieldInputType.h: Ditto.
+
+        * html/TextInputType.cpp:
+        (WebCore::TextInputType::canSetSuggestedValue): Added.
+        (WebCore::TextInputType::shouldRespectSpeechAttribute): Added.
+        * html/TextInputType.h: Ditto.
+
+        * html/TimeInputType.cpp:
+        (WebCore::TimeInputType::scaledStepValueShouldBeInteger): Fixed
+        typo in the name of this function.
+        * html/TimeInputType.h: Ditto.
+
+        * html/URLInputType.cpp:
+        (WebCore::URLInputType::isURLField): Added.
+        * html/URLInputType.h: Ditto.
+
 2011-01-03  Mihai Parparita  <mihaip at chromium.org>
 
         Unreviewed.
diff --git a/WebCore/dom/InputElement.h b/WebCore/dom/InputElement.h
index 34784bc..2d5606d 100644
--- a/WebCore/dom/InputElement.h
+++ b/WebCore/dom/InputElement.h
@@ -75,6 +75,12 @@ public:
     static const int s_maximumLength;
     static const int s_defaultSize;
 
+    // Replaces CRs and LFs, shrinks the value for s_maximumLength.
+    // This should be applied to values from the HTML value attribute and the DOM value property.
+    // This function should be called only by sanitizeValue() implementations.
+    // Public so it can be called by InputType.
+    static String sanitizeValueForTextField(const InputElement*, const String&);
+
 protected:
     static void dispatchFocusEvent(InputElement*, Element*);
     static void dispatchBlurEvent(InputElement*, Element*);
@@ -82,10 +88,6 @@ protected:
     static void updateSelectionRange(InputElement*, Element*, int start, int end);
     static void aboutToUnload(InputElement*, Element*);
     static void setValueFromRenderer(InputElementData&, InputElement*, Element*, const String&);
-    // Replaces CRs and LFs, shrinks the value for s_maximumLength.
-    // This should be applied to values from the HTML value attribute and the DOM value property.
-    // This function should be called only by sanitizeValue() implementations.
-    static String sanitizeValueForTextField(const InputElement*, const String&);
     // Replaces CRs and LFs, shrinks the value for the specified maximum length.
     // This should be applied to values specified by users.
     // The input string may be a fragment of the whole value.
diff --git a/WebCore/html/BaseButtonInputType.cpp b/WebCore/html/BaseButtonInputType.cpp
index c8ffd37..93fe873 100644
--- a/WebCore/html/BaseButtonInputType.cpp
+++ b/WebCore/html/BaseButtonInputType.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -81,4 +82,19 @@ RenderObject* BaseButtonInputType::createRenderer(RenderArena* arena, RenderStyl
     return new (arena) RenderButton(element());
 }
 
+// FIXME: Could share this with BaseCheckableInputType and RangeInputType if we had a common base class.
+void BaseButtonInputType::accessKeyAction(bool sendToAnyElement)
+{
+    InputType::accessKeyAction(sendToAnyElement);
+
+    // Send mouse button events if the caller specified sendToAnyElement.
+    // FIXME: The comment above is no good. It says what we do, but not why.
+    element()->dispatchSimulatedClick(0, sendToAnyElement);
+}
+
+bool BaseButtonInputType::storesValueSeparateFromAttribute()
+{
+    return false;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/BaseButtonInputType.h b/WebCore/html/BaseButtonInputType.h
index 9c3a564..1607f3c 100644
--- a/WebCore/html/BaseButtonInputType.h
+++ b/WebCore/html/BaseButtonInputType.h
@@ -46,6 +46,8 @@ private:
     virtual void handleKeypressEvent(KeyboardEvent*);
     virtual void handleKeyupEvent(KeyboardEvent*);
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
+    virtual void accessKeyAction(bool sendToAnyElement);
+    virtual bool storesValueSeparateFromAttribute();
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/BaseCheckableInputType.cpp b/WebCore/html/BaseCheckableInputType.cpp
index e089945..b08bae3 100644
--- a/WebCore/html/BaseCheckableInputType.cpp
+++ b/WebCore/html/BaseCheckableInputType.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -76,4 +77,34 @@ void BaseCheckableInputType::handleKeypressEvent(KeyboardEvent* event)
     }
 }
 
+bool BaseCheckableInputType::canSetStringValue() const
+{
+    return false;
+}
+
+// FIXME: Could share this with BaseButtonInputType and RangeInputType if we had a common base class.
+void BaseCheckableInputType::accessKeyAction(bool sendToAnyElement)
+{
+    InputType::accessKeyAction(sendToAnyElement);
+
+    // Send mouse button events if the caller specified sendToAnyElement.
+    // FIXME: The comment above is no good. It says what we do, but not why.
+    element()->dispatchSimulatedClick(0, sendToAnyElement);
+}
+
+String BaseCheckableInputType::fallbackValue()
+{
+    return element()->checked() ? "on" : "";
+}
+
+bool BaseCheckableInputType::storesValueSeparateFromAttribute()
+{
+    return false;
+}
+
+bool BaseCheckableInputType::isCheckable()
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/BaseCheckableInputType.h b/WebCore/html/BaseCheckableInputType.h
index a9bbc76..2515003 100644
--- a/WebCore/html/BaseCheckableInputType.h
+++ b/WebCore/html/BaseCheckableInputType.h
@@ -46,6 +46,11 @@ private:
     virtual void restoreFormControlState(const String&) const;
     virtual bool appendFormData(FormDataList&, bool) const;
     virtual void handleKeypressEvent(KeyboardEvent*);
+    virtual bool canSetStringValue() const;
+    virtual void accessKeyAction(bool sendToAnyElement);
+    virtual String fallbackValue();
+    virtual bool storesValueSeparateFromAttribute();
+    virtual bool isCheckable();
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/BaseDateAndTimeInputType.cpp b/WebCore/html/BaseDateAndTimeInputType.cpp
index 1974830..b672e51 100644
--- a/WebCore/html/BaseDateAndTimeInputType.cpp
+++ b/WebCore/html/BaseDateAndTimeInputType.cpp
@@ -174,4 +174,9 @@ String BaseDateAndTimeInputType::serialize(double value) const
     return date.toString(DateComponents::Millisecond);
 }
 
+bool BaseDateAndTimeInputType::hasSpinButton()
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/BaseDateAndTimeInputType.h b/WebCore/html/BaseDateAndTimeInputType.h
index c4b3046..867115d 100644
--- a/WebCore/html/BaseDateAndTimeInputType.h
+++ b/WebCore/html/BaseDateAndTimeInputType.h
@@ -42,11 +42,10 @@ protected:
     BaseDateAndTimeInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
     virtual double parseToDouble(const String&, double) const;
     virtual bool parseToDateComponents(const String&, DateComponents*) const;
-    // A helper for parseToDateComponents().
-    virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const = 0;
-    virtual bool setMillisecondToDateComponents(double, DateComponents*) const = 0;
 
 private:
+    virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const = 0;
+    virtual bool setMillisecondToDateComponents(double, DateComponents*) const = 0;
     virtual double valueAsDate() const;
     virtual void setValueAsDate(double, ExceptionCode&) const;
     virtual double valueAsNumber() const;
@@ -62,6 +61,7 @@ private:
     virtual void handleKeydownEvent(KeyboardEvent*);
     virtual void handleWheelEvent(WheelEvent*);
     virtual String serialize(double) const;
+    virtual bool hasSpinButton();
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/BaseTextInputType.h b/WebCore/html/BaseTextInputType.h
index 9bd6c6d..874e2a7 100644
--- a/WebCore/html/BaseTextInputType.h
+++ b/WebCore/html/BaseTextInputType.h
@@ -40,6 +40,8 @@ namespace WebCore {
 class BaseTextInputType : public TextFieldInputType {
 protected:
     BaseTextInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
+
+private:
     virtual bool isTextType() const;
     virtual bool patternMismatch(const String&) const;
 };
diff --git a/WebCore/html/ButtonInputType.cpp b/WebCore/html/ButtonInputType.cpp
index deaf30f..3af4720 100644
--- a/WebCore/html/ButtonInputType.cpp
+++ b/WebCore/html/ButtonInputType.cpp
@@ -50,4 +50,9 @@ bool ButtonInputType::supportsValidation() const
     return false;
 }
 
+bool ButtonInputType::isTextButton() const
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/ButtonInputType.h b/WebCore/html/ButtonInputType.h
index f016114..f6f87a6 100644
--- a/WebCore/html/ButtonInputType.h
+++ b/WebCore/html/ButtonInputType.h
@@ -43,6 +43,7 @@ private:
     ButtonInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
     virtual const AtomicString& formControlType() const;
     virtual bool supportsValidation() const;
+    virtual bool isTextButton() const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/CheckboxInputType.cpp b/WebCore/html/CheckboxInputType.cpp
index 8f987c8..39f9c7b 100644
--- a/WebCore/html/CheckboxInputType.cpp
+++ b/WebCore/html/CheckboxInputType.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -66,4 +67,38 @@ void CheckboxInputType::handleKeyupEvent(KeyboardEvent* event)
     dispatchSimulatedClickIfActive(event);
 }
 
+PassOwnPtr<ClickHandlingState> CheckboxInputType::willDispatchClick()
+{
+    // An event handler can use preventDefault or "return false" to reverse the checking we do here.
+    // The ClickHandlingState object contains what we need to undo what we did here in didDispatchClick.
+
+    OwnPtr<ClickHandlingState> state = adoptPtr(new ClickHandlingState);
+
+    state->checked = element()->checked();
+    state->indeterminate = element()->indeterminate();
+
+    if (state->indeterminate)
+        element()->setIndeterminate(false);
+    else
+        element()->setChecked(!state->checked, true);
+
+    return state.release();
+}
+
+void CheckboxInputType::didDispatchClick(Event* event, const ClickHandlingState& state)
+{
+    if (event->defaultPrevented() || event->defaultHandled()) {
+        element()->setIndeterminate(state.indeterminate);
+        element()->setChecked(state.checked);
+    }
+
+    // The work we did in willDispatchClick was default handling.
+    event->setDefaultHandled();
+}
+
+bool CheckboxInputType::isCheckbox() const
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/CheckboxInputType.h b/WebCore/html/CheckboxInputType.h
index a58a0a3..76725e7 100644
--- a/WebCore/html/CheckboxInputType.h
+++ b/WebCore/html/CheckboxInputType.h
@@ -45,6 +45,9 @@ private:
     virtual bool valueMissing(const String&) const;
     virtual String valueMissingText() const;
     virtual void handleKeyupEvent(KeyboardEvent*);
+    virtual PassOwnPtr<ClickHandlingState> willDispatchClick();
+    virtual void didDispatchClick(Event*, const ClickHandlingState&);
+    virtual bool isCheckbox() const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/DateTimeInputType.cpp b/WebCore/html/DateTimeInputType.cpp
index 78641f8..2acb997 100644
--- a/WebCore/html/DateTimeInputType.cpp
+++ b/WebCore/html/DateTimeInputType.cpp
@@ -79,7 +79,7 @@ double DateTimeInputType::stepScaleFactor() const
     return dateTimeStepScaleFactor;
 }
 
-bool DateTimeInputType::scaledStepValeuShouldBeInteger() const
+bool DateTimeInputType::scaledStepValueShouldBeInteger() const
 {
     return true;
 }
diff --git a/WebCore/html/DateTimeInputType.h b/WebCore/html/DateTimeInputType.h
index 9a0efd1..1b9e06c 100644
--- a/WebCore/html/DateTimeInputType.h
+++ b/WebCore/html/DateTimeInputType.h
@@ -47,7 +47,7 @@ private:
     virtual double maximum() const;
     virtual double defaultStep() const;
     virtual double stepScaleFactor() const;
-    virtual bool scaledStepValeuShouldBeInteger() const;
+    virtual bool scaledStepValueShouldBeInteger() const;
     virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const;
     virtual bool setMillisecondToDateComponents(double, DateComponents*) const;
 };
diff --git a/WebCore/html/DateTimeLocalInputType.cpp b/WebCore/html/DateTimeLocalInputType.cpp
index 1ec2a47..361fad7 100644
--- a/WebCore/html/DateTimeLocalInputType.cpp
+++ b/WebCore/html/DateTimeLocalInputType.cpp
@@ -85,7 +85,7 @@ double DateTimeLocalInputType::stepScaleFactor() const
     return dateTimeLocalStepScaleFactor;
 }
 
-bool DateTimeLocalInputType::scaledStepValeuShouldBeInteger() const
+bool DateTimeLocalInputType::scaledStepValueShouldBeInteger() const
 {
     return true;
 }
diff --git a/WebCore/html/DateTimeLocalInputType.h b/WebCore/html/DateTimeLocalInputType.h
index 966e294..ae118af 100644
--- a/WebCore/html/DateTimeLocalInputType.h
+++ b/WebCore/html/DateTimeLocalInputType.h
@@ -48,7 +48,7 @@ private:
     virtual double maximum() const;
     virtual double defaultStep() const;
     virtual double stepScaleFactor() const;
-    virtual bool scaledStepValeuShouldBeInteger() const;
+    virtual bool scaledStepValueShouldBeInteger() const;
     virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const;
     virtual bool setMillisecondToDateComponents(double, DateComponents*) const;
 };
diff --git a/WebCore/html/EmailInputType.cpp b/WebCore/html/EmailInputType.cpp
index e61129e..5d153a1 100644
--- a/WebCore/html/EmailInputType.cpp
+++ b/WebCore/html/EmailInputType.cpp
@@ -85,4 +85,9 @@ String EmailInputType::typeMismatchText() const
     return element()->multiple() ? validationMessageTypeMismatchForMultipleEmailText() : validationMessageTypeMismatchForEmailText();
 }
 
+bool EmailInputType::isEmailField() const
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/EmailInputType.h b/WebCore/html/EmailInputType.h
index 771715a..b94ae9c 100644
--- a/WebCore/html/EmailInputType.h
+++ b/WebCore/html/EmailInputType.h
@@ -45,6 +45,7 @@ private:
     virtual bool typeMismatchFor(const String&) const;
     virtual bool typeMismatch() const;
     virtual String typeMismatchText() const;
+    virtual bool isEmailField() const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/FileInputType.cpp b/WebCore/html/FileInputType.cpp
index 0e0e357..a4d1dd3 100644
--- a/WebCore/html/FileInputType.cpp
+++ b/WebCore/html/FileInputType.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Google Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
@@ -25,8 +25,10 @@
 #include "Event.h"
 #include "File.h"
 #include "FileList.h"
+#include "FileSystem.h"
 #include "FormDataList.h"
 #include "HTMLInputElement.h"
+#include "HTMLNames.h"
 #include "LocalizedStrings.h"
 #include "RenderFileUploadControl.h"
 #include <wtf/PassOwnPtr.h>
@@ -34,6 +36,14 @@
 
 namespace WebCore {
 
+using namespace HTMLNames;
+
+inline FileInputType::FileInputType(HTMLInputElement* element)
+    : BaseButtonInputType(element)
+    , m_fileList(FileList::create())
+{
+}
+
 PassOwnPtr<InputType> FileInputType::create(HTMLInputElement* element)
 {
     return adoptPtr(new FileInputType(element));
@@ -96,4 +106,91 @@ RenderObject* FileInputType::createRenderer(RenderArena* arena, RenderStyle*) co
     return new (arena) RenderFileUploadControl(element());
 }
 
+bool FileInputType::canSetStringValue() const
+{
+    return false;
+}
+
+bool FileInputType::canChangeFromAnotherType() const
+{
+    // Don't allow the type to be changed to file after the first type change.
+    // In other engines this might mean a JavaScript programmer could set a text
+    // field's value to something like /etc/passwd and then change it to a file input.
+    // I don't think this would actually occur in WebKit, but this rule still may be
+    // important for compatibility.
+    return false;
+}
+
+FileList* FileInputType::files()
+{
+    return m_fileList.get();
+}
+
+bool FileInputType::canSetValue(const String& value)
+{
+    // For security reasons, we don't allow setting the filename, but we do allow clearing it.
+    // The HTML5 spec (as of the 10/24/08 working draft) says that the value attribute isn't
+    // applicable to the file upload control at all, but for now we are keeping this behavior
+    // to avoid breaking existing websites that may be relying on this.
+    return value.isEmpty();
+}
+
+bool FileInputType::getTypeSpecificValue(String& value)
+{
+    if (m_fileList->isEmpty()) {
+        value = String();
+        return true;
+    }
+
+    // HTML5 tells us that we're supposed to use this goofy value for
+    // file input controls. Historically, browsers revealed the real
+    // file path, but that's a privacy problem. Code on the web
+    // decided to try to parse the value by looking for backslashes
+    // (because that's what Windows file paths use). To be compatible
+    // with that code, we make up a fake path for the file.
+    value = "C:\\fakepath\\" + m_fileList->item(0)->fileName();
+    return true;
+}
+
+bool FileInputType::storesValueSeparateFromAttribute()
+{
+    return true;
+}
+
+void FileInputType::setFileList(const Vector<String>& paths)
+{
+    m_fileList->clear();
+    size_t size = paths.size();
+
+#if ENABLE(DIRECTORY_UPLOAD)
+    // If a directory is being selected, the UI allows a directory to be chosen
+    // and the paths provided here share a root directory somewhere up the tree;
+    // we want to store only the relative paths from that point.
+    if (size && element()->fastHasAttribute(webkitdirectoryAttr)) {
+        // Find the common root path.
+        String rootPath = directoryName(paths[0]);
+        for (size_t i = 1; i < size; i++) {
+            while (!paths[i].startsWith(rootPath))
+                rootPath = directoryName(rootPath);
+        }
+        rootPath = directoryName(rootPath);
+        ASSERT(rootPath.length());
+        for (size_t i = 0; i < size; i++) {
+            // Normalize backslashes to slashes before exposing the relative path to script.
+            String relativePath = paths[i].substring(1 + rootPath.length()).replace('\\', '/');
+            m_fileList->append(File::create(relativePath, paths[i]));
+        }
+        return;
+    }
+#endif
+
+    for (size_t i = 0; i < size; i++)
+        m_fileList->append(File::create(paths[i]));
+}
+
+bool FileInputType::isFileUpload() const
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/FileInputType.h b/WebCore/html/FileInputType.h
index a8dad43..6d79ecd 100644
--- a/WebCore/html/FileInputType.h
+++ b/WebCore/html/FileInputType.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -32,21 +33,34 @@
 #define FileInputType_h
 
 #include "BaseButtonInputType.h"
+#include <wtf/RefPtr.h>
 
 namespace WebCore {
 
+class FileList;
+
 class FileInputType : public BaseButtonInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    FileInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
+    FileInputType(HTMLInputElement*);
     virtual const AtomicString& formControlType() const;
     virtual bool appendFormData(FormDataList&, bool) const;
     virtual bool valueMissing(const String&) const;
     virtual String valueMissingText() const;
     virtual void handleDOMActivateEvent(Event*);
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
+    virtual bool canSetStringValue() const;
+    virtual bool canChangeFromAnotherType() const;
+    virtual FileList* files();
+    virtual bool canSetValue(const String&);
+    virtual bool getTypeSpecificValue(String&); // Checked first, before internal storage or the value attribute.
+    virtual bool storesValueSeparateFromAttribute();
+    virtual void setFileList(const Vector<String>& paths);
+    virtual bool isFileUpload() const;
+
+    RefPtr<FileList> m_fileList;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index d1e1eeb..007639b 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll at kde.org)
  *           (C) 1999 Antti Koivisto (koivisto at kde.org)
  *           (C) 2001 Dirk Mueller (mueller at kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
  *           (C) 2006 Alexey Proskuryakov (ap at nypop.com)
  * Copyright (C) 2007 Samuel Weinig (sam at webkit.org)
  * Copyright (C) 2010 Google Inc. All rights reserved.
@@ -31,23 +31,13 @@
 #include "Attribute.h"
 #include "BeforeTextInsertedEvent.h"
 #include "CSSPropertyNames.h"
-#include "ChromeClient.h"
-#include "DateComponents.h"
 #include "Document.h"
-#include "Editor.h"
-#include "Event.h"
-#include "EventHandler.h"
 #include "EventNames.h"
 #include "ExceptionCode.h"
-#include "File.h"
 #include "FileList.h"
-#include "FileSystem.h"
-#include "FocusController.h"
-#include "FormDataList.h"
-#include "Frame.h"
+#include "HTMLCollection.h"
 #include "HTMLDataListElement.h"
 #include "HTMLFormElement.h"
-#include "HTMLImageLoader.h"
 #include "HTMLNames.h"
 #include "HTMLOptionElement.h"
 #include "HTMLParserIdioms.h"
@@ -55,22 +45,13 @@
 #include "KeyboardEvent.h"
 #include "LocalizedStrings.h"
 #include "MouseEvent.h"
-#include "Page.h"
-#include "RenderFileUploadControl.h"
-#include "RenderImage.h"
-#include "RenderSlider.h"
 #include "RenderTextControlSingleLine.h"
 #include "RenderTheme.h"
 #include "RuntimeEnabledFeatures.h"
 #include "ScriptEventListener.h"
-#include "Settings.h"
-#include "StepRange.h"
-#include "TextEvent.h"
 #include "WheelEvent.h"
-#include <wtf/HashMap.h>
 #include <wtf/MathExtras.h>
 #include <wtf/StdLibExtras.h>
-#include <wtf/text/StringHash.h>
 
 using namespace std;
 
@@ -83,16 +64,13 @@ const int maxSavedResults = 256;
 HTMLInputElement::HTMLInputElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
     : HTMLTextFormControlElement(tagName, document, form)
     , m_maxResults(-1)
-    , m_deprecatedTypeNumber(TEXT)
-    , m_checked(false)
-    , m_defaultChecked(false)
-    , m_useDefaultChecked(true)
-    , m_indeterminate(false)
-    , m_haveType(false)
-    , m_activeSubmit(false)
+    , m_isChecked(false)
+    , m_reflectsCheckedAttribute(true)
+    , m_isIndeterminate(false)
+    , m_hasType(false)
+    , m_isActivatedSubmit(false)
     , m_autocomplete(Uninitialized)
-    , m_autofilled(false)
-    , m_inited(false)
+    , m_isAutofilled(false)
     , m_inputType(InputType::createText(this))
 {
     ASSERT(hasTagName(inputTag) || hasTagName(isindexTag));
@@ -167,9 +145,7 @@ void HTMLInputElement::updateCheckedRadioButtons()
 
 bool HTMLInputElement::isValidValue(const String& value) const
 {
-    // Should not call isValidValue() for the following types because
-    // we can't set string values for these types.
-    if (deprecatedInputType() == CHECKBOX || deprecatedInputType() == FILE || deprecatedInputType() == RADIO) {
+    if (!m_inputType->canSetStringValue()) {
         ASSERT_NOT_REACHED();
         return false;
     }
@@ -293,7 +269,7 @@ bool HTMLInputElement::getAllowedValueStepWithDecimalPlaces(double* step, unsign
     double stepScaleFactor = m_inputType->stepScaleFactor();
     if (!isfinite(defaultStep) || !isfinite(stepScaleFactor))
         return false;
-    const AtomicString& stepString = getAttribute(stepAttr);
+    const AtomicString& stepString = fastGetAttribute(stepAttr);
     if (stepString.isEmpty()) {
         *step = defaultStep * stepScaleFactor;
         if (decimalPlaces)
@@ -320,7 +296,7 @@ bool HTMLInputElement::getAllowedValueStepWithDecimalPlaces(double* step, unsign
         parsed = max(round(parsed), 1.0);
     double result = parsed * stepScaleFactor;
     // For datetime, datetime-local, time, the result should be an integer.
-    if (m_inputType->scaledStepValeuShouldBeInteger())
+    if (m_inputType->scaledStepValueShouldBeInteger())
         result = max(round(result), 1.0);
     ASSERT(result > 0);
     *step = result;
@@ -389,33 +365,9 @@ void HTMLInputElement::stepDown(int n, ExceptionCode& ec)
 
 bool HTMLInputElement::isKeyboardFocusable(KeyboardEvent* event) const
 {
-    // If text fields can be focused, then they should always be keyboard focusable
     if (isTextField())
         return HTMLFormControlElementWithState::isFocusable();
-        
-    // If the base class says we can't be focused, then we can stop now.
-    if (!HTMLFormControlElementWithState::isKeyboardFocusable(event))
-        return false;
-
-    if (deprecatedInputType() == RADIO) {
-        // When using Spatial Navigation, every radio button should be focusable.
-        if (isSpatialNavigationEnabled(document()->frame()))
-            return true;
-
-        // Never allow keyboard tabbing to leave you in the same radio group.  Always
-        // skip any other elements in the group.
-        Node* currentFocusedNode = document()->focusedNode();
-        if (currentFocusedNode && currentFocusedNode->hasTagName(inputTag)) {
-            HTMLInputElement* focusedInput = static_cast<HTMLInputElement*>(currentFocusedNode);
-            if (focusedInput->deprecatedInputType() == RADIO && focusedInput->form() == form() && focusedInput->name() == name())
-                return false;
-        }
-        
-        // Allow keyboard focus if we're checked or if nothing in the group is checked.
-        return checked() || !checkedRadioButtons().checkedButtonForGroup(name());
-    }
-    
-    return true;
+    return HTMLFormControlElementWithState::isKeyboardFocusable(event) && m_inputType->isKeyboardFocusable();
 }
 
 bool HTMLInputElement::isMouseFocusable() const
@@ -440,11 +392,7 @@ void HTMLInputElement::aboutToUnload()
 
 bool HTMLInputElement::shouldUseInputMethod() const
 {
-    // The reason IME's are disabled for the password field is because IMEs 
-    // can access the underlying password and display it in clear text --
-    // e.g. you can use it to access the stored password for any site 
-    // with only trivial effort.
-    return isTextField() && deprecatedInputType() != PASSWORD;
+    return m_inputType->shouldUseInputMethod();
 }
 
 void HTMLInputElement::handleFocusEvent()
@@ -454,135 +402,92 @@ void HTMLInputElement::handleFocusEvent()
 
 void HTMLInputElement::handleBlurEvent()
 {
-    if (deprecatedInputType() == NUMBER) {
-        // Reset the renderer value, which might be unmatched with the element value.
-        setFormControlValueMatchesRenderer(false);
-        // We need to reset the renderer value explicitly because an unacceptable
-        // renderer value should be purged before style calculation.
-        if (renderer())
-            renderer()->updateFromElement();
-    }
+    m_inputType->handleBlurEvent();
     InputElement::dispatchBlurEvent(this, this);
 }
 
-void HTMLInputElement::setType(const String& t)
+void HTMLInputElement::setType(const String& type)
 {
     // FIXME: This should just call setAttribute. No reason to handle the empty string specially.
     // We should write a test case to show that setting to the empty string does not remove the
     // attribute in other browsers and then fix this. Note that setting to null *does* remove
     // the attribute and setAttribute implements that.
-    if (t.isEmpty()) {
-        int exccode;
-        removeAttribute(typeAttr, exccode);
+    if (type.isEmpty()) {
+        ExceptionCode ec;
+        removeAttribute(typeAttr, ec);
     } else
-        setAttribute(typeAttr, t);
-}
-
-PassOwnPtr<HTMLInputElement::InputTypeMap> HTMLInputElement::createTypeMap()
-{
-    OwnPtr<InputTypeMap> map = adoptPtr(new InputTypeMap);
-    map->add("button", BUTTON);
-    map->add("checkbox", CHECKBOX);
-    map->add("color", COLOR);
-    map->add("date", DATE);
-    map->add("datetime", DATETIME);
-    map->add("datetime-local", DATETIMELOCAL);
-    map->add("email", EMAIL);
-    map->add("file", FILE);
-    map->add("hidden", HIDDEN);
-    map->add("image", IMAGE);
-    map->add("khtml_isindex", ISINDEX);
-    map->add("month", MONTH);
-    map->add("number", NUMBER);
-    map->add("password", PASSWORD);
-    map->add("radio", RADIO);
-    map->add("range", RANGE);
-    map->add("reset", RESET);
-    map->add("search", SEARCH);
-    map->add("submit", SUBMIT);
-    map->add("tel", TELEPHONE);
-    map->add("time", TIME);
-    map->add("url", URL);
-    map->add("week", WEEK);
-    // No need to register "text" because it is the default type.
-    return map.release();
+        setAttribute(typeAttr, type);
 }
 
 void HTMLInputElement::updateType()
 {
-    static const InputTypeMap* typeMap = createTypeMap().leakPtr();
     const AtomicString& typeString = fastGetAttribute(typeAttr);
-    DeprecatedInputType newType = typeString.isEmpty() ? TEXT : typeMap->get(typeString);
-
-    // IMPORTANT: Don't allow the type to be changed to FILE after the first
-    // type change, otherwise a JavaScript programmer would be able to set a text
-    // field's value to something like /etc/passwd and then change it to a file field.
-    if (deprecatedInputType() != newType) {
-        if (newType == FILE && m_haveType)
-            // Set the attribute back to the old value.
-            // Useful in case we were called from inside parseMappedAttribute.
-            setAttribute(typeAttr, type());
-        else {
-            checkedRadioButtons().removeButton(this);
-
-            if (newType == FILE && !m_fileList)
-                m_fileList = FileList::create();
-
-            bool wasAttached = attached();
-            if (wasAttached)
-                detach();
-
-            bool didStoreValue = storesValueSeparateFromAttribute();
-            bool wasPasswordField = deprecatedInputType() == PASSWORD;
-            bool didRespectHeightAndWidth = respectHeightAndWidthAttrs();
-            m_deprecatedTypeNumber = newType;
-            m_inputType = InputType::create(this, typeString);
-            setNeedsWillValidateCheck();
-            bool willStoreValue = storesValueSeparateFromAttribute();
-            bool isPasswordField = deprecatedInputType() == PASSWORD;
-            bool willRespectHeightAndWidth = respectHeightAndWidthAttrs();
-
-            if (didStoreValue && !willStoreValue && !m_data.value().isNull()) {
-                setAttribute(valueAttr, m_data.value());
-                m_data.setValue(String());
-            }
-            if (!didStoreValue && willStoreValue)
-                m_data.setValue(sanitizeValue(getAttribute(valueAttr)));
-            else
-                InputElement::updateValueIfNeeded(m_data, this);
 
-            if (wasPasswordField && !isPasswordField)
-                unregisterForActivationCallbackIfNeeded();
-            else if (!wasPasswordField && isPasswordField)
-                registerForActivationCallbackIfNeeded();
-
-            if (didRespectHeightAndWidth != willRespectHeightAndWidth) {
-                NamedNodeMap* map = attributeMap();
-                ASSERT(map);
-                if (Attribute* height = map->getAttributeItem(heightAttr))
-                    attributeChanged(height, false);
-                if (Attribute* width = map->getAttributeItem(widthAttr))
-                    attributeChanged(width, false);
-                if (Attribute* align = map->getAttributeItem(alignAttr))
-                    attributeChanged(align, false);
-            }
-
-            if (wasAttached) {
-                attach();
-                if (document()->focusedNode() == this)
-                    updateFocusAppearance(true);
-            }
-
-            checkedRadioButtons().addButton(this);
-        }
+    OwnPtr<InputType> newType = InputType::create(this, typeString);
 
-        setNeedsValidityCheck();
-        InputElement::notifyFormStateChanged(this);
+    if (m_hasType && !newType->canChangeFromAnotherType()) {
+        // Set the attribute back to the old value.
+        // Useful in case we were called from inside parseMappedAttribute.
+        setAttribute(typeAttr, type());
+        return;
     }
-    m_haveType = true;
 
-    if (deprecatedInputType() != IMAGE && m_imageLoader)
-        m_imageLoader.clear();
+    m_hasType = true;
+
+    if (m_inputType->formControlType() == newType->formControlType())
+        return;
+
+    checkedRadioButtons().removeButton(this);
+
+    bool wasAttached = attached();
+    if (wasAttached)
+        detach();
+
+    bool didStoreValue = m_inputType->storesValueSeparateFromAttribute();
+    bool neededActivationCallback = needsActivationCallback();
+    bool didRespectHeightAndWidth = m_inputType->shouldRespectHeightAndWidthAttributes();
+
+    m_inputType = newType.release();
+
+    setNeedsWillValidateCheck();
+
+    bool willStoreValue = m_inputType->storesValueSeparateFromAttribute();
+
+    if (didStoreValue && !willStoreValue && !m_data.value().isNull()) {
+        setAttribute(valueAttr, m_data.value());
+        m_data.setValue(String());
+    }
+    if (!didStoreValue && willStoreValue)
+        m_data.setValue(sanitizeValue(fastGetAttribute(valueAttr)));
+    else
+        InputElement::updateValueIfNeeded(m_data, this);
+
+    if (neededActivationCallback)
+        unregisterForActivationCallbackIfNeeded();
+    else
+        registerForActivationCallbackIfNeeded();
+
+    if (didRespectHeightAndWidth != m_inputType->shouldRespectHeightAndWidthAttributes()) {
+        NamedNodeMap* map = attributeMap();
+        ASSERT(map);
+        if (Attribute* height = map->getAttributeItem(heightAttr))
+            attributeChanged(height, false);
+        if (Attribute* width = map->getAttributeItem(widthAttr))
+            attributeChanged(width, false);
+        if (Attribute* align = map->getAttributeItem(alignAttr))
+            attributeChanged(align, false);
+    }
+
+    if (wasAttached) {
+        attach();
+        if (document()->focusedNode() == this)
+            updateFocusAppearance(true);
+    }
+
+    checkedRadioButtons().addButton(this);
+
+    setNeedsValidityCheck();
+    InputElement::notifyFormStateChanged(this);
 }
 
 const AtomicString& HTMLInputElement::formControlType() const
@@ -614,58 +519,22 @@ bool HTMLInputElement::canHaveSelection() const
 
 void HTMLInputElement::accessKeyAction(bool sendToAnyElement)
 {
-    switch (deprecatedInputType()) {
-    case BUTTON:
-    case CHECKBOX:
-    case FILE:
-    case IMAGE:
-    case RADIO:
-    case RANGE:
-    case RESET:
-    case SUBMIT:
-        focus(false);
-        // send the mouse button events iff the caller specified sendToAnyElement
-        dispatchSimulatedClick(0, sendToAnyElement);
-        break;
-    case HIDDEN:
-        // a no-op for this type
-        break;
-    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:
-        // should never restore previous selection here
-        focus(false);
-         break;
-    }
+    m_inputType->accessKeyAction(sendToAnyElement);
 }
 
 bool HTMLInputElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
 {
-    if (((attrName == heightAttr || attrName == widthAttr) && respectHeightAndWidthAttrs())
+    if (((attrName == heightAttr || attrName == widthAttr) && m_inputType->shouldRespectHeightAndWidthAttributes())
         || attrName == vspaceAttr 
         || attrName == hspaceAttr) {
         result = eUniversal;
         return false;
     } 
 
-    if (attrName == alignAttr) {
-        if (deprecatedInputType() == IMAGE) {
-            // Share with <img> since the alignment behavior is the same.
-            result = eReplaced;
-            return false;
-        }
+    if (attrName == alignAttr && m_inputType->shouldRespectAlignAttribute()) {
+        // Share with <img> since the alignment behavior is the same.
+        result = eReplaced;
+        return false;
     }
 
     return HTMLElement::mapToEntry(attrName, result);
@@ -702,10 +571,9 @@ void HTMLInputElement::parseMappedAttribute(Attribute* attr)
         setFormControlValueMatchesRenderer(false);
         setNeedsValidityCheck();
     } else if (attr->name() == checkedAttr) {
-        m_defaultChecked = !attr->isNull();
-        if (m_useDefaultChecked) {
-            setChecked(m_defaultChecked);
-            m_useDefaultChecked = true;
+        if (m_reflectsCheckedAttribute) {
+            setChecked(!attr->isNull());
+            m_reflectsCheckedAttribute = true;
         }
         setNeedsValidityCheck();
     } else if (attr->name() == maxlengthAttr) {
@@ -713,16 +581,11 @@ void HTMLInputElement::parseMappedAttribute(Attribute* attr)
         setNeedsValidityCheck();
     } else if (attr->name() == sizeAttr)
         InputElement::parseSizeAttribute(m_data, this, attr);
-    else if (attr->name() == altAttr) {
-        if (renderer() && deprecatedInputType() == IMAGE)
-            toRenderImage(renderer())->updateAltText();
-    } else if (attr->name() == srcAttr) {
-        if (renderer() && deprecatedInputType() == IMAGE) {
-            if (!m_imageLoader)
-                m_imageLoader = adoptPtr(new HTMLImageLoader(this));
-            m_imageLoader->updateFromElementIgnoringPreviousError();
-        }
-    } else if (attr->name() == usemapAttr || attr->name() == accesskeyAttr) {
+    else if (attr->name() == altAttr)
+        m_inputType->altAttributeChanged();
+    else if (attr->name() == srcAttr)
+        m_inputType->srcAttributeChanged();
+    else if (attr->name() == usemapAttr || attr->name() == accesskeyAttr) {
         // FIXME: ignore for the moment
     } else if (attr->name() == vspaceAttr) {
         addCSSLength(attr, CSSPropertyMarginTop, attr->value());
@@ -731,13 +594,13 @@ void HTMLInputElement::parseMappedAttribute(Attribute* attr)
         addCSSLength(attr, CSSPropertyMarginLeft, attr->value());
         addCSSLength(attr, CSSPropertyMarginRight, attr->value());
     } else if (attr->name() == alignAttr) {
-        if (deprecatedInputType() == IMAGE)
+        if (m_inputType->shouldRespectAlignAttribute())
             addHTMLAlignment(attr);
     } else if (attr->name() == widthAttr) {
-        if (respectHeightAndWidthAttrs())
+        if (m_inputType->shouldRespectHeightAndWidthAttributes())
             addCSSLength(attr, CSSPropertyWidth, attr->value());
     } else if (attr->name() == heightAttr) {
-        if (respectHeightAndWidthAttrs())
+        if (m_inputType->shouldRespectHeightAndWidthAttributes())
             addCSSLength(attr, CSSPropertyHeight, attr->value());
     } else if (attr->name() == onsearchAttr) {
         // Search field and slider attributes all just cause updateFromElement to be called through style recalcing.
@@ -752,21 +615,12 @@ void HTMLInputElement::parseMappedAttribute(Attribute* attr)
             attach();
         }
         setNeedsStyleRecalc();
-    } else if (attr->name() == autosaveAttr
-               || attr->name() == incrementalAttr)
+    } else if (attr->name() == autosaveAttr || attr->name() == incrementalAttr)
         setNeedsStyleRecalc();
-    else if (attr->name() == minAttr
-             || attr->name() == maxAttr) {
-        if (deprecatedInputType() == RANGE) {
-            // Sanitize the value.
-            setValue(value());
-            setNeedsStyleRecalc();
-        }
+    else if (attr->name() == minAttr || attr->name() == maxAttr) {
+        m_inputType->minOrMaxAttributeChanged();
         setNeedsValidityCheck();
-    } else if (attr->name() == multipleAttr
-             || attr->name() == patternAttr
-             || attr->name() == precisionAttr
-             || attr->name() == stepAttr)
+    } else if (attr->name() == multipleAttr || attr->name() == patternAttr || attr->name() == precisionAttr || attr->name() == stepAttr)
         setNeedsValidityCheck();
 #if ENABLE(DATALIST)
     else if (attr->name() == listAttr)
@@ -785,11 +639,9 @@ void HTMLInputElement::parseMappedAttribute(Attribute* attr)
         HTMLTextFormControlElement::parseMappedAttribute(attr);
 }
 
-bool HTMLInputElement::rendererIsNeeded(RenderStyle *style)
+bool HTMLInputElement::rendererIsNeeded(RenderStyle* style)
 {
-    if (deprecatedInputType() == HIDDEN)
-        return false;
-    return HTMLFormControlElementWithState::rendererIsNeeded(style);
+    return m_inputType->rendererIsNeeded() && HTMLFormControlElementWithState::rendererIsNeeded(style);
 }
 
 RenderObject* HTMLInputElement::createRenderer(RenderArena* arena, RenderStyle* style)
@@ -799,32 +651,12 @@ RenderObject* HTMLInputElement::createRenderer(RenderArena* arena, RenderStyle*
 
 void HTMLInputElement::attach()
 {
-    if (!m_inited) {
-        if (!m_haveType)
-            updateType();
-        m_inited = true;
-    }
+    if (!m_hasType)
+        updateType();
 
     HTMLFormControlElementWithState::attach();
 
-    if (deprecatedInputType() == IMAGE) {
-        if (!m_imageLoader)
-            m_imageLoader = adoptPtr(new HTMLImageLoader(this));
-        m_imageLoader->updateFromElement();
-        if (renderer() && m_imageLoader->haveFiredBeforeLoadEvent()) {
-            RenderImage* renderImage = toRenderImage(renderer());
-            RenderImageResource* renderImageResource = renderImage->imageResource();
-            renderImageResource->setCachedImage(m_imageLoader->image()); 
-
-            // If we have no image at all because we have no src attribute, set
-            // image height and width for the alt text instead.
-            if (!m_imageLoader->image() && !renderImageResource->cachedImage())
-                renderImage->setImageSizeForAltText();
-        }
-    }
-
-    if (deprecatedInputType() == RADIO)
-        updateCheckedRadioButtons();
+    m_inputType->attach();
 
     if (document()->focusedNode() == this)
         document()->updateFocusAppearanceSoon(true /* restore selection */);
@@ -841,7 +673,7 @@ String HTMLInputElement::altText() const
     // http://www.w3.org/TR/1998/REC-html40-19980424/appendix/notes.html#altgen
     // also heavily discussed by Hixie on bugzilla
     // note this is intentionally different to HTMLImageElement::altText()
-    String alt = getAttribute(altAttr);
+    String alt = fastGetAttribute(altAttr);
     // fall back to title attribute
     if (alt.isNull())
         alt = getAttribute(titleAttr);
@@ -855,18 +687,18 @@ String HTMLInputElement::altText() const
 bool HTMLInputElement::isSuccessfulSubmitButton() const
 {
     // HTML spec says that buttons must have names to be considered successful.
-    // However, other browsers do not impose this constraint. So we do likewise.
-    return !disabled() && (deprecatedInputType() == IMAGE || deprecatedInputType() == SUBMIT);
+    // However, other browsers do not impose this constraint. So we do not.
+    return !disabled() && m_inputType->canBeSuccessfulSubmitButton();
 }
 
 bool HTMLInputElement::isActivatedSubmit() const
 {
-    return m_activeSubmit;
+    return m_isActivatedSubmit;
 }
 
 void HTMLInputElement::setActivatedSubmit(bool flag)
 {
-    m_activeSubmit = flag;
+    m_isActivatedSubmit = flag;
 }
 
 bool HTMLInputElement::appendFormData(FormDataList& encoding, bool multipart)
@@ -876,11 +708,11 @@ bool HTMLInputElement::appendFormData(FormDataList& encoding, bool multipart)
 
 void HTMLInputElement::reset()
 {
-    if (storesValueSeparateFromAttribute())
+    if (m_inputType->storesValueSeparateFromAttribute())
         setValue(String());
 
-    setChecked(m_defaultChecked);
-    m_useDefaultChecked = true;
+    setChecked(hasAttribute(checkedAttr));
+    m_reflectsCheckedAttribute = true;
 }
 
 bool HTMLInputElement::isTextField() const
@@ -900,8 +732,8 @@ void HTMLInputElement::setChecked(bool nowChecked, bool sendChangeEvent)
 
     checkedRadioButtons().removeButton(this);
 
-    m_useDefaultChecked = false;
-    m_checked = nowChecked;
+    m_reflectsCheckedAttribute = false;
+    m_isChecked = nowChecked;
     setNeedsStyleRecalc();
 
     updateCheckedRadioButtons();
@@ -917,17 +749,16 @@ void HTMLInputElement::setChecked(bool nowChecked, bool sendChangeEvent)
     // unchecked to match other browsers. DOM is not a useful standard for this
     // because it says only to fire change events at "lose focus" time, which is
     // definitely wrong in practice for these types of elements.
-    if (sendChangeEvent && inDocument() && (deprecatedInputType() != RADIO || nowChecked))
+    if (sendChangeEvent && inDocument() && m_inputType->shouldSendChangeEventAfterCheckedChanged())
         dispatchFormControlChangeEvent();
 }
 
 void HTMLInputElement::setIndeterminate(bool newValue)
 {
-    // Only checkboxes and radio buttons honor indeterminate.
-    if (!allowsIndeterminate() || indeterminate() == newValue)
+    if (!m_inputType->isCheckable() || indeterminate() == newValue)
         return;
 
-    m_indeterminate = newValue;
+    m_isIndeterminate = newValue;
 
     setNeedsStyleRecalc();
 
@@ -945,84 +776,37 @@ void HTMLInputElement::copyNonAttributeProperties(const Element* source)
     const HTMLInputElement* sourceElement = static_cast<const HTMLInputElement*>(source);
 
     m_data.setValue(sourceElement->m_data.value());
-    setChecked(sourceElement->m_checked);
-    m_defaultChecked = sourceElement->m_defaultChecked;
-    m_useDefaultChecked = sourceElement->m_useDefaultChecked;
-    m_indeterminate = sourceElement->m_indeterminate;
+    setChecked(sourceElement->m_isChecked);
+    m_reflectsCheckedAttribute = sourceElement->m_reflectsCheckedAttribute;
+    m_isIndeterminate = sourceElement->m_isIndeterminate;
 
     HTMLFormControlElementWithState::copyNonAttributeProperties(source);
 }
 
 String HTMLInputElement::value() const
 {
-    if (deprecatedInputType() == FILE) {
-        if (!m_fileList->isEmpty()) {
-            // HTML5 tells us that we're supposed to use this goofy value for
-            // file input controls.  Historically, browsers reveals the real
-            // file path, but that's a privacy problem.  Code on the web
-            // decided to try to parse the value by looking for backslashes
-            // (because that's what Windows file paths use).  To be compatible
-            // with that code, we make up a fake path for the file.
-            return "C:\\fakepath\\" + m_fileList->item(0)->fileName();
-        }
-        return String();
-    }
+    String value;
+    if (m_inputType->getTypeSpecificValue(value))
+        return value;
 
-    String value = m_data.value();
-    if (value.isNull()) {
-        value = sanitizeValue(fastGetAttribute(valueAttr));
-        
-        // If no attribute exists, extra handling may be necessary.
-        // For Checkbox Types just use "on" or "" based off the checked() state of the control.
-        // For a Range Input use the calculated default value.
-        if (value.isNull()) {
-            if (deprecatedInputType() == CHECKBOX || deprecatedInputType() == RADIO)
-                return checked() ? "on" : "";
-            if (deprecatedInputType() == RANGE)
-                return serializeForNumberType(StepRange(this).defaultValue());
-        }
-    }
+    value = m_data.value();
+    if (!value.isNull())
+        return value;
 
-    return value;
+    value = sanitizeValue(fastGetAttribute(valueAttr));
+    if (!value.isNull())
+        return value;
+
+    return m_inputType->fallbackValue();
 }
 
 String HTMLInputElement::valueWithDefault() const
 {
-    String v = value();
-    if (v.isNull()) {
-        switch (deprecatedInputType()) {
-        case BUTTON:
-        case CHECKBOX:
-        case COLOR:
-        case DATE:
-        case DATETIME:
-        case DATETIMELOCAL:
-        case EMAIL:
-        case FILE:
-        case HIDDEN:
-        case IMAGE:
-        case ISINDEX:
-        case MONTH:
-        case NUMBER:
-        case PASSWORD:
-        case RADIO:
-        case RANGE:
-        case SEARCH:
-        case TELEPHONE:
-        case TEXT:
-        case TIME:
-        case URL:
-        case WEEK:
-            break;
-        case RESET:
-            v = resetButtonDefaultLabel();
-            break;
-        case SUBMIT:
-            v = submitButtonDefaultLabel();
-            break;
-        }
-    }
-    return v;
+    String value = this->value();
+    if (!value.isNull())
+        return value;
+
+    return m_inputType->defaultValue();
 }
 
 void HTMLInputElement::setValueForUser(const String& value)
@@ -1038,7 +822,7 @@ const String& HTMLInputElement::suggestedValue() const
 
 void HTMLInputElement::setSuggestedValue(const String& value)
 {
-    if (deprecatedInputType() != TEXT)
+    if (!m_inputType->canSetSuggestedValue())
         return;
     setFormControlValueMatchesRenderer(false);
     m_data.setSuggestedValue(sanitizeValue(value));
@@ -1050,16 +834,13 @@ void HTMLInputElement::setSuggestedValue(const String& value)
 
 void HTMLInputElement::setValue(const String& value, bool sendChangeEvent)
 {
-    // For security reasons, we don't allow setting the filename, but we do allow clearing it.
-    // The HTML5 spec (as of the 10/24/08 working draft) says that the value attribute isn't applicable to the file upload control
-    // but we don't want to break existing websites, who may be relying on this method to clear things.
-    if (deprecatedInputType() == FILE && !value.isEmpty())
+    if (!m_inputType->canSetValue(value))
         return;
 
     setFormControlValueMatchesRenderer(false);
-    if (storesValueSeparateFromAttribute()) {
-        if (deprecatedInputType() == FILE)
-            m_fileList->clear();
+    if (m_inputType->storesValueSeparateFromAttribute()) {
+        if (files())
+            files()->clear();
         else {
             m_data.setValue(sanitizeValue(value));
             if (isTextField())
@@ -1114,7 +895,7 @@ void HTMLInputElement::setValueAsNumber(double newValue, ExceptionCode& ec)
 
 String HTMLInputElement::placeholder() const
 {
-    return getAttribute(placeholderAttr).string();
+    return fastGetAttribute(placeholderAttr).string();
 }
 
 void HTMLInputElement::setPlaceholder(const String& value)
@@ -1130,7 +911,8 @@ bool HTMLInputElement::searchEventsShouldBeDispatched() const
 void HTMLInputElement::setValueFromRenderer(const String& value)
 {
     // File upload controls will always use setFileListFromRenderer.
-    ASSERT(deprecatedInputType() != FILE);
+    ASSERT(!isFileUpload());
+
     m_data.setSuggestedValue(String());
     InputElement::setValueFromRenderer(m_data, this, this, value);
     updatePlaceholderVisibility(false);
@@ -1142,148 +924,29 @@ void HTMLInputElement::setValueFromRenderer(const String& value)
 
 void HTMLInputElement::setFileListFromRenderer(const Vector<String>& paths)
 {
-    m_fileList->clear();
-    int size = paths.size();
-
-#if ENABLE(DIRECTORY_UPLOAD)
-    // If a directory is being selected, the UI allows a directory to be chosen
-    // and the paths provided here share a root directory somewhere up the tree;
-    // we want to store only the relative paths from that point.
-    if (webkitdirectory() && size > 0) {
-        String rootPath = directoryName(paths[0]);
-        // Find the common root path.
-        for (int i = 1; i < size; i++) {
-            while (!paths[i].startsWith(rootPath))
-                rootPath = directoryName(rootPath);
-        }
-        rootPath = directoryName(rootPath);
-        ASSERT(rootPath.length());
-        for (int i = 0; i < size; i++) {
-            // Normalize backslashes to slashes before exposing the relative path to script.
-            String relativePath = paths[i].substring(1 + rootPath.length()).replace('\\','/');
-            m_fileList->append(File::create(relativePath, paths[i]));
-        }
-    } else {
-        for (int i = 0; i < size; i++)
-            m_fileList->append(File::create(paths[i]));
-    }
-#else
-    for (int i = 0; i < size; i++)
-        m_fileList->append(File::create(paths[i]));
-#endif
+    m_inputType->setFileList(paths);
 
     setFormControlValueMatchesRenderer(true);
     InputElement::notifyFormStateChanged(this);
     setNeedsValidityCheck();
 }
 
-bool HTMLInputElement::storesValueSeparateFromAttribute() const
+void* HTMLInputElement::preDispatchEventHandler(Event* event)
 {
-    switch (deprecatedInputType()) {
-    case BUTTON:
-    case CHECKBOX:
-    case HIDDEN:
-    case IMAGE:
-    case RADIO:
-    case RESET:
-    case SUBMIT:
-        return false;
-    case COLOR:
-    case DATE:
-    case DATETIME:
-    case DATETIMELOCAL:
-    case EMAIL:
-    case FILE:
-    case ISINDEX:
-    case MONTH:
-    case NUMBER:
-    case PASSWORD:
-    case RANGE:
-    case SEARCH:
-    case TELEPHONE:
-    case TEXT:
-    case TIME:
-    case URL:
-    case WEEK:
-        return true;
-    }
-    return false;
-}
-
-struct EventHandlingState : FastAllocBase {
-    RefPtr<HTMLInputElement> m_currRadio;
-    bool m_indeterminate;
-    bool m_checked;
-    
-    EventHandlingState(bool indeterminate, bool checked)
-        : m_indeterminate(indeterminate)
-        , m_checked(checked) { }
-};
-
-void* HTMLInputElement::preDispatchEventHandler(Event* evt)
-{
-    // preventDefault or "return false" are used to reverse the automatic checking/selection we do here.
-    // This result gives us enough info to perform the "undo" in postDispatch of the action we take here.
-    void* result = 0; 
-    if ((deprecatedInputType() == CHECKBOX || deprecatedInputType() == RADIO) && evt->type() == eventNames().clickEvent) {
-        OwnPtr<EventHandlingState> state = adoptPtr(new EventHandlingState(indeterminate(), checked()));
-        if (deprecatedInputType() == CHECKBOX) {
-            if (indeterminate())
-                setIndeterminate(false);
-            else
-                setChecked(!checked(), true);
-        } else {
-            // For radio buttons, store the current selected radio object.
-            // We really want radio groups to end up in sane states, i.e., to have something checked.
-            // Therefore if nothing is currently selected, we won't allow this action to be "undone", since
-            // we want some object in the radio group to actually get selected.
-            HTMLInputElement* currRadio = checkedRadioButtons().checkedButtonForGroup(name());
-            if (currRadio) {
-                // We have a radio button selected that is not us.  Cache it in our result field and ref it so
-                // that it can't be destroyed.
-                state->m_currRadio = currRadio;
-            }
-            if (indeterminate())
-                setIndeterminate(false);
-            setChecked(true, true);
-        }
-        result = state.leakPtr(); // FIXME: Check whether this actually ends up leaking.
-    }
-    return result;
+    if (event->type() != eventNames().clickEvent)
+        return 0;
+    // FIXME: Check whether there are any cases where this actually ends up leaking.
+    return m_inputType->willDispatchClick().leakPtr();
 }
 
-void HTMLInputElement::postDispatchEventHandler(Event *evt, void* data)
+void HTMLInputElement::postDispatchEventHandler(Event* event, void* dataFromPreDispatch)
 {
-    if ((deprecatedInputType() == CHECKBOX || deprecatedInputType() == RADIO) && evt->type() == eventNames().clickEvent) {
-        
-        if (EventHandlingState* state = reinterpret_cast<EventHandlingState*>(data)) {
-            if (deprecatedInputType() == CHECKBOX) {
-                // Reverse the checking we did in preDispatch.
-                if (evt->defaultPrevented() || evt->defaultHandled()) {
-                    setIndeterminate(state->m_indeterminate);
-                    setChecked(state->m_checked);
-                }
-            } else {
-                HTMLInputElement* input = state->m_currRadio.get();
-                if (evt->defaultPrevented() || evt->defaultHandled()) {
-                    // Restore the original selected radio button if possible.
-                    // Make sure it is still a radio button and only do the restoration if it still
-                    // belongs to our group.
-
-                    if (input && input->form() == form() && input->deprecatedInputType() == RADIO && input->name() == name()) {
-                        // Ok, the old radio button is still in our form and in our group and is still a 
-                        // radio button, so it's safe to restore selection to it.
-                        input->setChecked(true);
-                    }
-                    setIndeterminate(state->m_indeterminate);
-                }
-            }
-            delete state;
-        }
-
-        // Left clicks on radio buttons and check boxes already performed default actions in preDispatchEventHandler(). 
-        evt->setDefaultHandled();
-    }
+    OwnPtr<ClickHandlingState> state = adoptPtr(static_cast<ClickHandlingState*>(dataFromPreDispatch));
+    if (event->type() != eventNames().clickEvent)
+        return;
+    if (!state)
+        return;
+    m_inputType->didDispatchClick(event, *state);
 }
 
 void HTMLInputElement::defaultEventHandler(Event* evt)
@@ -1379,7 +1042,7 @@ bool HTMLInputElement::isURLAttribute(Attribute *attr) const
 
 String HTMLInputElement::defaultValue() const
 {
-    return getAttribute(valueAttr);
+    return fastGetAttribute(valueAttr);
 }
 
 void HTMLInputElement::setDefaultValue(const String &value)
@@ -1387,11 +1050,6 @@ void HTMLInputElement::setDefaultValue(const String &value)
     setAttribute(valueAttr, value);
 }
 
-bool HTMLInputElement::defaultChecked() const
-{
-    return fastHasAttribute(checkedAttr);
-}
-
 void HTMLInputElement::setDefaultName(const AtomicString& name)
 {
     m_data.setName(name);
@@ -1399,12 +1057,12 @@ void HTMLInputElement::setDefaultName(const AtomicString& name)
 
 String HTMLInputElement::accept() const
 {
-    return getAttribute(acceptAttr);
+    return fastGetAttribute(acceptAttr);
 }
 
 String HTMLInputElement::alt() const
 {
-    return getAttribute(altAttr);
+    return fastGetAttribute(altAttr);
 }
 
 int HTMLInputElement::maxLength() const
@@ -1425,13 +1083,6 @@ bool HTMLInputElement::multiple() const
     return fastHasAttribute(multipleAttr);
 }
 
-#if ENABLE(DIRECTORY_UPLOAD)
-bool HTMLInputElement::webkitdirectory() const
-{
-    return fastHasAttribute(webkitdirectoryAttr);
-}
-#endif
-
 void HTMLInputElement::setSize(unsigned size)
 {
     setAttribute(sizeAttr, String::number(size));
@@ -1439,52 +1090,36 @@ void HTMLInputElement::setSize(unsigned size)
 
 KURL HTMLInputElement::src() const
 {
-    return document()->completeURL(getAttribute(srcAttr));
+    return document()->completeURL(fastGetAttribute(srcAttr));
 }
 
-void HTMLInputElement::setAutofilled(bool b)
+void HTMLInputElement::setAutofilled(bool autofilled)
 {
-    if (b == m_autofilled)
+    if (autofilled == m_isAutofilled)
         return;
         
-    m_autofilled = b;
+    m_isAutofilled = autofilled;
     setNeedsStyleRecalc();
 }
 
 FileList* HTMLInputElement::files()
 {
-    if (deprecatedInputType() != FILE)
-        return 0;
-    return m_fileList.get();
+    return m_inputType->files();
 }
 
 bool HTMLInputElement::isAcceptableValue(const String& proposedValue) const
 {
-    if (deprecatedInputType() != NUMBER)
-        return true;
-    return proposedValue.isEmpty() || parseToDoubleForNumberType(proposedValue, 0);
+    return m_inputType->isAcceptableValue(proposedValue);
 }
 
 String HTMLInputElement::sanitizeValue(const String& proposedValue) const
 {
-    if (deprecatedInputType() == NUMBER)
-        return parseToDoubleForNumberType(proposedValue, 0) ? proposedValue : String();
-
-    if (isTextField())
-        return InputElement::sanitizeValueForTextField(this, proposedValue);
-
-    // If the proposedValue is null than this is a reset scenario and we
-    // want the range input's value attribute to take priority over the
-    // calculated default (middle) value.
-    if (deprecatedInputType() == RANGE && !proposedValue.isNull())
-        return serializeForNumberType(StepRange(this).clampValue(proposedValue));
-
-    return proposedValue;
+    return m_inputType->sanitizeValue(proposedValue);
 }
 
 bool HTMLInputElement::hasUnacceptableValue() const
 {
-    return deprecatedInputType() == NUMBER && renderer() && !isAcceptableValue(toRenderTextControl(renderer())->text());
+    return m_inputType->hasUnacceptableValue();
 }
 
 bool HTMLInputElement::isInRange() const
@@ -1499,7 +1134,7 @@ bool HTMLInputElement::isOutOfRange() const
 
 bool HTMLInputElement::needsActivationCallback()
 {
-    return deprecatedInputType() == PASSWORD || m_autocomplete == Off;
+    return m_autocomplete == Off || m_inputType->shouldResetOnDocumentActivation();
 }
 
 void HTMLInputElement::registerForActivationCallbackIfNeeded()
@@ -1548,15 +1183,14 @@ void HTMLInputElement::documentDidBecomeActive()
 
 void HTMLInputElement::willMoveToNewOwnerDocument()
 {
-    if (m_imageLoader)
-        m_imageLoader->elementWillMoveToNewOwnerDocument();
+    m_inputType->willMoveToNewOwnerDocument();
 
     // Always unregister for cache callbacks when leaving a document, even if we would otherwise like to be registered
     if (needsActivationCallback())
         document()->unregisterForDocumentActivationCallbacks(this);
         
     document()->checkedRadioButtons().removeButton(this);
-    
+
     HTMLFormControlElementWithState::willMoveToNewOwnerDocument();
 }
 
@@ -1591,56 +1225,37 @@ HTMLDataListElement* HTMLInputElement::dataList() const
     if (!m_hasNonEmptyList)
         return 0;
 
-    switch (deprecatedInputType()) {
-    case COLOR:
-    case DATE:
-    case DATETIME:
-    case DATETIMELOCAL:
-    case EMAIL:
-    case MONTH:
-    case NUMBER:
-    case RANGE:
-    case SEARCH:
-    case TELEPHONE:
-    case TEXT:
-    case TIME:
-    case URL:
-    case WEEK: {
-        Element* element = document()->getElementById(getAttribute(listAttr));
-        if (element && element->hasTagName(datalistTag))
-            return static_cast<HTMLDataListElement*>(element);
-        break;
-    }
-    case BUTTON:
-    case CHECKBOX:
-    case FILE:
-    case HIDDEN:
-    case IMAGE:
-    case ISINDEX:
-    case PASSWORD:
-    case RADIO:
-    case RESET:
-    case SUBMIT:
-        break;
-    }
-    return 0;
+    if (!m_inputType->shouldRespectListAttribute())
+        return 0;
+
+    Element* element = document()->getElementById(fastGetAttribute(listAttr));
+    if (!element)
+        return 0;
+    if (!element->hasTagName(datalistTag))
+        return 0;
+
+    return static_cast<HTMLDataListElement*>(element);
 }
 
 HTMLOptionElement* HTMLInputElement::selectedOption() const
 {
-    String currentValue = value();
-    // The empty value never matches to a datalist option because it
+    String value = this->value();
+
+    // The empty string never matches to a datalist option because it
     // doesn't represent a suggestion according to the standard.
-    if (currentValue.isEmpty())
+    if (value.isEmpty())
         return 0;
 
     HTMLDataListElement* sourceElement = dataList();
     if (!sourceElement)
         return 0;
     RefPtr<HTMLCollection> options = sourceElement->options();
-    for (unsigned i = 0; options && i < options->length(); ++i) {
+    if (!options)
+        return 0;
+    unsigned length = options->length();
+    for (unsigned i = 0; i < length; ++i) {
         HTMLOptionElement* option = static_cast<HTMLOptionElement*>(options->item(i));
-        if (!option->disabled() && currentValue == option->value())
+        if (!option->disabled() && value == option->value())
             return option;
     }
     return 0;
@@ -1697,7 +1312,7 @@ void HTMLInputElement::stepUpFromRenderer(int n)
     // The value will be the default value after stepping for <input value=(empty/invalid) step="any" />
     // FIXME: Not any changes after stepping, even if it is an invalid value, may be better.
     // (e.g. Stepping-up for <input type="number" value="foo" step="any" /> => "foo")
-    if (equalIgnoringCase(getAttribute(stepAttr), "any"))
+    if (equalIgnoringCase(fastGetAttribute(stepAttr), "any"))
         step = 0;
     else if (!getAllowedValueStepWithDecimalPlaces(&step, &stepDecimalPlaces))
         return;
@@ -1762,49 +1377,126 @@ void HTMLInputElement::stepUpFromRenderer(int n)
 }
 
 #if ENABLE(WCSS)
+
 void HTMLInputElement::setWapInputFormat(String& mask)
 {
     String validateMask = validateInputMask(m_data, mask);
     if (!validateMask.isEmpty())
         m_data.setInputFormatMask(validateMask);
 }
+
 #endif
 
 #if ENABLE(INPUT_SPEECH)
+
 bool HTMLInputElement::isSpeechEnabled() const
 {
-    switch (deprecatedInputType()) {
     // FIXME: Add support for RANGE, EMAIL, URL, COLOR and DATE/TIME input types.
-    case NUMBER:
-    case PASSWORD:
-    case SEARCH:
-    case TELEPHONE:
-    case TEXT:
-        return RuntimeEnabledFeatures::speechInputEnabled() && hasAttribute(webkitspeechAttr);
-    case BUTTON:
-    case CHECKBOX:
-    case COLOR:
-    case DATE:
-    case DATETIME:
-    case DATETIMELOCAL:
-    case EMAIL:
-    case FILE:
-    case HIDDEN:
-    case IMAGE:
-    case ISINDEX:
-    case MONTH:
-    case RADIO:
-    case RANGE:
-    case RESET:
-    case SUBMIT:
-    case TIME:
-    case URL:
-    case WEEK:
-        return false;
-    }
-    return false;
+    return m_inputType->shouldRespectSpeechAttribute() && RuntimeEnabledFeatures::speechInputEnabled() && hasAttribute(webkitspeechAttr);
 }
 
 #endif
 
+bool HTMLInputElement::isTextButton() const
+{
+    return m_inputType->isTextButton();
+}
+
+bool HTMLInputElement::isRadioButton() const
+{
+    return m_inputType->isRadioButton();
+}
+
+bool HTMLInputElement::isSearchField() const
+{
+    return m_inputType->isSearchField();
+}
+
+bool HTMLInputElement::isInputTypeHidden() const
+{
+    return m_inputType->isHiddenType();
+}
+
+bool HTMLInputElement::isPasswordField() const
+{
+    return m_inputType->isPasswordField();
+}
+
+bool HTMLInputElement::isCheckbox() const
+{
+    return m_inputType->isCheckbox();
+}
+
+bool HTMLInputElement::isText() const
+{
+    return m_inputType->isTextType();
+}
+
+bool HTMLInputElement::isEmailField() const
+{
+    return m_inputType->isEmailField();
+}
+
+bool HTMLInputElement::isFileUpload() const
+{
+    return m_inputType->isFileUpload();
+}
+
+bool HTMLInputElement::isImageButton() const
+{
+    return m_inputType->isImageButton();
+}
+
+bool HTMLInputElement::isNumberField() const
+{
+    return m_inputType->isNumberField();
+}
+
+bool HTMLInputElement::isSubmitButton() const
+{
+    return m_inputType->isSubmitButton();
+}
+
+bool HTMLInputElement::isTelephoneField() const
+{
+    return m_inputType->isTelephoneField();
+}
+
+bool HTMLInputElement::isURLField() const
+{
+    return m_inputType->isURLField();
+}
+
+bool HTMLInputElement::isEnumeratable() const
+{
+    return m_inputType->isEnumeratable();
+}
+
+bool HTMLInputElement::isChecked() const
+{
+    return checked() && m_inputType->isCheckable();
+}
+
+bool HTMLInputElement::hasSpinButton() const
+{
+    return m_inputType->hasSpinButton();
+}
+
+bool HTMLInputElement::supportsPlaceholder() const
+{
+    return isTextType();
+}
+
+CheckedRadioButtons& HTMLInputElement::checkedRadioButtons() const
+{
+    if (HTMLFormElement* formElement = form())
+        return formElement->checkedRadioButtons();
+    return document()->checkedRadioButtons();
+}
+
+void HTMLInputElement::handleBeforeTextInsertedEvent(Event* event)
+{
+    InputElement::handleBeforeTextInsertedEvent(m_data, this, this, event);
+}
+
 } // namespace
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index 92f16db..eb30de0 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -25,21 +25,15 @@
 #define HTMLInputElement_h
 
 #include "HTMLFormControlElement.h"
-#include "HTMLFormElement.h"
 #include "InputElement.h"
-#include "InputType.h"
-#include <wtf/OwnPtr.h>
 
 namespace WebCore {
 
-class DateComponents;
 class FileList;
 class HTMLDataListElement;
-class HTMLImageLoader;
 class HTMLOptionElement;
 class InputType;
 class KURL;
-class VisibleSelection;
 
 class HTMLInputElement : public HTMLTextFormControlElement, public InputElement {
 public:
@@ -84,38 +78,38 @@ public:
     // stepUp()/stepDown() for user-interaction.
     void stepUpFromRenderer(int);
 
-    bool isTextButton() const { return deprecatedInputType() == SUBMIT || deprecatedInputType() == RESET || deprecatedInputType() == BUTTON; }
+    bool isTextButton() const;
 
-    virtual bool isRadioButton() const { return deprecatedInputType() == RADIO; }
+    virtual bool isRadioButton() const;
     virtual bool isTextField() const;
-    virtual bool isSearchField() const { return deprecatedInputType() == SEARCH; }
-    virtual bool isInputTypeHidden() const { return deprecatedInputType() == HIDDEN; }
-    virtual bool isPasswordField() const { return deprecatedInputType() == PASSWORD; }
-    virtual bool isCheckbox() const { return deprecatedInputType() == CHECKBOX; }
+    virtual bool isSearchField() const;
+    virtual bool isInputTypeHidden() const;
+    virtual bool isPasswordField() const;
+    virtual bool isCheckbox() const;
 
     // FIXME: It's highly likely that any call site calling this function should instead
     // be using a different one. Many input elements behave like text fields, and in addition
     // any unknown input type is treated as text. Consider, for example, isTextField or
     // isTextField && !isPasswordField.
-    bool isText() const { return deprecatedInputType() == TEXT; }
+    bool isText() const;
 
-    bool isEmailField() const { return deprecatedInputType() == EMAIL; }
-    bool isFileUpload() const { return deprecatedInputType() == FILE; }
-    bool isImageButton() const { return deprecatedInputType() == IMAGE; }
-    bool isNumberField() const { return deprecatedInputType() == NUMBER; }
-    bool isSubmitButton() const { return deprecatedInputType() == SUBMIT; }
-    bool isTelephoneField() const { return deprecatedInputType() == TELEPHONE; }
-    bool isURLField() const { return deprecatedInputType() == URL; }
+    bool isEmailField() const;
+    bool isFileUpload() const;
+    bool isImageButton() const;
+    bool isNumberField() const;
+    bool isSubmitButton() const;
+    bool isTelephoneField() const;
+    bool isURLField() const;
 
 #if ENABLE(INPUT_SPEECH)
     virtual bool isSpeechEnabled() const;
 #endif
 
-    bool checked() const { return m_checked; }
+    bool checked() const { return m_isChecked; }
     void setChecked(bool, bool sendChangeEvent = false);
 
     // 'indeterminate' is a state independent of the checked state that causes the control to draw in a way that hides the actual state.
-    bool indeterminate() const { return m_indeterminate; }
+    bool indeterminate() const { return m_isIndeterminate; }
     void setIndeterminate(bool);
 
     virtual int size() const;
@@ -165,8 +159,6 @@ public:
 
     String defaultValue() const;
     void setDefaultValue(const String&);
-    
-    bool defaultChecked() const;
 
     void setDefaultName(const AtomicString&);
 
@@ -182,12 +174,8 @@ public:
 
     bool multiple() const;
 
-#if ENABLE(DIRECTORY_UPLOAD)
-    bool webkitdirectory() const;
-#endif
-
-    virtual bool isAutofilled() const { return m_autofilled; }
-    void setAutofilled(bool value = true);
+    virtual bool isAutofilled() const { return m_isAutofilled; }
+    void setAutofilled(bool = true);
 
     FileList* files();
 
@@ -203,60 +191,26 @@ public:
     void setWapInputFormat(String& mask);
 #endif
 
-    inline CheckedRadioButtons& checkedRadioButtons() const
-    {
-        if (HTMLFormElement* formElement = form())
-            return formElement->checkedRadioButtons();
-        return document()->checkedRadioButtons();
-    }
-
-    void handleBeforeTextInsertedEvent(Event* event);
-
+    // These functions are public so they can be used in InputType classes.
+    // Otherwise, they would be private.
+    CheckedRadioButtons& checkedRadioButtons() const;
+    void handleBeforeTextInsertedEvent(Event*);
+    void updateCheckedRadioButtons();
+    
 protected:
     HTMLInputElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
 
     virtual void defaultEventHandler(Event*);
 
 private:
-    enum DeprecatedInputType {
-        TEXT = 0, // TEXT must be 0.
-        PASSWORD,
-        ISINDEX,
-        CHECKBOX,
-        RADIO,
-        SUBMIT,
-        RESET,
-        FILE,
-        HIDDEN,
-        IMAGE,
-        BUTTON,
-        SEARCH,
-        RANGE,
-        EMAIL,
-        NUMBER,
-        TELEPHONE,
-        URL,
-        COLOR,
-        DATE,
-        DATETIME,
-        DATETIMELOCAL,
-        MONTH,
-        TIME,
-        WEEK,
-    };
-
     enum AutoCompleteSetting { Uninitialized, On, Off };
 
-    typedef HashMap<String, HTMLInputElement::DeprecatedInputType, CaseFoldingHash> InputTypeMap;
-    static PassOwnPtr<InputTypeMap> createTypeMap();
-    DeprecatedInputType deprecatedInputType() const { return static_cast<DeprecatedInputType>(m_deprecatedTypeNumber); }
-
     virtual void willMoveToNewOwnerDocument();
     virtual void didMoveToNewOwnerDocument();
 
     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
     virtual bool isMouseFocusable() const;
-    virtual bool isEnumeratable() const { return deprecatedInputType() != IMAGE; }
+    virtual bool isEnumeratable() const;
     virtual void updateFocusAppearance(bool restorePreviousSelection);
     virtual void aboutToUnload();
     virtual bool shouldUseInputMethod() const;
@@ -264,16 +218,14 @@ private:
     virtual const AtomicString& formControlName() const;
  
     // isChecked is used by the rendering tree/CSS while checked() is used by JS to determine checked state
-    virtual bool isChecked() const { return checked() && (deprecatedInputType() == CHECKBOX || deprecatedInputType() == RADIO); }
+    virtual bool isChecked() const;
     virtual bool isIndeterminate() const { return indeterminate(); }
     
     virtual bool isTextFormControl() const { return isTextField(); }
 
-    virtual bool hasSpinButton() const { return deprecatedInputType() == NUMBER || deprecatedInputType() == DATE || deprecatedInputType() == DATETIME || deprecatedInputType() == DATETIMELOCAL || deprecatedInputType() == MONTH || deprecatedInputType() == TIME || deprecatedInputType() == WEEK; }
+    virtual bool hasSpinButton() const;
     virtual bool canTriggerImplicitSubmission() const { return isTextField(); }
 
-    bool allowsIndeterminate() const { return deprecatedInputType() == CHECKBOX || deprecatedInputType() == RADIO; }
-
     virtual const AtomicString& formControlType() const;
 
     virtual bool searchEventsShouldBeDispatched() const;
@@ -296,9 +248,6 @@ private:
 
     virtual bool isSuccessfulSubmitButton() const;
 
-    // Report if this input type uses height & width attributes
-    bool respectHeightAndWidthAttrs() const { return deprecatedInputType() == IMAGE || deprecatedInputType() == HIDDEN; }
-
     virtual void reset();
 
     virtual void* preDispatchEventHandler(Event*);
@@ -319,8 +268,6 @@ private:
 
     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
 
-    bool storesValueSeparateFromAttribute() const;
-
     bool needsActivationCallback();
     void registerForActivationCallbackIfNeeded();
     void unregisterForActivationCallbackIfNeeded();
@@ -328,7 +275,7 @@ private:
     virtual bool supportsMaxLength() const { return isTextType(); }
     bool isTextType() const;
 
-    virtual bool supportsPlaceholder() const { return isTextType() || deprecatedInputType() == ISINDEX; }
+    virtual bool supportsPlaceholder() const;
     virtual bool isEmptyValue() const { return value().isEmpty(); }
     virtual void handleFocusEvent();
     virtual void handleBlurEvent();
@@ -341,8 +288,6 @@ private:
 
     void updateType();
 
-    void updateCheckedRadioButtons();
-    
     // Helper for stepUp()/stepDown().  Adds step value * count to the current value.
     void applyStep(double count, ExceptionCode&);
 
@@ -356,29 +301,19 @@ private:
 
     InputElementData m_data;
     short m_maxResults;
-    OwnPtr<HTMLImageLoader> m_imageLoader;
-    RefPtr<FileList> m_fileList;
-    unsigned m_deprecatedTypeNumber : 5; // DeprecatedInputType 
-    bool m_checked : 1;
-    bool m_defaultChecked : 1;
-    bool m_useDefaultChecked : 1;
-    bool m_indeterminate : 1;
-    bool m_haveType : 1;
-    bool m_activeSubmit : 1;
+    bool m_isChecked : 1;
+    bool m_reflectsCheckedAttribute : 1;
+    bool m_isIndeterminate : 1;
+    bool m_hasType : 1;
+    bool m_isActivatedSubmit : 1;
     unsigned m_autocomplete : 2; // AutoCompleteSetting
-    bool m_autofilled : 1;
-    bool m_inited : 1;
+    bool m_isAutofilled : 1;
 #if ENABLE(DATALIST)
     bool m_hasNonEmptyList : 1;
 #endif
     OwnPtr<InputType> m_inputType;
 };
 
-inline void HTMLInputElement::handleBeforeTextInsertedEvent(Event* event)
-{
-    InputElement::handleBeforeTextInsertedEvent(m_data, this, this, event);
-}
-
 } //namespace
 
 #endif
diff --git a/WebCore/html/HiddenInputType.cpp b/WebCore/html/HiddenInputType.cpp
index 6e083e6..3aed1db 100644
--- a/WebCore/html/HiddenInputType.cpp
+++ b/WebCore/html/HiddenInputType.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -55,4 +56,28 @@ RenderObject* HiddenInputType::createRenderer(RenderArena*, RenderStyle*) const
     return 0;
 }
 
+void HiddenInputType::accessKeyAction(bool)
+{
+}
+
+bool HiddenInputType::rendererIsNeeded()
+{
+    return false;
+}
+
+bool HiddenInputType::storesValueSeparateFromAttribute()
+{
+    return false;
+}
+
+bool HiddenInputType::isHiddenType() const
+{
+    return true;
+}
+
+bool HiddenInputType::shouldRespectHeightAndWidthAttributes()
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/HiddenInputType.h b/WebCore/html/HiddenInputType.h
index 1617371..e232a36 100644
--- a/WebCore/html/HiddenInputType.h
+++ b/WebCore/html/HiddenInputType.h
@@ -44,6 +44,11 @@ private:
     virtual const AtomicString& formControlType() const;
     virtual bool supportsValidation() const;
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
+    virtual void accessKeyAction(bool sendToAnyElement);
+    virtual bool rendererIsNeeded();
+    virtual bool storesValueSeparateFromAttribute();
+    virtual bool isHiddenType() const;
+    virtual bool shouldRespectHeightAndWidthAttributes();
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/ImageInputType.cpp b/WebCore/html/ImageInputType.cpp
index 572caa7..85b3329 100644
--- a/WebCore/html/ImageInputType.cpp
+++ b/WebCore/html/ImageInputType.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Google Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
@@ -23,6 +23,8 @@
 #include "ImageInputType.h"
 
 #include "FormDataList.h"
+#include "HTMLFormElement.h"
+#include "HTMLImageLoader.h"
 #include "HTMLInputElement.h"
 #include "MouseEvent.h"
 #include "RenderImage.h"
@@ -30,6 +32,11 @@
 
 namespace WebCore {
 
+inline ImageInputType::ImageInputType(HTMLInputElement* element)
+    : BaseButtonInputType(element)
+{
+}
+
 PassOwnPtr<InputType> ImageInputType::create(HTMLInputElement* element)
 {
     return adoptPtr(new ImageInputType(element));
@@ -85,4 +92,77 @@ RenderObject* ImageInputType::createRenderer(RenderArena* arena, RenderStyle*) c
     return image;
 }
 
+void ImageInputType::altAttributeChanged()
+{
+    RenderImage* image = toRenderImage(element()->renderer());
+    if (!image)
+        return;
+    image->updateAltText();
+}
+
+void ImageInputType::srcAttributeChanged()
+{
+    if (!element()->renderer())
+        return;
+    if (!m_imageLoader)
+        m_imageLoader = adoptPtr(new HTMLImageLoader(element()));
+    m_imageLoader->updateFromElementIgnoringPreviousError();
+}
+
+void ImageInputType::attach()
+{
+    BaseButtonInputType::attach();
+
+    if (!m_imageLoader)
+        m_imageLoader = adoptPtr(new HTMLImageLoader(element()));
+    m_imageLoader->updateFromElement();
+
+    RenderImage* renderer = toRenderImage(element()->renderer());
+    if (!renderer)
+        return;
+
+    if (!m_imageLoader->haveFiredBeforeLoadEvent())
+        return;
+
+    RenderImageResource* imageResource = renderer->imageResource();
+    imageResource->setCachedImage(m_imageLoader->image()); 
+
+    // If we have no image at all because we have no src attribute, set
+    // image height and width for the alt text instead.
+    if (!m_imageLoader->image() && !imageResource->cachedImage())
+        renderer->setImageSizeForAltText();
+}
+
+void ImageInputType::willMoveToNewOwnerDocument()
+{
+    BaseButtonInputType::willMoveToNewOwnerDocument();
+    if (m_imageLoader)
+        m_imageLoader->elementWillMoveToNewOwnerDocument();
+}
+
+bool ImageInputType::shouldRespectAlignAttribute()
+{
+    return true;
+}
+
+bool ImageInputType::canBeSuccessfulSubmitButton()
+{
+    return true;
+}
+
+bool ImageInputType::isImageButton() const
+{
+    return true;
+}
+
+bool ImageInputType::isEnumeratable()
+{
+    return false;
+}
+
+bool ImageInputType::shouldRespectHeightAndWidthAttributes()
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/ImageInputType.h b/WebCore/html/ImageInputType.h
index 1fd92f4..9cb6021 100644
--- a/WebCore/html/ImageInputType.h
+++ b/WebCore/html/ImageInputType.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -33,24 +34,36 @@
 
 #include "BaseButtonInputType.h"
 #include "IntPoint.h"
+#include <wtf/OwnPtr.h>
 
 namespace WebCore {
 
+class HTMLImageLoader;
+
 class ImageInputType : public BaseButtonInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    ImageInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
+    ImageInputType(HTMLInputElement*);
     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;
     virtual void handleDOMActivateEvent(Event*);
+    virtual void altAttributeChanged();
+    virtual void srcAttributeChanged();
+    virtual void attach();
+    virtual void willMoveToNewOwnerDocument();
+    virtual bool shouldRespectAlignAttribute();
+    virtual bool canBeSuccessfulSubmitButton();
+    virtual bool isImageButton() const;
+    virtual bool isEnumeratable();
+    virtual bool shouldRespectHeightAndWidthAttributes();
 
-    // This is valid only during HTMLFormElement::prepareForSubmission().
-    IntPoint m_clickLocation;
+    OwnPtr<HTMLImageLoader> m_imageLoader;
+    IntPoint m_clickLocation; // Valid only during HTMLFormElement::prepareForSubmission().
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/InputType.cpp b/WebCore/html/InputType.cpp
index b724407..d23ce96 100644
--- a/WebCore/html/InputType.cpp
+++ b/WebCore/html/InputType.cpp
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll at kde.org)
  *           (C) 1999 Antti Koivisto (koivisto at kde.org)
  *           (C) 2001 Dirk Mueller (mueller at kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
  *           (C) 2006 Alexey Proskuryakov (ap at nypop.com)
  * Copyright (C) 2007 Samuel Weinig (sam at webkit.org)
  * Copyright (C) 2010 Google Inc. All rights reserved.
@@ -38,6 +38,7 @@
 #include "EmailInputType.h"
 #include "FileInputType.h"
 #include "FormDataList.h"
+#include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
 #include "HiddenInputType.h"
 #include "ImageInputType.h"
@@ -68,7 +69,9 @@ namespace WebCore {
 
 using namespace std;
 
-typedef HashMap<String, PassOwnPtr<InputType> (*)(HTMLInputElement*), CaseFoldingHash> InputTypeFactoryMap;
+typedef PassOwnPtr<InputType> (*InputTypeFactoryFunction)(HTMLInputElement*);
+typedef HashMap<String, InputTypeFactoryFunction, CaseFoldingHash> InputTypeFactoryMap;
+
 static PassOwnPtr<InputTypeFactoryMap> createInputTypeFactoryMap()
 {
     OwnPtr<InputTypeFactoryMap> map = adoptPtr(new InputTypeFactoryMap);
@@ -99,7 +102,7 @@ static PassOwnPtr<InputTypeFactoryMap> createInputTypeFactoryMap()
     return map.release();
 }
 
-PassOwnPtr<InputType> InputType::create(HTMLInputElement* element, const AtomicString& typeName)
+PassOwnPtr<InputType> InputType::create(HTMLInputElement* element, const String& typeName)
 {
     static const InputTypeFactoryMap* factoryMap = createInputTypeFactoryMap().leakPtr();
     PassOwnPtr<InputType> (*factory)(HTMLInputElement*) = typeName.isEmpty() ? 0 : factoryMap->get(typeName);
@@ -277,7 +280,7 @@ bool InputType::parsedStepValueShouldBeInteger() const
     return false;
 }
 
-bool InputType::scaledStepValeuShouldBeInteger() const
+bool InputType::scaledStepValueShouldBeInteger() const
 {
     return false;
 }
@@ -376,6 +379,239 @@ void InputType::dispatchSimulatedClickIfActive(KeyboardEvent* event) const
     event->setDefaultHandled();
 }
 
+bool InputType::canSetStringValue() const
+{
+    return true;
+}
+
+bool InputType::isKeyboardFocusable() const
+{
+    return true;
+}
+
+bool InputType::shouldUseInputMethod() const
+{
+    return false;
+}
+
+void InputType::handleBlurEvent()
+{
+}
+
+void InputType::accessKeyAction(bool)
+{
+    element()->focus(false);
+}
+
+void InputType::attach()
+{
+}
+
+void InputType::altAttributeChanged()
+{
+}
+
+void InputType::srcAttributeChanged()
+{
+}
+
+void InputType::willMoveToNewOwnerDocument()
+{
+}
+
+bool InputType::shouldRespectAlignAttribute()
+{
+    return false;
+}
+
+bool InputType::canChangeFromAnotherType() const
+{
+    return true;
+}
+
+void InputType::minOrMaxAttributeChanged()
+{
+}
+
+bool InputType::canBeSuccessfulSubmitButton()
+{
+    return false;
+}
+
+bool InputType::rendererIsNeeded()
+{
+    return true;
+}
+
+FileList* InputType::files()
+{
+    return 0;
+}
+
+bool InputType::getTypeSpecificValue(String&)
+{
+    return false;
+}
+
+String InputType::fallbackValue()
+{
+    return String();
+}
+
+String InputType::defaultValue()
+{
+    return String();
+}
+
+bool InputType::canSetSuggestedValue()
+{
+    return false;
+}
+
+bool InputType::shouldSendChangeEventAfterCheckedChanged()
+{
+    return true;
+}
+
+bool InputType::storesValueSeparateFromAttribute()
+{
+    return true;
+}
+
+bool InputType::canSetValue(const String&)
+{
+    return true;
+}
+
+PassOwnPtr<ClickHandlingState> InputType::willDispatchClick()
+{
+    return PassOwnPtr<ClickHandlingState>();
+}
+
+void InputType::didDispatchClick(Event*, const ClickHandlingState&)
+{
+}
+
+bool InputType::isAcceptableValue(const String&)
+{
+    return true;
+}
+
+String InputType::sanitizeValue(const String& proposedValue)
+{
+    return proposedValue;
+}
+
+bool InputType::hasUnacceptableValue()
+{
+    return false;
+}
+
+void InputType::setFileList(const Vector<String>&)
+{
+    ASSERT_NOT_REACHED();
+}
+
+bool InputType::shouldResetOnDocumentActivation()
+{
+    return false;
+}
+
+bool InputType::shouldRespectListAttribute()
+{
+    return false;
+}
+
+bool InputType::shouldRespectSpeechAttribute()
+{
+    return false;
+}
+
+bool InputType::isTextButton() const
+{
+    return false;
+}
+
+bool InputType::isRadioButton() const
+{
+    return false;
+}
+
+bool InputType::isSearchField() const
+{
+    return false;
+}
+
+bool InputType::isHiddenType() const
+{
+    return false;
+}
+
+bool InputType::isPasswordField() const
+{
+    return false;
+}
+
+bool InputType::isCheckbox() const
+{
+    return false;
+}
+
+bool InputType::isEmailField() const
+{
+    return false;
+}
+
+bool InputType::isFileUpload() const
+{
+    return false;
+}
+
+bool InputType::isImageButton() const
+{
+    return false;
+}
+
+bool InputType::isNumberField() const
+{
+    return false;
+}
+
+bool InputType::isSubmitButton() const
+{
+    return false;
+}
+
+bool InputType::isTelephoneField() const
+{
+    return false;
+}
+
+bool InputType::isURLField() const
+{
+    return false;
+}
+
+bool InputType::isEnumeratable()
+{
+    return true;
+}
+
+bool InputType::isCheckable()
+{
+    return false;
+}
+
+bool InputType::hasSpinButton()
+{
+    return false;
+}
+
+bool InputType::shouldRespectHeightAndWidthAttributes()
+{
+    return false;
+}
+
 namespace InputTypeNames {
 
 // The type names must be lowercased because they will be the return values of
@@ -525,6 +761,6 @@ const AtomicString& week()
     return name;
 }
 
-} // namespace WebCore::InpuTypeNames
+} // namespace WebCore::InputTypeNames
 
 } // namespace WebCore
diff --git a/WebCore/html/InputType.h b/WebCore/html/InputType.h
index 994851a..4d25a97 100644
--- a/WebCore/html/InputType.h
+++ b/WebCore/html/InputType.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -31,15 +32,17 @@
 #ifndef InputType_h
 #define InputType_h
 
-#include "ExceptionCode.h"
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
 
 namespace WebCore {
 
 class BeforeTextInsertedEvent;
 class DateComponents;
 class Event;
+class FileList;
 class FormDataList;
 class HTMLFormElement;
 class HTMLInputElement;
@@ -50,21 +53,53 @@ class RenderObject;
 class RenderStyle;
 class WheelEvent;
 
+typedef int ExceptionCode;
+
+struct ClickHandlingState {
+    bool checked;
+    bool indeterminate;
+    RefPtr<HTMLInputElement> checkedRadioButton;
+
+    WTF_MAKE_FAST_ALLOCATED
+};
+
 // 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> create(HTMLInputElement*, const String&);
     static PassOwnPtr<InputType> createText(HTMLInputElement*);
     virtual ~InputType();
 
+    virtual const AtomicString& formControlType() const = 0;
+    virtual bool canChangeFromAnotherType() const;
+
     // Type query functions
 
+    // Any time we are using one of these functions it's best to refactor
+    // to add a virtual function to allow the input type object to do the
+    // work instead, or at least make a query function that asks a higher
+    // level question. These functions make the HTMLInputElement class
+    // inflexible because it's harder to add new input types if there is
+    // scattered code with special cases for various types.
+
+    virtual bool isCheckbox() const;
+    virtual bool isEmailField() const;
+    virtual bool isFileUpload() const;
+    virtual bool isHiddenType() const;
+    virtual bool isImageButton() const;
+    virtual bool isNumberField() const;
+    virtual bool isPasswordField() const;
+    virtual bool isRadioButton() const;
+    virtual bool isRangeControl() const;
+    virtual bool isSearchField() const;
+    virtual bool isSubmitButton() const;
+    virtual bool isTelephoneField() const;
+    virtual bool isTextButton() const;
     virtual bool isTextField() const;
     virtual bool isTextType() const;
-    virtual bool isRangeControl() const;
-    virtual const AtomicString& formControlType() const = 0;
+    virtual bool isURLField() const;
 
     // Form value functions
 
@@ -75,6 +110,9 @@ public:
 
     // DOM property functions
 
+    virtual bool getTypeSpecificValue(String&); // Checked first, before internal storage or the value attribute.
+    virtual String fallbackValue(); // Checked last, if both internal storage and value attribute are missing.
+    virtual String defaultValue(); // Checked after even fallbackValue, only when the valueWithDefault function is called.
     virtual double valueAsDate() const;
     virtual void setValueAsDate(double, ExceptionCode&) const;
     virtual double valueAsNumber() const;
@@ -97,20 +135,26 @@ public:
     virtual double defaultValueForStepUp() const;
     virtual double minimum() const;
     virtual double maximum() const;
-    virtual bool stepMismatch(const String&, double) const;
+    virtual bool stepMismatch(const String&, double step) const;
     virtual double stepBase() const;
     virtual double stepBaseWithDecimalPlaces(unsigned*) const;
     virtual double defaultStep() const;
     virtual double stepScaleFactor() const;
     virtual bool parsedStepValueShouldBeInteger() const;
-    virtual bool scaledStepValeuShouldBeInteger() const;
+    virtual bool scaledStepValueShouldBeInteger() const;
     virtual double acceptableError(double) const;
     virtual String typeMismatchText() const;
     virtual String valueMissingText() const;
+    virtual bool canSetStringValue() const;
+    virtual bool isAcceptableValue(const String&);
+    virtual String sanitizeValue(const String&);
+    virtual bool hasUnacceptableValue();
 
     // Event handlers
 
     virtual void handleClickEvent(MouseEvent*);
+    virtual PassOwnPtr<ClickHandlingState> willDispatchClick();
+    virtual void didDispatchClick(Event*, const ClickHandlingState&);
     virtual void handleDOMActivateEvent(Event*);
     virtual void handleKeydownEvent(KeyboardEvent*);
     virtual void handleKeypressEvent(KeyboardEvent*);
@@ -121,25 +165,53 @@ public:
     // Helpers for event handlers.
     virtual bool shouldSubmitImplicitly(Event*);
     virtual PassRefPtr<HTMLFormElement> formForSubmission() const;
+    virtual bool isKeyboardFocusable() const;
+    virtual bool shouldUseInputMethod() const;
+    virtual void handleBlurEvent();
+    virtual void accessKeyAction(bool sendToAnyElement);
+    virtual bool canBeSuccessfulSubmitButton();
 
     // Miscellaneous functions
 
+    virtual bool rendererIsNeeded();
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
+    virtual void attach();
+    virtual void minOrMaxAttributeChanged();
+    virtual void altAttributeChanged();
+    virtual void srcAttributeChanged();
+    virtual void willMoveToNewOwnerDocument();
+    virtual bool shouldRespectAlignAttribute();
+    virtual FileList* files();
+    virtual bool canSetSuggestedValue();
+    virtual bool shouldSendChangeEventAfterCheckedChanged();
+    virtual bool canSetValue(const String&);
+    virtual bool storesValueSeparateFromAttribute();
+    virtual void setFileList(const Vector<String>& paths);
+    virtual bool shouldResetOnDocumentActivation();
+    virtual bool shouldRespectListAttribute();
+    virtual bool shouldRespectSpeechAttribute();
+    virtual bool isEnumeratable();
+    virtual bool isCheckable();
+    virtual bool hasSpinButton();
+    virtual bool shouldRespectHeightAndWidthAttributes();
 
     // Parses the specified string for the type, and return
     // the double value for the parsing result if the parsing
     // succeeds; Returns defaultValue otherwise. This function can
     // return NaN or Infinity only if defaultValue is NaN or Infinity.
     virtual double parseToDouble(const String&, double defaultValue) const;
+
     // Parses the specified string for the type as parseToDouble() does.
     // In addition, it stores the number of digits after the decimal point
     // into *decimalPlaces.
-    virtual double parseToDoubleWithDecimalPlaces(const String& src, double defaultValue, unsigned *decimalPlaces) const;
+    virtual double parseToDoubleWithDecimalPlaces(const String&, double defaultValue, unsigned* decimalPlaces) const;
+
     // Parses the specified string for this InputType, and returns true if it
     // is successfully parsed. An instance pointed by the DateComponents*
     // parameter will have parsed values and be modified even if the parsing
     // fails. The DateComponents* parameter may be 0.
     virtual bool parseToDateComponents(const String&, DateComponents*) const;
+
     // Create a string representation of the specified double value for the
     // input type. If NaN or Infinity is specified, this returns an empty
     // string. This should not be called for types without valueAsNumber.
diff --git a/WebCore/html/IsIndexInputType.cpp b/WebCore/html/IsIndexInputType.cpp
index 31ee358..a275f28 100644
--- a/WebCore/html/IsIndexInputType.cpp
+++ b/WebCore/html/IsIndexInputType.cpp
@@ -32,6 +32,7 @@
 #include "IsIndexInputType.h"
 
 #include "Document.h"
+#include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
 #include <wtf/PassOwnPtr.h>
 
@@ -70,4 +71,9 @@ PassRefPtr<HTMLFormElement> IsIndexInputType::formForSubmission() const
     return form.release();
 }
 
+bool IsIndexInputType::shouldRespectListAttribute()
+{
+    return false;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/IsIndexInputType.h b/WebCore/html/IsIndexInputType.h
index f5e14af..64b06e7 100644
--- a/WebCore/html/IsIndexInputType.h
+++ b/WebCore/html/IsIndexInputType.h
@@ -45,6 +45,7 @@ private:
     virtual const AtomicString& formControlType() const;
     virtual bool supportsRequired() const;
     virtual PassRefPtr<HTMLFormElement> formForSubmission() const;
+    virtual bool shouldRespectListAttribute();
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/NumberInputType.cpp b/WebCore/html/NumberInputType.cpp
index 0a5c609..a42f949 100644
--- a/WebCore/html/NumberInputType.cpp
+++ b/WebCore/html/NumberInputType.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -36,6 +37,7 @@
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
 #include "KeyboardEvent.h"
+#include "RenderTextControl.h"
 #include <limits>
 #include <wtf/ASCIICType.h>
 #include <wtf/MathExtras.h>
@@ -234,4 +236,45 @@ double NumberInputType::acceptableError(double step) const
     return step / pow(2.0, FLT_MANT_DIG);
 }
 
+void NumberInputType::handleBlurEvent()
+{
+    // Reset the renderer value, which might be unmatched with the element value.
+    element()->setFormControlValueMatchesRenderer(false);
+
+    // We need to reset the renderer value explicitly because an unacceptable
+    // renderer value should be purged before style calculation.
+    if (element()->renderer())
+        element()->renderer()->updateFromElement();
+}
+
+bool NumberInputType::isAcceptableValue(const String& proposedValue)
+{
+    return proposedValue.isEmpty() || parseToDoubleForNumberType(proposedValue, 0);
+}
+
+String NumberInputType::sanitizeValue(const String& proposedValue)
+{
+    return parseToDoubleForNumberType(proposedValue, 0) ? proposedValue : String();
+}
+
+bool NumberInputType::hasUnacceptableValue()
+{
+    return element()->renderer() && !isAcceptableValue(toRenderTextControl(element()->renderer())->text());
+}
+
+bool NumberInputType::shouldRespectSpeechAttribute()
+{
+    return true;
+}
+
+bool NumberInputType::isNumberField() const
+{
+    return true;
+}
+
+bool NumberInputType::hasSpinButton()
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/NumberInputType.h b/WebCore/html/NumberInputType.h
index f048b54..0b23d34 100644
--- a/WebCore/html/NumberInputType.h
+++ b/WebCore/html/NumberInputType.h
@@ -63,6 +63,13 @@ private:
     virtual double parseToDoubleWithDecimalPlaces(const String&, double, unsigned*) const;
     virtual String serialize(double) const;
     virtual double acceptableError(double) const;
+    virtual void handleBlurEvent();
+    virtual bool isAcceptableValue(const String&);
+    virtual String sanitizeValue(const String&);
+    virtual bool hasUnacceptableValue();
+    virtual bool shouldRespectSpeechAttribute();
+    virtual bool isNumberField() const;
+    virtual bool hasSpinButton();
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/PasswordInputType.cpp b/WebCore/html/PasswordInputType.cpp
index cda689b..2a9ad02 100644
--- a/WebCore/html/PasswordInputType.cpp
+++ b/WebCore/html/PasswordInputType.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -58,4 +59,31 @@ void PasswordInputType::restoreFormControlState(const String&) const
     ASSERT_NOT_REACHED();
 }
 
+bool PasswordInputType::shouldUseInputMethod() const
+{
+    // Input methods are disabled for the password field because otherwise
+    // anyone can access the underlying password and display it in clear text.
+    return false;
+}
+
+bool PasswordInputType::shouldResetOnDocumentActivation()
+{
+    return true;
+}
+
+bool PasswordInputType::shouldRespectListAttribute()
+{
+    return false;
+}
+
+bool PasswordInputType::shouldRespectSpeechAttribute()
+{
+    return true;
+}
+
+bool PasswordInputType::isPasswordField() const
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/PasswordInputType.h b/WebCore/html/PasswordInputType.h
index cf25525..04c82b5 100644
--- a/WebCore/html/PasswordInputType.h
+++ b/WebCore/html/PasswordInputType.h
@@ -44,6 +44,11 @@ private:
     virtual const AtomicString& formControlType() const;
     virtual bool saveFormControlState(String&) const;
     virtual void restoreFormControlState(const String&) const;
+    virtual bool shouldUseInputMethod() const;
+    virtual bool shouldResetOnDocumentActivation();
+    virtual bool shouldRespectListAttribute();
+    virtual bool shouldRespectSpeechAttribute();
+    virtual bool isPasswordField() const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/RadioInputType.cpp b/WebCore/html/RadioInputType.cpp
index c5dfd78..0c13161 100644
--- a/WebCore/html/RadioInputType.cpp
+++ b/WebCore/html/RadioInputType.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Inc. All rights reserved.
+ * Copyright (C) 2005, 2011 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Google Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
@@ -115,4 +115,82 @@ void RadioInputType::handleKeyupEvent(KeyboardEvent* event)
     dispatchSimulatedClickIfActive(event);
 }
 
+bool RadioInputType::isKeyboardFocusable() const
+{
+    // When using Spatial Navigation, every radio button should be focusable.
+    if (isSpatialNavigationEnabled(element()->document()->frame()))
+        return true;
+
+    // Never allow keyboard tabbing to leave you in the same radio group.  Always
+    // skip any other elements in the group.
+    Node* currentFocusedNode = element()->document()->focusedNode();
+    if (currentFocusedNode && currentFocusedNode->hasTagName(inputTag)) {
+        HTMLInputElement* focusedInput = static_cast<HTMLInputElement*>(currentFocusedNode);
+        if (focusedInput->isRadioButton() && focusedInput->form() == element()->form() && focusedInput->name() == element()->name())
+            return false;
+    }
+
+    // Allow keyboard focus if we're checked or if nothing in the group is checked.
+    return element()->checked() || !element()->checkedRadioButtons().checkedButtonForGroup(element()->name());
+}
+
+void RadioInputType::attach()
+{
+    InputType::attach();
+    element()->updateCheckedRadioButtons();
+}
+
+bool RadioInputType::shouldSendChangeEventAfterCheckedChanged()
+{
+    // Don't send a change event for a radio button that's getting unchecked.
+    // This was done to match the behavior of other browsers.
+    return element()->checked();
+}
+
+PassOwnPtr<ClickHandlingState> RadioInputType::willDispatchClick()
+{
+    // An event handler can use preventDefault or "return false" to reverse the selection we do here.
+    // The ClickHandlingState object contains what we need to undo what we did here in didDispatchClick.
+
+    // We want radio groups to end up in sane states, i.e., to have something checked.
+    // Therefore if nothing is currently selected, we won't allow the upcoming action to be "undone", since
+    // we want some object in the radio group to actually get selected.
+
+    OwnPtr<ClickHandlingState> state = adoptPtr(new ClickHandlingState);
+
+    state->checked = element()->checked();
+    state->indeterminate = element()->indeterminate();
+    state->checkedRadioButton = element()->checkedRadioButtons().checkedButtonForGroup(element()->name());
+
+    if (element()->indeterminate())
+        element()->setIndeterminate(false);
+    element()->setChecked(true, true);
+
+    return state.release();
+}
+
+void RadioInputType::didDispatchClick(Event* event, const ClickHandlingState& state)
+{
+    if (event->defaultPrevented() || event->defaultHandled()) {
+        // Restore the original selected radio button if possible.
+        // Make sure it is still a radio button and only do the restoration if it still belongs to our group.
+        HTMLInputElement* checkedRadioButton = state.checkedRadioButton.get();
+        if (checkedRadioButton
+                && checkedRadioButton->isRadioButton()
+                && checkedRadioButton->form() == element()->form()
+                && checkedRadioButton->name() == element()->name()) {
+            checkedRadioButton->setChecked(true);
+        }
+        element()->setIndeterminate(state.indeterminate);
+    }
+
+    // The work we did in willDispatchClick was default handling.
+    event->setDefaultHandled();
+}
+
+bool RadioInputType::isRadioButton() const
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/RadioInputType.h b/WebCore/html/RadioInputType.h
index 86dbc47..8c731d0 100644
--- a/WebCore/html/RadioInputType.h
+++ b/WebCore/html/RadioInputType.h
@@ -47,6 +47,12 @@ private:
     virtual void handleClickEvent(MouseEvent*);
     virtual void handleKeydownEvent(KeyboardEvent*);
     virtual void handleKeyupEvent(KeyboardEvent*);
+    virtual bool isKeyboardFocusable() const;
+    virtual void attach();
+    virtual bool shouldSendChangeEventAfterCheckedChanged();
+    virtual PassOwnPtr<ClickHandlingState> willDispatchClick();
+    virtual void didDispatchClick(Event*, const ClickHandlingState&);
+    virtual bool isRadioButton() const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/RangeInputType.cpp b/WebCore/html/RangeInputType.cpp
index 89b248e..5d71da7 100644
--- a/WebCore/html/RangeInputType.cpp
+++ b/WebCore/html/RangeInputType.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -36,6 +37,7 @@
 #include "HTMLParserIdioms.h"
 #include "KeyboardEvent.h"
 #include "RenderSlider.h"
+#include "StepRange.h"
 #include <limits>
 #include <wtf/MathExtras.h>
 #include <wtf/PassOwnPtr.h>
@@ -205,4 +207,44 @@ String RangeInputType::serialize(double value) const
     return serializeForNumberType(value);
 }
 
+// FIXME: Could share this with BaseButtonInputType and BaseCheckableInputType if we had a common base class.
+void RangeInputType::accessKeyAction(bool sendToAnyElement)
+{
+    InputType::accessKeyAction(sendToAnyElement);
+
+    // Send mouse button events if the caller specified sendToAnyElement.
+    // FIXME: The comment above is no good. It says what we do, but not why.
+    element()->dispatchSimulatedClick(0, sendToAnyElement);
+}
+
+void RangeInputType::minOrMaxAttributeChanged()
+{
+    InputType::minOrMaxAttributeChanged();
+
+    // Sanitize the value.
+    element()->setValue(element()->value());
+    element()->setNeedsStyleRecalc();
+}
+
+String RangeInputType::fallbackValue()
+{
+    return serializeForNumberType(StepRange(element()).defaultValue());
+}
+
+String RangeInputType::sanitizeValue(const String& proposedValue)
+{
+    // If the proposedValue is null than this is a reset scenario and we
+    // want the range input's value attribute to take priority over the
+    // calculated default (middle) value.
+    if (proposedValue.isNull())
+        return proposedValue;
+
+    return serializeForNumberType(StepRange(element()).clampValue(proposedValue));
+}
+
+bool RangeInputType::shouldRespectListAttribute()
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/RangeInputType.h b/WebCore/html/RangeInputType.h
index c802602..7f341a7 100644
--- a/WebCore/html/RangeInputType.h
+++ b/WebCore/html/RangeInputType.h
@@ -60,6 +60,11 @@ private:
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
     virtual double parseToDouble(const String&, double) const;
     virtual String serialize(double) const;
+    virtual void accessKeyAction(bool sendToAnyElement);
+    virtual void minOrMaxAttributeChanged();
+    virtual String fallbackValue();
+    virtual String sanitizeValue(const String& proposedValue);
+    virtual bool shouldRespectListAttribute();
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/ResetInputType.cpp b/WebCore/html/ResetInputType.cpp
index 27bf8ea..4a7be33 100644
--- a/WebCore/html/ResetInputType.cpp
+++ b/WebCore/html/ResetInputType.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -32,7 +33,9 @@
 #include "ResetInputType.h"
 
 #include "Event.h"
+#include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
+#include "LocalizedStrings.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -60,4 +63,14 @@ void ResetInputType::handleDOMActivateEvent(Event* event)
     event->setDefaultHandled();
 }
 
+String ResetInputType::defaultValue()
+{
+    return resetButtonDefaultLabel();
+}
+
+bool ResetInputType::isTextButton() const
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/ResetInputType.h b/WebCore/html/ResetInputType.h
index 651ae50..2c633bc 100644
--- a/WebCore/html/ResetInputType.h
+++ b/WebCore/html/ResetInputType.h
@@ -44,6 +44,8 @@ private:
     virtual const AtomicString& formControlType() const;
     virtual bool supportsValidation() const;
     virtual void handleDOMActivateEvent(Event*);
+    virtual String defaultValue();
+    virtual bool isTextButton() const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/SearchInputType.cpp b/WebCore/html/SearchInputType.cpp
index 6f3a01c..2006486 100644
--- a/WebCore/html/SearchInputType.cpp
+++ b/WebCore/html/SearchInputType.cpp
@@ -45,4 +45,14 @@ const AtomicString& SearchInputType::formControlType() const
     return InputTypeNames::search();
 }
 
+bool SearchInputType::shouldRespectSpeechAttribute()
+{
+    return true;
+}
+
+bool SearchInputType::isSearchField() const
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/SearchInputType.h b/WebCore/html/SearchInputType.h
index edffdb0..56cda53 100644
--- a/WebCore/html/SearchInputType.h
+++ b/WebCore/html/SearchInputType.h
@@ -42,6 +42,8 @@ public:
 private:
     SearchInputType(HTMLInputElement* element) : BaseTextInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual bool shouldRespectSpeechAttribute();
+    virtual bool isSearchField() const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/SubmitInputType.cpp b/WebCore/html/SubmitInputType.cpp
index 155aa22..da6dde8 100644
--- a/WebCore/html/SubmitInputType.cpp
+++ b/WebCore/html/SubmitInputType.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -33,7 +34,9 @@
 
 #include "Event.h"
 #include "FormDataList.h"
+#include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
+#include "LocalizedStrings.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -72,4 +75,24 @@ void SubmitInputType::handleDOMActivateEvent(Event* event)
     event->setDefaultHandled();
 }
 
+bool SubmitInputType::canBeSuccessfulSubmitButton()
+{
+    return true;
+}
+
+String SubmitInputType::defaultValue()
+{
+    return submitButtonDefaultLabel();
+}
+
+bool SubmitInputType::isSubmitButton() const
+{
+    return true;
+}
+
+bool SubmitInputType::isTextButton() const
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/SubmitInputType.h b/WebCore/html/SubmitInputType.h
index 7ec1120..c102871 100644
--- a/WebCore/html/SubmitInputType.h
+++ b/WebCore/html/SubmitInputType.h
@@ -45,6 +45,10 @@ private:
     virtual bool appendFormData(FormDataList&, bool) const;
     virtual bool supportsRequired() const;
     virtual void handleDOMActivateEvent(Event*);
+    virtual bool canBeSuccessfulSubmitButton();
+    virtual String defaultValue();
+    virtual bool isSubmitButton() const;
+    virtual bool isTextButton() const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/TelephoneInputType.cpp b/WebCore/html/TelephoneInputType.cpp
index 27d66ce..c1c77f0 100644
--- a/WebCore/html/TelephoneInputType.cpp
+++ b/WebCore/html/TelephoneInputType.cpp
@@ -45,4 +45,14 @@ const AtomicString& TelephoneInputType::formControlType() const
     return InputTypeNames::telephone();
 }
 
+bool TelephoneInputType::shouldRespectSpeechAttribute()
+{
+    return true;
+}
+
+bool TelephoneInputType::isTelephoneField() const
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/TelephoneInputType.h b/WebCore/html/TelephoneInputType.h
index 9458f50..602c883 100644
--- a/WebCore/html/TelephoneInputType.h
+++ b/WebCore/html/TelephoneInputType.h
@@ -42,6 +42,8 @@ public:
 private:
     TelephoneInputType(HTMLInputElement* element) : BaseTextInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual bool shouldRespectSpeechAttribute();
+    virtual bool isTelephoneField() const;
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/TextFieldInputType.cpp b/WebCore/html/TextFieldInputType.cpp
index a249420..54527b1 100644
--- a/WebCore/html/TextFieldInputType.cpp
+++ b/WebCore/html/TextFieldInputType.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -104,4 +105,19 @@ RenderObject* TextFieldInputType::createRenderer(RenderArena* arena, RenderStyle
     return new (arena) RenderTextControlSingleLine(element(), element()->placeholderShouldBeVisible());
 }
 
+bool TextFieldInputType::shouldUseInputMethod() const
+{
+    return true;
+}
+
+String TextFieldInputType::sanitizeValue(const String& proposedValue)
+{
+    return InputElement::sanitizeValueForTextField(element(), proposedValue);
+}
+
+bool TextFieldInputType::shouldRespectListAttribute()
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/TextFieldInputType.h b/WebCore/html/TextFieldInputType.h
index 8333b27..e882c82 100644
--- a/WebCore/html/TextFieldInputType.h
+++ b/WebCore/html/TextFieldInputType.h
@@ -40,14 +40,19 @@ namespace WebCore {
 class TextFieldInputType : public InputType {
 protected:
     TextFieldInputType(HTMLInputElement* element) : InputType(element) { }
-    virtual bool isTextField() const;
-    virtual bool valueMissing(const String&) const;
     virtual void handleKeydownEvent(KeyboardEvent*);
     void handleKeydownEventForSpinButton(KeyboardEvent*);
     void handleWheelEventForSpinButton(WheelEvent*);
+
+private:
+    virtual bool isTextField() const;
+    virtual bool valueMissing(const String&) const;
     virtual void forwardEvent(Event*);
     virtual bool shouldSubmitImplicitly(Event*);
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
+    virtual bool shouldUseInputMethod() const;
+    virtual String sanitizeValue(const String& proposedValue);
+    virtual bool shouldRespectListAttribute();
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/TextInputType.cpp b/WebCore/html/TextInputType.cpp
index 23a8679..c37263a 100644
--- a/WebCore/html/TextInputType.cpp
+++ b/WebCore/html/TextInputType.cpp
@@ -45,4 +45,15 @@ const AtomicString& TextInputType::formControlType() const
     return InputTypeNames::text();
 }
 
+bool TextInputType::canSetSuggestedValue()
+{
+    // FIXME: Should this really be restricted to plain text? What about search, for example?
+    return true;
+}
+
+bool TextInputType::shouldRespectSpeechAttribute()
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/TextInputType.h b/WebCore/html/TextInputType.h
index 89fd9b0..3b6810e 100644
--- a/WebCore/html/TextInputType.h
+++ b/WebCore/html/TextInputType.h
@@ -42,6 +42,8 @@ public:
 private:
     TextInputType(HTMLInputElement* element) : BaseTextInputType(element) { }
     virtual const AtomicString& formControlType() const;
+    virtual bool canSetSuggestedValue();
+    virtual bool shouldRespectSpeechAttribute();
 };
 
 } // namespace WebCore
diff --git a/WebCore/html/TimeInputType.cpp b/WebCore/html/TimeInputType.cpp
index 6b381be..33423a9 100644
--- a/WebCore/html/TimeInputType.cpp
+++ b/WebCore/html/TimeInputType.cpp
@@ -91,7 +91,7 @@ double TimeInputType::stepScaleFactor() const
     return timeStepScaleFactor;
 }
 
-bool TimeInputType::scaledStepValeuShouldBeInteger() const
+bool TimeInputType::scaledStepValueShouldBeInteger() const
 {
     return true;
 }
diff --git a/WebCore/html/TimeInputType.h b/WebCore/html/TimeInputType.h
index b50d987..3e68fad 100644
--- a/WebCore/html/TimeInputType.h
+++ b/WebCore/html/TimeInputType.h
@@ -47,7 +47,7 @@ private:
     virtual double maximum() const;
     virtual double defaultStep() const;
     virtual double stepScaleFactor() const;
-    virtual bool scaledStepValeuShouldBeInteger() const;
+    virtual bool scaledStepValueShouldBeInteger() const;
     virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const;
     virtual bool setMillisecondToDateComponents(double, DateComponents*) const;
 };
diff --git a/WebCore/html/URLInputType.cpp b/WebCore/html/URLInputType.cpp
index 1b8f3da..3a913b2 100644
--- a/WebCore/html/URLInputType.cpp
+++ b/WebCore/html/URLInputType.cpp
@@ -63,4 +63,9 @@ String URLInputType::typeMismatchText() const
     return validationMessageTypeMismatchForURLText();
 }
 
+bool URLInputType::isURLField() const
+{
+    return true;
+}
+
 } // namespace WebCore
diff --git a/WebCore/html/URLInputType.h b/WebCore/html/URLInputType.h
index 4a6522c..fb4bb3d 100644
--- a/WebCore/html/URLInputType.h
+++ b/WebCore/html/URLInputType.h
@@ -45,6 +45,7 @@ private:
     virtual bool typeMismatchFor(const String&) const;
     virtual bool typeMismatch() const;
     virtual String typeMismatchText() const;
+    virtual bool isURLField() const;
 };
 
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list