2011-05-06 Kent Tamura <tkent@chromium.org>
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 May 2011 04:24:09 +0000 (04:24 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 May 2011 04:24:09 +0000 (04:24 +0000)
        Reviewed by Ryosuke Niwa.

        Eliminate WebCore/dom/InputElement.{cpp,h}
        https://bugs.webkit.org/show_bug.cgi?id=60262

        - Fold in all of the code of InputElement.{cpp,h} into HTMLInputElement
          and TextFieldInputType.
        - Change the return type of Node::toInputElement():
          InputElement* -> HTMLInputElement*

        No new tests. This change should not change the existing behaviour.

        * CMakeLists.txt: Remove InpuntElement.cpp and/or InputElement.h.
        * GNUmakefile.list.am: ditto.
        * WebCore.exp.in: Add symbols of functions exposed to WebKit.
        * WebCore.gypi: Remove InpuntElement.cpp and/or InputElement.h.
        * WebCore.pro: ditto.
        * WebCore.vcproj/WebCore.vcproj: ditto.
        * WebCore.xcodeproj/project.pbxproj: ditto.
        * accessibility/AXObjectCache.cpp:
        (WebCore::AXObjectCache::textMarkerDataForVisiblePosition):
          Follow the return type change of Node::toInputElement().
        * accessibility/AccessibilityRenderObject.cpp:
        (WebCore::AccessibilityRenderObject::isPasswordField): ditto.
        (WebCore::AccessibilityRenderObject::isIndeterminate): ditto.
        (WebCore::AccessibilityRenderObject::isNativeCheckboxOrRadio): ditto.
        (WebCore::AccessibilityRenderObject::isChecked): ditto.
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::canShareStyleWithElement): ditto.
        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector): ditto.
        * dom/CheckedRadioButtons.cpp:
        (WebCore::CheckedRadioButtons::removeButton): ditto.
        * dom/DOMAllInOne.cpp: Remove InputElement.h.
        * dom/InputElement.cpp: Removed.
        * dom/InputElement.h: Removed.
        * dom/Node.cpp:
        (WebCore::Node::toInputElement):
          Change the return type from InputElement* to HTMLInputElement*.
        * dom/Node.h: ditto.
        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::HTMLInputElement):
        (WebCore::HTMLInputElement::formControlName):
        (WebCore::HTMLInputElement::tooLong):
        (WebCore::HTMLInputElement::updateFocusAppearance):
        (WebCore::HTMLInputElement::aboutToUnload):
        (WebCore::HTMLInputElement::handleFocusEvent):
        (WebCore::HTMLInputElement::handleBlurEvent):
        (WebCore::HTMLInputElement::updateType):
        (WebCore::HTMLInputElement::parseMappedAttribute):
        (WebCore::HTMLInputElement::size):
        (WebCore::HTMLInputElement::copyNonAttributeProperties):
        (WebCore::HTMLInputElement::value):
        (WebCore::HTMLInputElement::suggestedValue):
        (WebCore::HTMLInputElement::setSuggestedValue):
        (WebCore::HTMLInputElement::setValue):
        (WebCore::HTMLInputElement::setValueFromRenderer):
        (WebCore::HTMLInputElement::setFileListFromRenderer):
        (WebCore::HTMLInputElement::setDefaultName):
        (WebCore::HTMLInputElement::maxLength):
        (WebCore::HTMLInputElement::cacheSelection):
        (WebCore::formatCodes): Moved from InputElement.
        (WebCore::cursorPositionToMaskIndex): ditto.
        (WebCore::HTMLInputElement::isConformToInputMask): ditto.
        (WebCore::HTMLInputElement::validateInputMask): ditto.
        (WebCore::HTMLInputElement::setWapInputFormat): ditto.
        (WebCore::HTMLInputElement::notifyFormStateChanged): ditto.
        (WebCore::HTMLInputElement::parseMaxLengthAttribute): ditto.
        (WebCore::HTMLInputElement::updateValueIfNeeded):ditto.
        * html/HTMLInputElement.h:
          - Add data members which were defined in InputElementData.
          - Make some functions public because the public interface InputElement is removed.
          - Make some functions non-virtual because they don't override
            corresponding virtual functions of InputElement anymore.
        (WebCore::HTMLInputElement::toInputElement):
          Follow the return type change of Node::toInputElement().
        (WebCore::HTMLInputElement::isIndeterminate):
        (WebCore::HTMLInputElement::isAutofilled):
        (WebCore::HTMLInputElement::supportsMaxLength):
        (WebCore::HTMLInputElement::cachedSelectionStart):
        (WebCore::HTMLInputElement::cachedSelectionEnd):
        * html/HTMLTextAreaElement.cpp: Remove unused InputElement.h.
        * html/InputType.cpp:
        (WebCore::InputType::handleBeforeTextInsertedEvent): Remove the code.
        * html/InputType.h: Update for the above.
        * html/TextFieldInputType.cpp:
        (WebCore::replaceEOLAndLimitLength): Moved from InputElement.cpp.
        (WebCore::TextFieldInputType::sanitizeValue): Implement with replaceEOLAndLimitLength().
        (WebCore::TextFieldInputType::handleBeforeTextInsertedEvent):
          Move the code from InputElement::handleBeforeTextInsertedEvent().
        * html/TextFieldInputType.h: Update declarations.
        * rendering/RenderTextControlSingleLine.cpp:
          - Remove ASSERT(node()->isHTMLElement()) because it is checked in the constructor.
          - Follow the return type change of inputElement().
        (WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
          Make sure node() is an HTMLInputElement instance.
        (WebCore::RenderTextControlSingleLine::addSearchResult):
        (WebCore::RenderTextControlSingleLine::stopSearchEventTimer):
        (WebCore::RenderTextControlSingleLine::showPopup):
        (WebCore::RenderTextControlSingleLine::hidePopup):
        (WebCore::RenderTextControlSingleLine::subtreeHasChanged):
        (WebCore::RenderTextControlSingleLine::updateFromElement):
        (WebCore::RenderTextControlSingleLine::createInnerBlockStyle):
        (WebCore::RenderTextControlSingleLine::createResultsButtonStyle):
        (WebCore::RenderTextControlSingleLine::createCancelButtonStyle):
        (WebCore::RenderTextControlSingleLine::createInnerSpinButtonStyle):
        (WebCore::RenderTextControlSingleLine::createOuterSpinButtonStyle):
        (WebCore::RenderTextControlSingleLine::createSpeechButtonStyle):
        (WebCore::RenderTextControlSingleLine::visibilityForCancelButton):
        (WebCore::RenderTextControlSingleLine::startSearchEventTimer):
        (WebCore::RenderTextControlSingleLine::searchEventTimerFired):
        (WebCore::RenderTextControlSingleLine::valueChanged):
        (WebCore::RenderTextControlSingleLine::setTextFromItem):
        (WebCore::RenderTextControlSingleLine::inputElement):
        * rendering/RenderTextControlSingleLine.h:
          Change the return type of inputElement(): InputElement* -> HTMLInputElement*.
        * rendering/RenderTheme.cpp:
        (WebCore::RenderTheme::isChecked):
          Follow the return type change of Node::toInputElement().
        (WebCore::RenderTheme::isIndeterminate): ditto.
        (WebCore::RenderTheme::shouldHaveSpinButton):
          Change the parameter type: InputElement* -> HTMLInputElement*.
        * rendering/RenderTheme.h: ditto.
2011-05-06  Kent Tamura  <tkent@chromium.org>

        Reviewed by Ryosuke Niwa.

        Eliminate WebCore/dom/InputElement.{cpp,h}
        https://bugs.webkit.org/show_bug.cgi?id=60262

        * src/WebInputElement.cpp:
        (WebKit::WebInputElement::defaultMaxLength):
          Replace InputElement::s_maximumLength with HTMLInputElement::maximumLength.
        (WebKit::toWebInputElement):
          Follow the return type change of Node::toInputElement().
2011-05-06  Kent Tamura  <tkent@chromium.org>

        Reviewed by Ryosuke Niwa.

        Eliminate WebCore/dom/InputElement.{cpp,h}
        https://bugs.webkit.org/show_bug.cgi?id=60262

        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
        (DumpRenderTreeSupportGtk::setAutofilled):
          Follow the return type change of Node::toInputElement().
        (DumpRenderTreeSupportGtk::setValueForUser): ditto.
2011-05-06  Kent Tamura  <tkent@chromium.org>

        Reviewed by Ryosuke Niwa.

        Eliminate WebCore/dom/InputElement.{cpp,h}
        https://bugs.webkit.org/show_bug.cgi?id=60262

        * Api/qwebpage.cpp:
        (QWebPage::inputMethodQuery):
          Replace InputElement::s_maximumLength with HTMLInputElement::maximumLength.
        * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
        (DumpRenderTreeSupportQt::setAutofilled):
          Follow the return type change of Node::toInputElement().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@85998 268f45cc-cd09-0410-ab3c-d52691b4dbfc

34 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/dom/CheckedRadioButtons.cpp
Source/WebCore/dom/DOMAllInOne.cpp
Source/WebCore/dom/InputElement.cpp [deleted file]
Source/WebCore/dom/InputElement.h [deleted file]
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/InputType.cpp
Source/WebCore/html/TextFieldInputType.cpp
Source/WebCore/html/TextFieldInputType.h
Source/WebCore/rendering/RenderTextControlSingleLine.cpp
Source/WebCore/rendering/RenderTextControlSingleLine.h
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebInputElement.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
Source/WebKit/qt/Api/qwebpage.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp

index 58ade54..2cfa5e9 100644 (file)
@@ -570,7 +570,6 @@ SET(WebCore_SOURCES
     dom/ExceptionBase.cpp
     dom/ExceptionCode.cpp
     dom/IconURL.cpp
-    dom/InputElement.cpp
     dom/KeyboardEvent.cpp
     dom/MessageChannel.cpp
     dom/MessageEvent.cpp
index 3217108..9023034 100644 (file)
@@ -1,3 +1,128 @@
+2011-05-06  Kent Tamura  <tkent@chromium.org>
+
+        Reviewed by Ryosuke Niwa.
+
+        Eliminate WebCore/dom/InputElement.{cpp,h}
+        https://bugs.webkit.org/show_bug.cgi?id=60262
+
+        - Fold in all of the code of InputElement.{cpp,h} into HTMLInputElement
+          and TextFieldInputType.
+        - Change the return type of Node::toInputElement():
+          InputElement* -> HTMLInputElement*
+
+        No new tests. This change should not change the existing behaviour.
+
+        * CMakeLists.txt: Remove InpuntElement.cpp and/or InputElement.h.
+        * GNUmakefile.list.am: ditto.
+        * WebCore.exp.in: Add symbols of functions exposed to WebKit.
+        * WebCore.gypi: Remove InpuntElement.cpp and/or InputElement.h.
+        * WebCore.pro: ditto.
+        * WebCore.vcproj/WebCore.vcproj: ditto.
+        * WebCore.xcodeproj/project.pbxproj: ditto.
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::textMarkerDataForVisiblePosition):
+          Follow the return type change of Node::toInputElement().
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::isPasswordField): ditto.
+        (WebCore::AccessibilityRenderObject::isIndeterminate): ditto.
+        (WebCore::AccessibilityRenderObject::isNativeCheckboxOrRadio): ditto.
+        (WebCore::AccessibilityRenderObject::isChecked): ditto.
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::canShareStyleWithElement): ditto.
+        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector): ditto.
+        * dom/CheckedRadioButtons.cpp:
+        (WebCore::CheckedRadioButtons::removeButton): ditto.
+        * dom/DOMAllInOne.cpp: Remove InputElement.h.
+        * dom/InputElement.cpp: Removed.
+        * dom/InputElement.h: Removed.
+        * dom/Node.cpp:
+        (WebCore::Node::toInputElement):
+          Change the return type from InputElement* to HTMLInputElement*.
+        * dom/Node.h: ditto.
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::HTMLInputElement):
+        (WebCore::HTMLInputElement::formControlName):
+        (WebCore::HTMLInputElement::tooLong):
+        (WebCore::HTMLInputElement::updateFocusAppearance):
+        (WebCore::HTMLInputElement::aboutToUnload):
+        (WebCore::HTMLInputElement::handleFocusEvent):
+        (WebCore::HTMLInputElement::handleBlurEvent):
+        (WebCore::HTMLInputElement::updateType):
+        (WebCore::HTMLInputElement::parseMappedAttribute):
+        (WebCore::HTMLInputElement::size):
+        (WebCore::HTMLInputElement::copyNonAttributeProperties):
+        (WebCore::HTMLInputElement::value):
+        (WebCore::HTMLInputElement::suggestedValue):
+        (WebCore::HTMLInputElement::setSuggestedValue):
+        (WebCore::HTMLInputElement::setValue):
+        (WebCore::HTMLInputElement::setValueFromRenderer):
+        (WebCore::HTMLInputElement::setFileListFromRenderer):
+        (WebCore::HTMLInputElement::setDefaultName):
+        (WebCore::HTMLInputElement::maxLength):
+        (WebCore::HTMLInputElement::cacheSelection):
+        (WebCore::formatCodes): Moved from InputElement.
+        (WebCore::cursorPositionToMaskIndex): ditto.
+        (WebCore::HTMLInputElement::isConformToInputMask): ditto.
+        (WebCore::HTMLInputElement::validateInputMask): ditto.
+        (WebCore::HTMLInputElement::setWapInputFormat): ditto.
+        (WebCore::HTMLInputElement::notifyFormStateChanged): ditto.
+        (WebCore::HTMLInputElement::parseMaxLengthAttribute): ditto.
+        (WebCore::HTMLInputElement::updateValueIfNeeded):ditto.
+        * html/HTMLInputElement.h:
+          - Add data members which were defined in InputElementData.
+          - Make some functions public because the public interface InputElement is removed.
+          - Make some functions non-virtual because they don't override
+            corresponding virtual functions of InputElement anymore.
+        (WebCore::HTMLInputElement::toInputElement):
+          Follow the return type change of Node::toInputElement().
+        (WebCore::HTMLInputElement::isIndeterminate):
+        (WebCore::HTMLInputElement::isAutofilled):
+        (WebCore::HTMLInputElement::supportsMaxLength):
+        (WebCore::HTMLInputElement::cachedSelectionStart):
+        (WebCore::HTMLInputElement::cachedSelectionEnd):
+        * html/HTMLTextAreaElement.cpp: Remove unused InputElement.h.
+        * html/InputType.cpp:
+        (WebCore::InputType::handleBeforeTextInsertedEvent): Remove the code.
+        * html/InputType.h: Update for the above.
+        * html/TextFieldInputType.cpp:
+        (WebCore::replaceEOLAndLimitLength): Moved from InputElement.cpp.
+        (WebCore::TextFieldInputType::sanitizeValue): Implement with replaceEOLAndLimitLength().
+        (WebCore::TextFieldInputType::handleBeforeTextInsertedEvent):
+          Move the code from InputElement::handleBeforeTextInsertedEvent().
+        * html/TextFieldInputType.h: Update declarations.
+        * rendering/RenderTextControlSingleLine.cpp:
+          - Remove ASSERT(node()->isHTMLElement()) because it is checked in the constructor.
+          - Follow the return type change of inputElement().
+        (WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
+          Make sure node() is an HTMLInputElement instance.
+        (WebCore::RenderTextControlSingleLine::addSearchResult):
+        (WebCore::RenderTextControlSingleLine::stopSearchEventTimer):
+        (WebCore::RenderTextControlSingleLine::showPopup):
+        (WebCore::RenderTextControlSingleLine::hidePopup):
+        (WebCore::RenderTextControlSingleLine::subtreeHasChanged):
+        (WebCore::RenderTextControlSingleLine::updateFromElement):
+        (WebCore::RenderTextControlSingleLine::createInnerBlockStyle):
+        (WebCore::RenderTextControlSingleLine::createResultsButtonStyle):
+        (WebCore::RenderTextControlSingleLine::createCancelButtonStyle):
+        (WebCore::RenderTextControlSingleLine::createInnerSpinButtonStyle):
+        (WebCore::RenderTextControlSingleLine::createOuterSpinButtonStyle):
+        (WebCore::RenderTextControlSingleLine::createSpeechButtonStyle):
+        (WebCore::RenderTextControlSingleLine::visibilityForCancelButton):
+        (WebCore::RenderTextControlSingleLine::startSearchEventTimer):
+        (WebCore::RenderTextControlSingleLine::searchEventTimerFired):
+        (WebCore::RenderTextControlSingleLine::valueChanged):
+        (WebCore::RenderTextControlSingleLine::setTextFromItem):
+        (WebCore::RenderTextControlSingleLine::inputElement):
+        * rendering/RenderTextControlSingleLine.h:
+          Change the return type of inputElement(): InputElement* -> HTMLInputElement*.
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::isChecked):
+          Follow the return type change of Node::toInputElement().
+        (WebCore::RenderTheme::isIndeterminate): ditto.
+        (WebCore::RenderTheme::shouldHaveSpinButton):
+          Change the parameter type: InputElement* -> HTMLInputElement*.
+        * rendering/RenderTheme.h: ditto.
+
 2011-05-06  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Eric Seidel.
index 6e6f8a3..4dd7655 100644 (file)
@@ -1153,8 +1153,6 @@ webcore_sources += \
        Source/WebCore/dom/IgnoreDestructiveWriteCountIncrementer.h \
        Source/WebCore/dom/IconURL.cpp \
        Source/WebCore/dom/IconURL.h \
-       Source/WebCore/dom/InputElement.cpp \
-       Source/WebCore/dom/InputElement.h \
        Source/WebCore/dom/HashChangeEvent.h \
        Source/WebCore/dom/KeyboardEvent.cpp \
        Source/WebCore/dom/KeyboardEvent.h \
index c54ffcd..0964ee0 100644 (file)
@@ -445,6 +445,7 @@ __ZN7WebCore16FontFallbackList15releaseFontDataEv
 __ZN7WebCore16FontPlatformDataC1EP6NSFontfbbNS_15FontOrientationENS_15TextOrientationENS_16FontWidthVariantE
 __ZN7WebCore16FontPlatformDataD1Ev
 __ZN7WebCore16HTMLInputElement13setAutofilledEb
+__ZN7WebCore16HTMLInputElement15setValueForUserERKN3WTF6StringE
 __ZN7WebCore16IconDatabaseBase28synchronousIconURLForPageURLERKN3WTF6StringE
 __ZN7WebCore16IconDatabaseBase4openERKN3WTF6StringES4_
 __ZN7WebCore16LegacyWebArchive19createFromSelectionEPNS_5FrameE
@@ -1146,7 +1147,9 @@ __ZNK7WebCore15VisiblePosition19absoluteCaretBoundsEv
 __ZNK7WebCore15VisiblePosition4nextENS_27EditingBoundaryCrossingRuleE
 __ZNK7WebCore15VisiblePosition8previousENS_27EditingBoundaryCrossingRuleE
 __ZNK7WebCore16FontFallbackList10fontDataAtEPKNS_4FontEj
+__ZNK7WebCore16HTMLInputElement11isTextFieldEv
 __ZNK7WebCore16HTMLInputElement12autoCompleteEv
+__ZNK7WebCore16HTMLInputElement15isPasswordFieldEv
 __ZNK7WebCore16HTMLInputElement21lastChangeWasUserEditEv
 __ZNK7WebCore16IconDatabaseBase12databasePathEv
 __ZNK7WebCore16ResourceResponse13nsURLResponseEv
index 501a76d..9affc52 100644 (file)
             'dom/EventTarget.h',
             'dom/ExceptionCode.h',
             'dom/FragmentScriptingPermission.h',
-            'dom/InputElement.h',
             'dom/KeyboardEvent.h',
             'dom/MappedAttributeEntry.h',
             'dom/MessagePort.h',
             'dom/IgnoreDestructiveWriteCountIncrementer.h',
             'dom/IconURL.cpp',
             'dom/IconURL.h',
-            'dom/InputElement.cpp',
             'dom/KeyboardEvent.cpp',
             'dom/MessageChannel.cpp',
             'dom/MessageChannel.h',
index 656540a..d6fb251 100644 (file)
@@ -493,7 +493,6 @@ SOURCES += \
     dom/ExceptionBase.cpp \
     dom/ExceptionCode.cpp \
     dom/IconURL.cpp \
-    dom/InputElement.cpp \
     dom/KeyboardEvent.cpp \
     dom/MessageChannel.cpp \
     dom/MessageEvent.cpp \
@@ -1470,7 +1469,6 @@ HEADERS += \
     dom/ExceptionBase.h \
     dom/ExceptionCode.h \
     dom/FragmentScriptingPermission.h \
-    dom/InputElement.h \
     dom/KeyboardEvent.h \
     dom/MessageChannel.h \
     dom/MessageEvent.h \
index 3dc02c8..c33f8c2 100755 (executable)
                                >
                        </File>
                        <File
-                               RelativePath="..\dom\InputElement.cpp"
-                               >
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug_Cairo_CFLite|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release_Cairo_CFLite|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug_All|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Production|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\dom\InputElement.h"
-                               >
-                       </File>
-                       <File
                                RelativePath="..\dom\KeyboardEvent.cpp"
                                >
                                <FileConfiguration
index e67395e..12fd79b 100644 (file)
                0854B0231255E4E600B9CDD0 /* SVGRootInlineBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 0854B0111255E4E600B9CDD0 /* SVGRootInlineBox.h */; };
                0854B0251255E4E600B9CDD0 /* SVGTextQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 0854B0131255E4E600B9CDD0 /* SVGTextQuery.h */; };
                085797091278394C00A8EC5F /* SVGAnimatedBoolean.h in Headers */ = {isa = PBXBuildFile; fileRef = 085797081278394C00A8EC5F /* SVGAnimatedBoolean.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               08591AA50F085C4E009BACB1 /* InputElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08591AA40F085C4E009BACB1 /* InputElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
                085A15931289A8DD002710E3 /* SVGAnimatedTransformListPropertyTearOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 085A15921289A8DD002710E3 /* SVGAnimatedTransformListPropertyTearOff.h */; settings = {ATTRIBUTES = (Private, ); }; };
                085B92BA0EFDE73D00E6123C /* FormDataBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 085B92B80EFDE73D00E6123C /* FormDataBuilder.cpp */; };
                085B92BB0EFDE73D00E6123C /* FormDataBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 085B92B90EFDE73D00E6123C /* FormDataBuilder.h */; settings = {ATTRIBUTES = (); }; };
                08641D4712142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08641D4512142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp */; };
                08641D4812142F7D008DE9F6 /* RenderImageResourceStyleImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 08641D4612142F7D008DE9F6 /* RenderImageResourceStyleImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
                086BBD0F136039C2008B15D8 /* Glyph.h in Headers */ = {isa = PBXBuildFile; fileRef = 086BBD0E136039C2008B15D8 /* Glyph.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               08700BE70F086C5300919419 /* InputElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08700BE60F086C5300919419 /* InputElement.cpp */; };
                087281550F26B9B600AFC596 /* OptionElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 087281510F26B9B600AFC596 /* OptionElement.cpp */; };
                087281560F26B9B600AFC596 /* OptionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 087281520F26B9B600AFC596 /* OptionElement.h */; };
                087281570F26B9B600AFC596 /* OptionGroupElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 087281530F26B9B600AFC596 /* OptionGroupElement.cpp */; };
                0854B0121255E4E600B9CDD0 /* SVGTextQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTextQuery.cpp; sourceTree = "<group>"; };
                0854B0131255E4E600B9CDD0 /* SVGTextQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextQuery.h; sourceTree = "<group>"; };
                085797081278394C00A8EC5F /* SVGAnimatedBoolean.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedBoolean.h; sourceTree = "<group>"; };
-               08591AA40F085C4E009BACB1 /* InputElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InputElement.h; sourceTree = "<group>"; };
                085A15921289A8DD002710E3 /* SVGAnimatedTransformListPropertyTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedTransformListPropertyTearOff.h; sourceTree = "<group>"; };
                085B92B80EFDE73D00E6123C /* FormDataBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormDataBuilder.cpp; sourceTree = "<group>"; };
                085B92B90EFDE73D00E6123C /* FormDataBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormDataBuilder.h; sourceTree = "<group>"; };
                08641D4512142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderImageResourceStyleImage.cpp; sourceTree = "<group>"; };
                08641D4612142F7D008DE9F6 /* RenderImageResourceStyleImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderImageResourceStyleImage.h; sourceTree = "<group>"; };
                086BBD0E136039C2008B15D8 /* Glyph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Glyph.h; sourceTree = "<group>"; };
-               08700BE60F086C5300919419 /* InputElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InputElement.cpp; sourceTree = "<group>"; };
                087281510F26B9B600AFC596 /* OptionElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionElement.cpp; sourceTree = "<group>"; };
                087281520F26B9B600AFC596 /* OptionElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionElement.h; sourceTree = "<group>"; };
                087281530F26B9B600AFC596 /* OptionGroupElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionGroupElement.cpp; sourceTree = "<group>"; };
                                2442BBF81194C9D300D49469 /* HashChangeEvent.h */,
                                8482B7441198C32E00BFB005 /* HashChangeEvent.idl */,
                                8AB4BC76126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h */,
-                               08700BE60F086C5300919419 /* InputElement.cpp */,
-                               08591AA40F085C4E009BACB1 /* InputElement.h */,
                                85031B2D0A44EFC700F992E0 /* KeyboardEvent.cpp */,
                                85031B2E0A44EFC700F992E0 /* KeyboardEvent.h */,
                                14CF7C2009F7110600EB3665 /* KeyboardEvent.idl */,
                                A8CFF5E30A155A05000A4234 /* InlineFlowBox.h in Headers */,
                                BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */,
                                BCEA485A097D93020094C9E4 /* InlineTextBox.h in Headers */,
-                               08591AA50F085C4E009BACB1 /* InputElement.h in Headers */,
                                37E3524D12450C6600BAF5D9 /* InputType.h in Headers */,
                                93309DEA099E64920056E581 /* InsertIntoTextNodeCommand.h in Headers */,
                                93309DEC099E64920056E581 /* InsertLineBreakCommand.h in Headers */,
                                A8CFF5E60A155A05000A4234 /* InlineBox.cpp in Sources */,
                                A8CFF5E40A155A05000A4234 /* InlineFlowBox.cpp in Sources */,
                                BCEA4859097D93020094C9E4 /* InlineTextBox.cpp in Sources */,
-                               08700BE70F086C5300919419 /* InputElement.cpp in Sources */,
                                37E3524B12450C5200BAF5D9 /* InputType.cpp in Sources */,
                                93309DE9099E64920056E581 /* InsertIntoTextNodeCommand.cpp in Sources */,
                                93309DEB099E64920056E581 /* InsertLineBreakCommand.cpp in Sources */,
index b471201..19a45dd 100644 (file)
 #include "Frame.h"
 #include "HTMLAreaElement.h"
 #include "HTMLImageElement.h"
+#include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #if ENABLE(VIDEO)
 #include "MediaControlElements.h"
 #endif
-#include "InputElement.h"
 #include "Page.h"
 #include "RenderListBox.h"
 #include "RenderMenuList.h"
@@ -616,7 +616,7 @@ void AXObjectCache::textMarkerDataForVisiblePosition(TextMarkerData& textMarkerD
         return;
     
     if (domNode->isHTMLElement()) {
-        InputElement* inputElement = domNode->toInputElement();
+        HTMLInputElement* inputElement = domNode->toInputElement();
         if (inputElement && inputElement->isPasswordField())
             return;
     }
index fbaadec..02a1bbf 100644 (file)
@@ -496,7 +496,7 @@ bool AccessibilityRenderObject::isPasswordField() const
     if (ariaRoleAttribute() != UnknownRole)
         return false;
 
-    InputElement* inputElement = m_renderer->node()->toInputElement();
+    HTMLInputElement* inputElement = m_renderer->node()->toInputElement();
     if (!inputElement)
         return false;
 
@@ -589,7 +589,7 @@ bool AccessibilityRenderObject::isIndeterminate() const
     if (!m_renderer->node())
         return false;
 
-    InputElement* inputElement = m_renderer->node()->toInputElement();
+    HTMLInputElement* inputElement = m_renderer->node()->toInputElement();
     if (!inputElement)
         return false;
 
@@ -600,7 +600,7 @@ bool AccessibilityRenderObject::isNativeCheckboxOrRadio() const
 {
     Node* elementNode = node();
     if (elementNode) {
-        InputElement* input = elementNode->toInputElement();
+        HTMLInputElement* input = elementNode->toInputElement();
         if (input)
             return input->isCheckbox() || input->isRadioButton();
     }
@@ -615,7 +615,7 @@ bool AccessibilityRenderObject::isChecked() const
         return false;
 
     // First test for native checkedness semantics
-    InputElement* inputElement = m_renderer->node()->toInputElement();
+    HTMLInputElement* inputElement = m_renderer->node()->toInputElement();
     if (inputElement)
         return inputElement->isChecked();
 
index 9dcdcbe..5f0aacd 100644 (file)
@@ -1069,8 +1069,8 @@ bool CSSStyleSelector::canShareStyleWithElement(Node* node) const
         return false;
 
     if (isControl) {
-        InputElement* thisInputElement = element->toInputElement();
-        InputElement* otherInputElement = m_element->toInputElement();
+        HTMLInputElement* thisInputElement = element->toInputElement();
+        HTMLInputElement* otherInputElement = m_element->toInputElement();
 
         if (!thisInputElement || !otherInputElement)
             return false;
@@ -2773,7 +2773,7 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
             case CSSSelector::PseudoAutofill: {
                 if (!e || !e->isFormControlElement())
                     break;
-                if (InputElement* inputElement = e->toInputElement())
+                if (HTMLInputElement* inputElement = e->toInputElement())
                     return inputElement->isAutofilled();
                 break;
             }
@@ -2866,7 +2866,7 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
                 // Even though WinIE allows checked and indeterminate to co-exist, the CSS selector spec says that
                 // you can't be both checked and indeterminate.  We will behave like WinIE behind the scenes and just
                 // obey the CSS spec here in the test for matching the pseudo.
-                InputElement* inputElement = e->toInputElement();
+                HTMLInputElement* inputElement = e->toInputElement();
                 if (inputElement && inputElement->isChecked() && !inputElement->isIndeterminate())
                     return true;
                 break;
@@ -2874,7 +2874,7 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
             case CSSSelector::PseudoIndeterminate: {
                 if (!e || !e->isFormControlElement())
                     break;
-                InputElement* inputElement = e->toInputElement();
+                HTMLInputElement* inputElement = e->toInputElement();
                 if (inputElement && inputElement->isIndeterminate())
                     return true;
                 break;
index 7523372..2a0fea4 100644 (file)
@@ -77,7 +77,7 @@ void CheckedRadioButtons::removeButton(HTMLFormControlElement* element)
     if (it == m_nameToCheckedRadioButtonMap->end() || it->second != element)
         return;
     
-    InputElement* inputElement = element->toInputElement();
+    HTMLInputElement* inputElement = element->toInputElement();
     ASSERT_UNUSED(inputElement, inputElement);
     ASSERT(inputElement->isChecked());
     ASSERT(element->isRadioButton());
index 55674df..f2949b1 100644 (file)
@@ -76,7 +76,6 @@
 #include "ExceptionBase.cpp"
 #include "ExceptionCode.cpp"
 #include "IconURL.cpp"
-#include "InputElement.cpp"
 #include "KeyboardEvent.cpp"
 #include "MessageChannel.cpp"
 #include "MessageEvent.cpp"
diff --git a/Source/WebCore/dom/InputElement.cpp b/Source/WebCore/dom/InputElement.cpp
deleted file mode 100644 (file)
index b7d148c..0000000
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "InputElement.h"
-
-#include "BeforeTextInsertedEvent.h"
-
-#if ENABLE(WCSS)
-#include "CSSPropertyNames.h"
-#include "CSSRule.h"
-#include "CSSRuleList.h"
-#include "CSSStyleRule.h"
-#include "CSSStyleSelector.h"
-#endif
-
-#include "Attribute.h"
-#include "Chrome.h"
-#include "ChromeClient.h"
-#include "Document.h"
-#include "Event.h"
-#include "EventNames.h"
-#include "Frame.h"
-#include "FrameSelection.h"
-#include "Page.h"
-#include "RenderTextControlSingleLine.h"
-#include "TextIterator.h"
-
-namespace WebCore {
-
-// FIXME: According to HTML4, the length attribute's value can be arbitrarily
-// large. However, due to https://bugs.webkit.org/show_bug.cgi?id=14536 things
-// get rather sluggish when a text field has a larger number of characters than
-// this, even when just clicking in the text field.
-const int InputElement::s_maximumLength = 524288;
-const int InputElement::s_defaultSize = 20;
-
-void InputElement::dispatchFocusEvent(InputElement* inputElement, Element* element)
-{
-    if (!inputElement->isTextField())
-        return;
-
-    Document* document = element->document();
-    if (inputElement->isPasswordField() && document->frame())
-        document->setUseSecureKeyboardEntryWhenActive(true);
-}
-
-void InputElement::dispatchBlurEvent(InputElement* inputElement, Element* element)
-{
-    if (!inputElement->isTextField())
-        return;
-
-    Document* document = element->document();
-    Frame* frame = document->frame();
-    if (!frame)
-        return;
-
-    if (inputElement->isPasswordField())
-        document->setUseSecureKeyboardEntryWhenActive(false);
-
-    frame->editor()->textFieldDidEndEditing(element);
-}
-
-void InputElement::updateFocusAppearance(InputElementData& data, InputElement* inputElement, Element* element, bool restorePreviousSelection)
-{
-    ASSERT(inputElement->isTextField());
-
-    if (!restorePreviousSelection || data.cachedSelectionStart() == -1)
-        inputElement->select();
-    else
-        // Restore the cached selection.
-        updateSelectionRange(inputElement, element, data.cachedSelectionStart(), data.cachedSelectionEnd());
-
-    Document* document = element->document();
-    if (document && document->frame())
-        document->frame()->selection()->revealSelection();
-}
-
-void InputElement::updateSelectionRange(InputElement* inputElement, Element* element, int start, int end)
-{
-    if (!inputElement->isTextField())
-        return;
-
-    setSelectionRange(element, start, end);
-}
-
-void InputElement::aboutToUnload(InputElement* inputElement, Element* element)
-{
-    if (!inputElement->isTextField() || !element->focused())
-        return;
-
-    Document* document = element->document();
-    Frame* frame = document->frame();
-    if (!frame)
-        return;
-
-    frame->editor()->textFieldDidEndEditing(element);
-}
-
-void InputElement::setValueFromRenderer(InputElementData& data, InputElement* inputElement, Element* element, const String& value)
-{
-    // Renderer and our event handler are responsible for sanitizing values.
-    ASSERT_UNUSED(inputElement, value == inputElement->sanitizeValue(value) || inputElement->sanitizeValue(value).isEmpty());
-
-    // Workaround for bug where trailing \n is included in the result of textContent.
-    // The assert macro above may also be simplified to:  value == constrainValue(value)
-    // http://bugs.webkit.org/show_bug.cgi?id=9661
-    if (value == "\n")
-        data.setValue("");
-    else
-        data.setValue(value);
-
-    element->setFormControlValueMatchesRenderer(true);
-
-    // Input event is fired by the Node::defaultEventHandler for editable controls.
-    if (!inputElement->isTextField())
-        element->dispatchInputEvent();
-    notifyFormStateChanged(element);
-}
-
-static String replaceEOLAndLimitLength(const InputElement* inputElement, const String& proposedValue, int maxLength)
-{
-    if (!inputElement->isTextField())
-        return proposedValue;
-
-    String string = proposedValue;
-    string.replace("\r\n", " ");
-    string.replace('\r', ' ');
-    string.replace('\n', ' ');
-
-    unsigned newLength = numCharactersInGraphemeClusters(string, maxLength);
-    for (unsigned i = 0; i < newLength; ++i) {
-        const UChar current = string[i];
-        if (current < ' ' && current != '\t') {
-            newLength = i;
-            break;
-        }
-    }
-    return string.left(newLength);
-}
-
-String InputElement::sanitizeValueForTextField(const InputElement* inputElement, const String& proposedValue)
-{
-#if ENABLE(WCSS)
-    InputElementData data = const_cast<InputElement*>(inputElement)->data();
-    if (!isConformToInputMask(data, proposedValue)) {
-        if (isConformToInputMask(data, data.value()))
-            return data.value();
-        return String();
-    }
-#endif
-    return replaceEOLAndLimitLength(inputElement, proposedValue, s_maximumLength);
-}
-
-String InputElement::sanitizeUserInputValue(const InputElement* inputElement, const String& proposedValue, int maxLength)
-{
-    return replaceEOLAndLimitLength(inputElement, proposedValue, maxLength);
-}
-
-void InputElement::handleBeforeTextInsertedEvent(InputElementData& data, InputElement* inputElement, Element* element, Event* event)
-{
-    ASSERT(event->isBeforeTextInsertedEvent());
-    // Make sure that the text to be inserted will not violate the maxLength.
-
-    // We use RenderTextControlSingleLine::text() instead of InputElement::value()
-    // because they can be mismatched by sanitizeValue() in
-    // RenderTextControlSingleLine::subtreeHasChanged() in some cases.
-    unsigned oldLength = numGraphemeClusters(toRenderTextControlSingleLine(element->renderer())->text());
-
-    // selectionLength represents the selection length of this text field to be
-    // removed by this insertion.
-    // If the text field has no focus, we don't need to take account of the
-    // selection length. The selection is the source of text drag-and-drop in
-    // that case, and nothing in the text field will be removed.
-    unsigned selectionLength = element->focused() ? numGraphemeClusters(plainText(element->document()->frame()->selection()->selection().toNormalizedRange().get())) : 0;
-    ASSERT(oldLength >= selectionLength);
-
-    // Selected characters will be removed by the next text event.
-    unsigned baseLength = oldLength - selectionLength;
-    unsigned maxLength = static_cast<unsigned>(inputElement->supportsMaxLength() ? data.maxLength() : s_maximumLength); // maxLength() can never be negative.
-    unsigned appendableLength = maxLength > baseLength ? maxLength - baseLength : 0;
-
-    // Truncate the inserted text to avoid violating the maxLength and other constraints.
-    BeforeTextInsertedEvent* textEvent = static_cast<BeforeTextInsertedEvent*>(event);
-#if ENABLE(WCSS)
-    RefPtr<Range> range = element->document()->frame()->selection()->selection().toNormalizedRange();
-    String candidateString = toRenderTextControlSingleLine(element->renderer())->text();
-    if (selectionLength)
-        candidateString.replace(range->startOffset(), range->endOffset(), textEvent->text());
-    else
-        candidateString.insert(textEvent->text(), range->startOffset());
-    if (!isConformToInputMask(inputElement->data(), candidateString)) {
-        textEvent->setText("");
-        return;
-    }
-#endif
-    textEvent->setText(sanitizeUserInputValue(inputElement, textEvent->text(), appendableLength));
-}
-
-void InputElement::parseSizeAttribute(InputElementData& data, Element* element, Attribute* attribute)
-{
-    data.setSize(attribute->isNull() ? InputElement::s_defaultSize : attribute->value().toInt());
-
-    if (RenderObject* renderer = element->renderer())
-        renderer->setNeedsLayoutAndPrefWidthsRecalc();
-}
-
-void InputElement::parseMaxLengthAttribute(InputElementData& data, InputElement* inputElement, Element* element, Attribute* attribute)
-{
-    int maxLength = attribute->isNull() ? InputElement::s_maximumLength : attribute->value().toInt();
-    if (maxLength <= 0 || maxLength > InputElement::s_maximumLength)
-        maxLength = InputElement::s_maximumLength;
-
-    int oldMaxLength = data.maxLength();
-    data.setMaxLength(maxLength);
-
-    if (oldMaxLength != maxLength)
-        updateValueIfNeeded(data, inputElement);
-
-    element->setNeedsStyleRecalc();
-}
-
-void InputElement::updateValueIfNeeded(InputElementData& data, InputElement* inputElement)
-{
-    String oldValue = data.value();
-    String newValue = inputElement->sanitizeValue(oldValue);
-    if (newValue != oldValue)
-        inputElement->setValue(newValue);
-}
-
-void InputElement::notifyFormStateChanged(Element* element)
-{
-    Document* document = element->document();
-    Frame* frame = document->frame();
-    if (!frame)
-        return;
-
-    if (Page* page = frame->page())
-        page->chrome()->client()->formStateDidChange(element);
-}
-
-// InputElementData
-InputElementData::InputElementData()
-    : m_size(InputElement::s_defaultSize)
-    , m_maxLength(InputElement::s_maximumLength)
-    , m_cachedSelectionStart(-1)
-    , m_cachedSelectionEnd(-1)
-#if ENABLE(WCSS)
-    , m_inputFormatMask("*m")
-    , m_maxInputCharsAllowed(InputElement::s_maximumLength)
-#endif
-{
-}
-
-InputElementData::~InputElementData()
-{
-}
-
-const AtomicString& InputElementData::name() const
-{
-    return m_name.isNull() ? emptyAtom : m_name;
-}
-
-#if ENABLE(WCSS)
-static inline const AtomicString& formatCodes()
-{
-    DEFINE_STATIC_LOCAL(AtomicString, codes, ("AaNnXxMm"));
-    return codes;
-}
-
-static unsigned cursorPositionToMaskIndex(const String& inputFormatMask, unsigned cursorPosition)
-{
-    UChar mask;
-    int index = -1;
-    do {
-        mask = inputFormatMask[++index];
-        if (mask == '\\')
-            ++index;
-        else if (mask == '*' || (isASCIIDigit(mask) && mask != '0')) {
-            index = inputFormatMask.length() - 1;
-            break;
-        }
-    } while (cursorPosition--);
-
-    return index;
-}
-
-bool InputElement::isConformToInputMask(const InputElementData& data, const String& inputChars)
-{
-    for (unsigned i = 0; i < inputChars.length(); ++i)
-        if (!isConformToInputMask(data, inputChars[i], i))
-            return false;
-    return true;
-}
-
-bool InputElement::isConformToInputMask(const InputElementData& data, UChar inChar, unsigned cursorPosition)
-{
-    String inputFormatMask = data.inputFormatMask();
-
-    if (inputFormatMask.isEmpty() || inputFormatMask == "*M" || inputFormatMask == "*m")
-        return true;
-
-    if (cursorPosition >= data.maxInputCharsAllowed())
-        return false;
-
-    unsigned maskIndex = cursorPositionToMaskIndex(inputFormatMask, cursorPosition);
-    bool ok = true;
-    UChar mask = inputFormatMask[maskIndex];
-    // Match the inputed character with input mask
-    switch (mask) {
-    case 'A':
-        ok = !isASCIIDigit(inChar) && !isASCIILower(inChar) && isASCIIPrintable(inChar);
-        break;
-    case 'a':
-        ok = !isASCIIDigit(inChar) && !isASCIIUpper(inChar) && isASCIIPrintable(inChar);
-        break;
-    case 'N':
-        ok = isASCIIDigit(inChar);
-        break;
-    case 'n':
-        ok = !isASCIIAlpha(inChar) && isASCIIPrintable(inChar);
-        break;
-    case 'X':
-        ok = !isASCIILower(inChar) && isASCIIPrintable(inChar);
-        break;
-    case 'x':
-        ok = !isASCIIUpper(inChar) && isASCIIPrintable(inChar);
-        break;
-    case 'M':
-    case 'm':
-        ok = isASCIIPrintable(inChar);
-        break;
-    default:
-        ok = (mask == inChar);
-        break;
-    }
-
-    return ok;
-}
-
-String InputElement::validateInputMask(InputElementData& data, String& inputMask)
-{
-    inputMask.replace("\\\\", "\\");
-
-    bool isValid = true;
-    bool hasWildcard = false;
-    unsigned escapeCharCount = 0;
-    unsigned maskLength = inputMask.length();
-    UChar formatCode;
-    for (unsigned i = 0; i < maskLength; ++i) {
-        formatCode = inputMask[i];
-        if (formatCodes().find(formatCode) == -1) {
-            if (formatCode == '*' || (isASCIIDigit(formatCode) && formatCode != '0')) {
-                // Validate codes which ends with '*f' or 'nf'
-                formatCode = inputMask[++i];
-                if ((i + 1 != maskLength) || formatCodes().find(formatCode) == -1) {
-                    isValid = false;
-                    break;
-                }
-                hasWildcard = true;
-            } else if (formatCode == '\\') {
-                // skip over the next mask character
-                ++i;
-                ++escapeCharCount;
-            } else {
-                isValid = false;
-                break;
-            }
-        }
-    }
-
-    if (!isValid)
-        return String();
-    // calculate the number of characters allowed to be entered by input mask
-    unsigned allowedLength = maskLength;
-    if (escapeCharCount)
-        allowedLength -= escapeCharCount;
-
-    if (hasWildcard) {
-        formatCode = inputMask[maskLength - 2];
-        if (formatCode == '*')
-            allowedLength = data.maxInputCharsAllowed();
-        else {
-            unsigned leftLen = String(&formatCode).toInt();
-            allowedLength = leftLen + allowedLength - 2;
-        }
-    }
-
-    if (allowedLength < data.maxInputCharsAllowed())
-        data.setMaxInputCharsAllowed(allowedLength);
-
-    return inputMask;
-}
-
-#endif
-
-}
diff --git a/Source/WebCore/dom/InputElement.h b/Source/WebCore/dom/InputElement.h
deleted file mode 100644 (file)
index 5a4e95d..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef InputElement_h
-#define InputElement_h
-
-#include "PlatformString.h"
-#include <wtf/text/AtomicString.h>
-
-namespace WebCore {
-
-class Attribute;
-class Document;
-class Element;
-class Event;
-class InputElementData;
-
-class InputElement {
-public:
-    virtual ~InputElement() { }
-
-    virtual bool isAutofilled() const = 0;
-    virtual bool isChecked() const = 0;
-    virtual bool isIndeterminate() const = 0;
-    virtual bool isInputTypeHidden() const = 0;
-    virtual bool isPasswordField() const = 0;
-    virtual bool isSearchField() const = 0;
-    virtual bool isTextField() const = 0;
-    virtual bool isRadioButton() const = 0;
-    virtual bool isCheckbox() const = 0;
-    virtual bool isRangeControl() const = 0;
-    
-    virtual bool supportsMaxLength() const = 0;
-    virtual bool isSteppable() const = 0;
-#if ENABLE(INPUT_SPEECH)
-    virtual bool isSpeechEnabled() const = 0;
-#endif    
-
-    virtual bool searchEventsShouldBeDispatched() const = 0;
-
-    virtual int size() const = 0;
-    virtual const String& suggestedValue() const = 0;
-    virtual String value() const = 0;
-    virtual void setValue(const String&, bool sendChangeEvent = false) = 0;
-    virtual void setValueForUser(const String&) = 0;
-    // The value which is drawn by a renderer.
-    virtual String visibleValue() const = 0;
-    virtual String convertFromVisibleValue(const String&) const = 0;
-
-    // Returns true if the specified string can be set as the value of InputElement.
-    virtual bool isAcceptableValue(const String&) const = 0;
-    virtual String sanitizeValue(const String&) const = 0;
-    virtual void setValueFromRenderer(const String&) = 0;
-
-    virtual void cacheSelection(int start, int end) = 0;
-    virtual void select() = 0;
-  
-#if ENABLE(WCSS)
-    virtual InputElementData data() const = 0; 
-#endif
-
-    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*);
-    static void updateFocusAppearance(InputElementData&, InputElement*, Element*, bool restorePreviousSelection);
-    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 the specified maximum length.
-    // This should be applied to values specified by users.
-    // The input string may be a fragment of the whole value.
-    static String sanitizeUserInputValue(const InputElement*, const String&, int);
-    static void handleBeforeTextInsertedEvent(InputElementData&, InputElement*, Element*, Event*);
-    static void parseSizeAttribute(InputElementData&, Element*, Attribute*);
-    static void parseMaxLengthAttribute(InputElementData&, InputElement*, Element*, Attribute*);
-    static void updateValueIfNeeded(InputElementData&, InputElement*);
-    static void notifyFormStateChanged(Element*);
-#if ENABLE(WCSS)
-    static bool isConformToInputMask(const InputElementData&, const String&);
-    static bool isConformToInputMask(const InputElementData&, UChar, unsigned);
-    static String validateInputMask(InputElementData&, String&);
-#endif
-};
-
-// HTMLInputElement hold this struct as member variable
-// and pass it to the static helper functions in InputElement
-class InputElementData {
-public:
-    InputElementData();
-    ~InputElementData();
-
-    const AtomicString& name() const;
-    void setName(const AtomicString& value) { m_name = value; }
-
-    // The null String represents "use the default value," and the empty String
-    // represents the empty value.
-    String value() const { return m_value; }
-    void setValue(const String& value) { m_value = value; }
-
-    const String& suggestedValue() const { return m_suggestedValue; }
-    void setSuggestedValue(const String& value) { m_suggestedValue = value; }
-
-    int size() const { return m_size; }
-    void setSize(int value) { m_size = value; }
-
-    int maxLength() const { return m_maxLength; }
-    void setMaxLength(int value) { m_maxLength = value; }
-
-    int cachedSelectionStart() const { return m_cachedSelectionStart; }
-    void setCachedSelectionStart(int value) { m_cachedSelectionStart = value; }
-
-    int cachedSelectionEnd() const { return m_cachedSelectionEnd; }
-    void setCachedSelectionEnd(int value) { m_cachedSelectionEnd = value; }
-
-#if ENABLE(WCSS)
-    String inputFormatMask() const { return m_inputFormatMask; }
-    void setInputFormatMask(const String& mask) { m_inputFormatMask = mask; }
-    unsigned maxInputCharsAllowed() const { return m_maxInputCharsAllowed; }
-    void setMaxInputCharsAllowed(unsigned maxLength) { m_maxInputCharsAllowed = maxLength; }
-  
-#endif
-
-private:
-    AtomicString m_name;
-    String m_value;
-    String m_suggestedValue;
-    int m_size;
-    int m_maxLength;
-    int m_cachedSelectionStart;
-    int m_cachedSelectionEnd;
-#if ENABLE(WCSS)
-    String m_inputFormatMask;
-    unsigned m_maxInputCharsAllowed;
-#endif
-};
-
-}
-
-#endif
index 0fc400c..4428ffa 100644 (file)
@@ -559,7 +559,7 @@ void Node::setShadowHost(Element* host)
     setParent(host);
 }
 
-InputElement* Node::toInputElement()
+HTMLInputElement* Node::toInputElement()
 {
     // If one of the below ASSERTs trigger, you are calling this function
     // directly or indirectly from a constructor or destructor of this object.
index 0571dfa..c288d1f 100644 (file)
@@ -54,7 +54,7 @@ class EventContext;
 class EventListener;
 class FloatPoint;
 class Frame;
-class InputElement;
+class HTMLInputElement;
 class IntRect;
 class KeyboardEvent;
 class NSResolver;
@@ -524,7 +524,7 @@ public:
 
     virtual Node* toNode() { return this; }
 
-    virtual InputElement* toInputElement();
+    virtual HTMLInputElement* toInputElement();
 
     virtual ScriptExecutionContext* scriptExecutionContext() const;
 
index f9ccaf9..d135f97 100644 (file)
@@ -6,6 +6,7 @@
  *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
  * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #include "AXObjectCache.h"
 #include "Attribute.h"
 #include "BeforeTextInsertedEvent.h"
+#include "Chrome.h"
+#include "ChromeClient.h"
 #include "CSSPropertyNames.h"
 #include "Document.h"
 #include "EventNames.h"
 #include "ExceptionCode.h"
 #include "FileList.h"
+#include "Frame.h"
 #include "HTMLCollection.h"
 #include "HTMLDataListElement.h"
 #include "HTMLFormElement.h"
@@ -45,6 +49,7 @@
 #include "KeyboardEvent.h"
 #include "LocalizedStrings.h"
 #include "MouseEvent.h"
+#include "Page.h"
 #include "PlatformMouseEvent.h"
 #include "RenderTextControlSingleLine.h"
 #include "RenderTheme.h"
@@ -60,10 +65,24 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
+// FIXME: According to HTML4, the length attribute's value can be arbitrarily
+// large. However, due to https://bugs.webkit.org/show_bug.cgi?id=14536 things
+// get rather sluggish when a text field has a larger number of characters than
+// this, even when just clicking in the text field.
+const int HTMLInputElement::maximumLength = 524288;
+const int defaultSize = 20;
 const int maxSavedResults = 256;
 
 HTMLInputElement::HTMLInputElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form, bool createdByParser)
     : HTMLTextFormControlElement(tagName, document, form)
+    , m_size(defaultSize)
+    , m_maxLength(maximumLength)
+    , m_cachedSelectionStart(-1)
+    , m_cachedSelectionEnd(-1)
+#if ENABLE(WCSS)
+    , m_inputFormatMask("*m")
+    , m_maxInputCharsAllowed(maximumLength)
+#endif
     , m_maxResults(-1)
     , m_isChecked(false)
     , m_reflectsCheckedAttribute(true)
@@ -98,7 +117,7 @@ HTMLInputElement::~HTMLInputElement()
 
 const AtomicString& HTMLInputElement::formControlName() const
 {
-    return m_data.name();
+    return m_name.isNull() ? emptyAtom : m_name;
 }
 
 bool HTMLInputElement::autoComplete() const
@@ -200,7 +219,7 @@ bool HTMLInputElement::tooLong(const String& value, NeedsToCheckDirtyFlag check)
         return false;
     if (check == CheckDirtyFlag) {
         // Return false for the default value even if it is longer than maxLength.
-        bool userEdited = !m_data.value().isNull();
+        bool userEdited = !m_value.isNull();
         if (!userEdited)
             return false;
     }
@@ -393,15 +412,29 @@ bool HTMLInputElement::isMouseFocusable() const
 
 void HTMLInputElement::updateFocusAppearance(bool restorePreviousSelection)
 {
-    if (isTextField())
-        InputElement::updateFocusAppearance(m_data, this, this, restorePreviousSelection);
-    else
+    if (isTextField()) {
+        if (!restorePreviousSelection || m_cachedSelectionStart == -1)
+            select();
+        else {
+            // Restore the cached selection.
+            WebCore::setSelectionRange(this, m_cachedSelectionStart, m_cachedSelectionEnd);
+        }
+        if (document()->frame())
+            document()->frame()->selection()->revealSelection();
+    } else
         HTMLFormControlElementWithState::updateFocusAppearance(restorePreviousSelection);
 }
 
 void HTMLInputElement::aboutToUnload()
 {
-    InputElement::aboutToUnload(this, this);
+    if (!isTextField() || !focused())
+        return;
+
+    Frame* frame = document()->frame();
+    if (!frame)
+        return;
+
+    frame->editor()->textFieldDidEndEditing(this);
 }
 
 bool HTMLInputElement::shouldUseInputMethod() const
@@ -411,13 +444,24 @@ bool HTMLInputElement::shouldUseInputMethod() const
 
 void HTMLInputElement::handleFocusEvent()
 {
-    InputElement::dispatchFocusEvent(this, this);
+    if (!isTextField())
+        return;
+    if (isPasswordField() && document()->frame())
+        document()->setUseSecureKeyboardEntryWhenActive(true);
 }
 
 void HTMLInputElement::handleBlurEvent()
 {
     m_inputType->handleBlurEvent();
-    InputElement::dispatchBlurEvent(this, this);
+
+    if (!isTextField())
+        return;
+    Frame* frame = document()->frame();
+    if (!frame)
+        return;
+    if (isPasswordField())
+        document()->setUseSecureKeyboardEntryWhenActive(false);
+    frame->editor()->textFieldDidEndEditing(this);
 }
 
 void HTMLInputElement::setType(const String& type)
@@ -466,14 +510,14 @@ void HTMLInputElement::updateType()
 
     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_value.isNull()) {
+        setAttribute(valueAttr, m_value);
+        m_value = String();
     }
     if (!didStoreValue && willStoreValue)
-        m_data.setValue(sanitizeValue(fastGetAttribute(valueAttr)));
+        m_value = sanitizeValue(fastGetAttribute(valueAttr));
     else
-        InputElement::updateValueIfNeeded(m_data, this);
+        updateValueIfNeeded();
 
     if (neededActivationCallback)
         unregisterForActivationCallbackIfNeeded();
@@ -502,7 +546,7 @@ void HTMLInputElement::updateType()
     checkedRadioButtons().addButton(this);
 
     setNeedsValidityCheck();
-    InputElement::notifyFormStateChanged(this);
+    notifyFormStateChanged();
 }
 
 const AtomicString& HTMLInputElement::formControlType() const
@@ -560,7 +604,7 @@ void HTMLInputElement::parseMappedAttribute(Attribute* attr)
 {
     if (attr->name() == nameAttr) {
         checkedRadioButtons().removeButton(this);
-        m_data.setName(attr->value());
+        m_name = attr->value();
         checkedRadioButtons().addButton(this);
         HTMLFormControlElementWithState::parseMappedAttribute(attr);
     } else if (attr->name() == autocompleteAttr) {
@@ -582,7 +626,7 @@ void HTMLInputElement::parseMappedAttribute(Attribute* attr)
         updateType();
     } else if (attr->name() == valueAttr) {
         // We only need to setChanged if the form is looking at the default value right now.
-        if (m_data.value().isNull())
+        if (m_value.isNull())
             setNeedsStyleRecalc();
         setFormControlValueMatchesRenderer(false);
         setNeedsValidityCheck();
@@ -595,12 +639,13 @@ void HTMLInputElement::parseMappedAttribute(Attribute* attr)
             setChecked(!attr->isNull());
             m_reflectsCheckedAttribute = true;
         }
-    } else if (attr->name() == maxlengthAttr) {
-        InputElement::parseMaxLengthAttribute(m_data, this, this, attr);
-        setNeedsValidityCheck();
-    } else if (attr->name() == sizeAttr)
-        InputElement::parseSizeAttribute(m_data, this, attr);
-    else if (attr->name() == altAttr)
+    } else if (attr->name() == maxlengthAttr)
+        parseMaxLengthAttribute(attr);
+    else if (attr->name() == sizeAttr) {
+        m_size = attr->isNull() ? defaultSize : attr->value().toInt();
+        if (renderer())
+            renderer()->setNeedsLayoutAndPrefWidthsRecalc();
+    } else if (attr->name() == altAttr)
         m_inputType->altAttributeChanged();
     else if (attr->name() == srcAttr)
         m_inputType->srcAttributeChanged();
@@ -808,14 +853,14 @@ void HTMLInputElement::setIndeterminate(bool newValue)
 
 int HTMLInputElement::size() const
 {
-    return m_data.size();
+    return m_size;
 }
 
 void HTMLInputElement::copyNonAttributeProperties(const Element* source)
 {
     const HTMLInputElement* sourceElement = static_cast<const HTMLInputElement*>(source);
 
-    m_data.setValue(sourceElement->m_data.value());
+    m_value = sourceElement->m_value;
     setChecked(sourceElement->m_isChecked);
     m_reflectsCheckedAttribute = sourceElement->m_reflectsCheckedAttribute;
     m_isIndeterminate = sourceElement->m_isIndeterminate;
@@ -829,7 +874,7 @@ String HTMLInputElement::value() const
     if (m_inputType->getTypeSpecificValue(value))
         return value;
 
-    value = m_data.value();
+    value = m_value;
     if (!value.isNull())
         return value;
 
@@ -857,7 +902,7 @@ void HTMLInputElement::setValueForUser(const String& value)
 
 const String& HTMLInputElement::suggestedValue() const
 {
-    return m_data.suggestedValue();
+    return m_suggestedValue;
 }
 
 void HTMLInputElement::setSuggestedValue(const String& value)
@@ -865,7 +910,7 @@ void HTMLInputElement::setSuggestedValue(const String& value)
     if (!m_inputType->canSetSuggestedValue())
         return;
     setFormControlValueMatchesRenderer(false);
-    m_data.setSuggestedValue(sanitizeValue(value));
+    m_suggestedValue = sanitizeValue(value);
     updatePlaceholderVisibility(false);
     if (renderer())
         renderer()->updateFromElement();
@@ -882,7 +927,7 @@ void HTMLInputElement::setValue(const String& value, bool sendChangeEvent)
         if (files())
             files()->clear();
         else {
-            m_data.setValue(sanitizeValue(value));
+            m_value = sanitizeValue(value);
             if (isTextField())
                 updatePlaceholderVisibility(false);
         }
@@ -893,12 +938,12 @@ void HTMLInputElement::setValue(const String& value, bool sendChangeEvent)
     setNeedsValidityCheck();
 
     if (isTextField()) {
-        unsigned max = m_data.value().length();
+        unsigned max = m_value.length();
         if (document()->focusedNode() == this)
-            InputElement::updateSelectionRange(this, this, max, max);
+            WebCore::setSelectionRange(this, max, max);
         else
             cacheSelection(max, max);
-        m_data.setSuggestedValue(String());
+        m_suggestedValue = String();
     }
     m_inputType->valueChanged();
 
@@ -914,7 +959,7 @@ void HTMLInputElement::setValue(const String& value, bool sendChangeEvent)
     if (isText() && (!focused() || !sendChangeEvent))
         setTextAsOfLastFormControlChangeEvent(value);
 
-    InputElement::notifyFormStateChanged(this);
+    notifyFormStateChanged();
 }
 
 double HTMLInputElement::valueAsDate() const
@@ -961,8 +1006,23 @@ void HTMLInputElement::setValueFromRenderer(const String& value)
     // File upload controls will always use setFileListFromRenderer.
     ASSERT(!isFileUpload());
 
-    m_data.setSuggestedValue(String());
-    InputElement::setValueFromRenderer(m_data, this, this, value);
+    m_suggestedValue = String();
+
+    // Renderer and our event handler are responsible for sanitizing values.
+    ASSERT(value == sanitizeValue(value) || sanitizeValue(value).isEmpty());
+
+    // Workaround for bug where trailing \n is included in the result of textContent.
+    // The assert macro above may also be simplified to: value == constrainValue(value)
+    // http://bugs.webkit.org/show_bug.cgi?id=9661
+    m_value = value == "\n" ? String("") : value;
+
+    setFormControlValueMatchesRenderer(true);
+
+    // Input event is fired by the Node::defaultEventHandler for editable controls.
+    if (!isTextField())
+        dispatchInputEvent();
+    notifyFormStateChanged();
+
     updatePlaceholderVisibility(false);
     setNeedsValidityCheck();
 
@@ -975,7 +1035,7 @@ void HTMLInputElement::setFileListFromRenderer(const Vector<String>& paths)
     m_inputType->setFileList(paths);
 
     setFormControlValueMatchesRenderer(true);
-    InputElement::notifyFormStateChanged(this);
+    notifyFormStateChanged();
     setNeedsValidityCheck();
 }
 
@@ -1105,7 +1165,7 @@ void HTMLInputElement::setDefaultValue(const String &value)
 
 void HTMLInputElement::setDefaultName(const AtomicString& name)
 {
-    m_data.setName(name);
+    m_name = name;
 }
 
 String HTMLInputElement::accept() const
@@ -1120,7 +1180,7 @@ String HTMLInputElement::alt() const
 
 int HTMLInputElement::maxLength() const
 {
-    return m_data.maxLength();
+    return m_maxLength;
 }
 
 void HTMLInputElement::setMaxLength(int maxLength, ExceptionCode& ec)
@@ -1219,8 +1279,8 @@ bool HTMLInputElement::isRequiredFormControl() const
 
 void HTMLInputElement::cacheSelection(int start, int end)
 {
-    m_data.setCachedSelectionStart(start);
-    m_data.setCachedSelectionEnd(end);
+    m_cachedSelectionStart = start;
+    m_cachedSelectionEnd = end;
 }
 
 void HTMLInputElement::addSearchResult()
@@ -1444,11 +1504,140 @@ void HTMLInputElement::stepUpFromRenderer(int n)
 
 #if ENABLE(WCSS)
 
+static inline const AtomicString& formatCodes()
+{
+    DEFINE_STATIC_LOCAL(AtomicString, codes, ("AaNnXxMm"));
+    return codes;
+}
+
+static unsigned cursorPositionToMaskIndex(const String& inputFormatMask, unsigned cursorPosition)
+{
+    UChar mask;
+    int index = -1;
+    do {
+        mask = inputFormatMask[++index];
+        if (mask == '\\')
+            ++index;
+        else if (mask == '*' || (isASCIIDigit(mask) && mask != '0')) {
+            index = inputFormatMask.length() - 1;
+            break;
+        }
+    } while (cursorPosition--);
+
+    return index;
+}
+
+bool HTMLInputElement::isConformToInputMask(const String& inputChars) const
+{
+    for (unsigned i = 0; i < inputChars.length(); ++i) {
+        if (!isConformToInputMask(inputChars[i], i))
+            return false;
+    }
+    return true;
+}
+
+bool HTMLInputElement::isConformToInputMask(UChar inChar, unsigned cursorPosition) const
+{
+    if (m_inputFormatMask.isEmpty() || m_inputFormatMask == "*M" || m_inputFormatMask == "*m")
+        return true;
+
+    if (cursorPosition >= m_maxInputCharsAllowed())
+        return false;
+
+    unsigned maskIndex = cursorPositionToMaskIndex(m_inputFormatMask, cursorPosition);
+    bool ok = true;
+    UChar mask = m_inputFormatMask[maskIndex];
+    // Match the inputed character with input mask
+    switch (mask) {
+    case 'A':
+        ok = !isASCIIDigit(inChar) && !isASCIILower(inChar) && isASCIIPrintable(inChar);
+        break;
+    case 'a':
+        ok = !isASCIIDigit(inChar) && !isASCIIUpper(inChar) && isASCIIPrintable(inChar);
+        break;
+    case 'N':
+        ok = isASCIIDigit(inChar);
+        break;
+    case 'n':
+        ok = !isASCIIAlpha(inChar) && isASCIIPrintable(inChar);
+        break;
+    case 'X':
+        ok = !isASCIILower(inChar) && isASCIIPrintable(inChar);
+        break;
+    case 'x':
+        ok = !isASCIIUpper(inChar) && isASCIIPrintable(inChar);
+        break;
+    case 'M':
+    case 'm':
+        ok = isASCIIPrintable(inChar);
+        break;
+    default:
+        ok = (mask == inChar);
+        break;
+    }
+
+    return ok;
+}
+
+String HTMLInputElement::validateInputMask(String& inputMask)
+{
+    inputMask.replace("\\\\", "\\");
+
+    bool isValid = true;
+    bool hasWildcard = false;
+    unsigned escapeCharCount = 0;
+    unsigned maskLength = inputMask.length();
+    UChar formatCode;
+    for (unsigned i = 0; i < maskLength; ++i) {
+        formatCode = inputMask[i];
+        if (formatCodes().find(formatCode) == -1) {
+            if (formatCode == '*' || (isASCIIDigit(formatCode) && formatCode != '0')) {
+                // Validate codes which ends with '*f' or 'nf'
+                formatCode = inputMask[++i];
+                if ((i + 1 != maskLength) || formatCodes().find(formatCode) == -1) {
+                    isValid = false;
+                    break;
+                }
+                hasWildcard = true;
+            } else if (formatCode == '\\') {
+                // skip over the next mask character
+                ++i;
+                ++escapeCharCount;
+            } else {
+                isValid = false;
+                break;
+            }
+        }
+    }
+
+    if (!isValid)
+        return String();
+    // calculate the number of characters allowed to be entered by input mask
+    unsigned allowedLength = maskLength;
+    if (escapeCharCount)
+        allowedLength -= escapeCharCount;
+
+    if (hasWildcard) {
+        formatCode = inputMask[maskLength - 2];
+        if (formatCode == '*')
+            allowedLength = m_maxInputCharsAllowed;
+        else {
+            unsigned leftLen = String(&formatCode).toInt();
+            allowedLength = leftLen + allowedLength - 2;
+        }
+    }
+
+    if (allowedLength < m_maxInputCharsAllowed)
+        m_maxInputCharsAllowed = allowedLength;
+
+    return inputMask;
+}
+
 void HTMLInputElement::setWapInputFormat(String& mask)
 {
-    String validateMask = validateInputMask(m_data, mask);
+    String validateMask = validateInputMask(mask);
     if (!validateMask.isEmpty())
-        m_data.setInputFormatMask(validateMask);
+        m_inputFormatMask = validateMask;
 }
 
 #endif
@@ -1560,9 +1749,34 @@ CheckedRadioButtons& HTMLInputElement::checkedRadioButtons() const
     return document()->checkedRadioButtons();
 }
 
-void HTMLInputElement::handleBeforeTextInsertedEvent(Event* event)
+void HTMLInputElement::notifyFormStateChanged()
+{
+    Frame* frame = document()->frame();
+    if (!frame)
+        return;
+
+    if (Page* page = frame->page())
+        page->chrome()->client()->formStateDidChange(this);
+}
+
+void HTMLInputElement::parseMaxLengthAttribute(Attribute* attribute)
+{
+    int maxLength = attribute->isNull() ? maximumLength : attribute->value().toInt();
+    if (maxLength <= 0 || maxLength > maximumLength)
+        maxLength = maximumLength;
+    int oldMaxLength = m_maxLength;
+    m_maxLength = maxLength;
+    if (oldMaxLength != maxLength)
+        updateValueIfNeeded();
+    setNeedsStyleRecalc();
+    setNeedsValidityCheck();
+}
+
+void HTMLInputElement::updateValueIfNeeded()
 {
-    InputElement::handleBeforeTextInsertedEvent(m_data, this, this, event);
+    String newValue = sanitizeValue(m_value);
+    if (newValue != m_value)
+        setValue(newValue);
 }
 
 } // namespace
index 5be7366..10ca20e 100644 (file)
@@ -25,7 +25,6 @@
 #define HTMLInputElement_h
 
 #include "HTMLFormControlElement.h"
-#include "InputElement.h"
 
 namespace WebCore {
 
@@ -35,14 +34,14 @@ class HTMLOptionElement;
 class InputType;
 class KURL;
 
-class HTMLInputElement : public HTMLTextFormControlElement, public InputElement {
+class HTMLInputElement : public HTMLTextFormControlElement {
 public:
     static PassRefPtr<HTMLInputElement> create(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser);
     virtual ~HTMLInputElement();
 
     DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitspeechchange);
 
-    virtual InputElement* toInputElement() { return this; }
+    virtual HTMLInputElement* toInputElement() { return this; }
 
     bool autoComplete() const;
 
@@ -78,18 +77,18 @@ public:
     void stepUp(ExceptionCode& ec) { stepUp(1, ec); }
     void stepDown(ExceptionCode& ec) { stepDown(1, ec); }
     // stepUp()/stepDown() for user-interaction.
-    virtual bool isSteppable() const;
+    bool isSteppable() const;
     void stepUpFromRenderer(int);
 
     bool isTextButton() const;
 
     virtual bool isRadioButton() const;
-    virtual bool isTextField() const;
-    virtual bool isSearchField() const;
-    virtual bool isInputTypeHidden() const;
-    virtual bool isPasswordField() const;
-    virtual bool isCheckbox() const;
-    virtual bool isRangeControl() const;
+    bool isTextField() const;
+    bool isSearchField() const;
+    bool isInputTypeHidden() const;
+    bool isPasswordField() const;
+    bool isCheckbox() const;
+    bool isRangeControl() 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
@@ -106,7 +105,7 @@ public:
     bool isURLField() const;
 
 #if ENABLE(INPUT_SPEECH)
-    virtual bool isSpeechEnabled() const;
+    bool isSpeechEnabled() const;
 #endif
 
     bool checked() const { return m_isChecked; }
@@ -116,18 +115,30 @@ public:
     bool indeterminate() const { return m_isIndeterminate; }
     void setIndeterminate(bool);
 
-    virtual int size() const;
+    // isChecked is used by the rendering tree/CSS while checked() is used by JS to determine checked state
+    virtual bool isChecked() const;
+    virtual bool isIndeterminate() const { return indeterminate(); }
+
+    int size() const;
 
     void setType(const String&);
 
-    virtual String value() const;
-    virtual void setValue(const String&, bool sendChangeEvent = false);
-    virtual void setValueForUser(const String&);
+    String value() const;
+    void setValue(const String&, bool sendChangeEvent = false);
+    void setValueForUser(const String&);
     // Checks if the specified string would be a valid value.
     // We should not call this for types with no string value such as CHECKBOX and RADIO.
     bool isValidValue(const String&) const;
 
-    virtual const String& suggestedValue() const;
+    String sanitizeValue(const String&) const;
+
+    // The value which is drawn by a renderer.
+    String visibleValue() const;
+    String convertFromVisibleValue(const String&) const;
+    // Returns true if the specified string can be set as the value of HTMLInputElement.
+    bool isAcceptableValue(const String&) const;
+
+    const String& suggestedValue() const;
     void setSuggestedValue(const String&);
 
     double valueAsDate() const;
@@ -141,11 +152,10 @@ public:
 
     String valueWithDefault() const;
 
-    virtual void setValueFromRenderer(const String&);
+    void setValueFromRenderer(const String&);
     void setFileListFromRenderer(const Vector<String>&);
 
     bool canHaveSelection() const;
-    virtual void select() { HTMLTextFormControlElement::select(); }
 
     virtual bool rendererIsNeeded(RenderStyle*);
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
@@ -178,13 +188,14 @@ public:
 
     bool multiple() const;
 
-    virtual bool isAutofilled() const { return m_isAutofilled; }
+    bool isAutofilled() const { return m_isAutofilled; }
     void setAutofilled(bool = true);
 
     FileList* files();
 
     void addSearchResult();
     void onSearch();
+    bool searchEventsShouldBeDispatched() const;
 
 #if ENABLE(DATALIST)
     HTMLElement* list() const;
@@ -198,11 +209,16 @@ public:
     // 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();
+#if ENABLE(WCSS)
+    bool isConformToInputMask(const String&) const;
+#endif
 
     bool lastChangeWasUserEdit() const;
-    
+    void cacheSelection(int start, int end);
+
+    static const int maximumLength;
+
 protected:
     HTMLInputElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser);
 
@@ -223,18 +239,12 @@ 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;
-    virtual bool isIndeterminate() const { return indeterminate(); }
-
     virtual bool isTextFormControl() const { return isTextField(); }
 
     virtual bool canTriggerImplicitSubmission() const { return isTextField(); }
 
     virtual const AtomicString& formControlType() const;
 
-    virtual bool searchEventsShouldBeDispatched() const;
-
     virtual bool saveFormControlState(String& value) const;
     virtual void restoreFormControlState(const String&);
 
@@ -261,12 +271,6 @@ private:
 
     virtual bool isURLAttribute(Attribute*) const;
 
-    virtual void cacheSelection(int start, int end);
-
-    virtual String visibleValue() const;
-    virtual String convertFromVisibleValue(const String&) const;
-    virtual bool isAcceptableValue(const String&) const;
-    virtual String sanitizeValue(const String&) const;
     virtual bool hasUnacceptableValue() const;
 
     virtual bool isInRange() const;
@@ -280,7 +284,7 @@ private:
     void registerForActivationCallbackIfNeeded();
     void unregisterForActivationCallbackIfNeeded();
 
-    virtual bool supportsMaxLength() const { return isTextType(); }
+    bool supportsMaxLength() const { return isTextType(); }
     bool isTextType() const;
 
     virtual bool supportsPlaceholder() const;
@@ -288,8 +292,8 @@ private:
     virtual bool isEmptySuggestedValue() const { return suggestedValue().isEmpty(); }
     virtual void handleFocusEvent();
     virtual void handleBlurEvent();
-    virtual int cachedSelectionStart() const { return m_data.cachedSelectionStart(); }
-    virtual int cachedSelectionEnd() const { return m_data.cachedSelectionEnd(); }
+    virtual int cachedSelectionStart() const { return m_cachedSelectionStart; }
+    virtual int cachedSelectionEnd() const { return m_cachedSelectionEnd; }
 
     virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); }
     virtual bool isRequiredFormControl() const;
@@ -303,12 +307,25 @@ private:
 #if ENABLE(DATALIST)
     HTMLDataListElement* dataList() const;
 #endif
-
+    void notifyFormStateChanged();
+    void parseMaxLengthAttribute(Attribute*);
+    void updateValueIfNeeded();
 #if ENABLE(WCSS)
-    virtual InputElementData data() const { return m_data; }
+    bool isConformToInputMask(UChar, unsigned) const;
+    String validateInputMask(String&);
 #endif
 
-    InputElementData m_data;
+    AtomicString m_name;
+    String m_value;
+    String m_suggestedValue;
+    int m_size;
+    int m_maxLength;
+    int m_cachedSelectionStart;
+    int m_cachedSelectionEnd;
+#if ENABLE(WCSS)
+    String m_inputFormatMask;
+    unsigned m_maxInputCharsAllowed;
+#endif
     short m_maxResults;
     bool m_isChecked : 1;
     bool m_reflectsCheckedAttribute : 1;
index e0463ff..a299b18 100644 (file)
@@ -39,7 +39,6 @@
 #include "FormDataList.h"
 #include "Frame.h"
 #include "HTMLNames.h"
-#include "InputElement.h"
 #include "Page.h"
 #include "RenderStyle.h"
 #include "RenderTextControlMultiLine.h"
index c882cd5..6b359ef 100644 (file)
@@ -326,9 +326,8 @@ void InputType::handleKeyupEvent(KeyboardEvent*)
 {
 }
 
-void InputType::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event)
+void InputType::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*)
 {
-    element()->handleBeforeTextInsertedEvent(event);
 }
 
 void InputType::handleWheelEvent(WheelEvent*)
index ffea2f4..6563049 100644 (file)
 #include "config.h"
 #include "TextFieldInputType.h"
 
+#include "BeforeTextInsertedEvent.h"
 #include "Frame.h"
 #include "HTMLInputElement.h"
 #include "KeyboardEvent.h"
 #include "RenderTextControlSingleLine.h"
 #include "TextEvent.h"
+#include "TextIterator.h"
 #include "WheelEvent.h"
 #include <wtf/text/WTFString.h>
 
@@ -119,9 +121,72 @@ bool TextFieldInputType::shouldUseInputMethod() const
     return true;
 }
 
+static String replaceEOLAndLimitLength(const String& proposedValue, int maxLength)
+{
+    String string = proposedValue;
+    string.replace("\r\n", " ");
+    string.replace('\r', ' ');
+    string.replace('\n', ' ');
+
+    unsigned newLength = numCharactersInGraphemeClusters(string, maxLength);
+    for (unsigned i = 0; i < newLength; ++i) {
+        const UChar current = string[i];
+        if (current < ' ' && current != '\t') {
+            newLength = i;
+            break;
+        }
+    }
+    return string.left(newLength);
+}
+
 String TextFieldInputType::sanitizeValue(const String& proposedValue)
 {
-    return InputElement::sanitizeValueForTextField(element(), proposedValue);
+#if ENABLE(WCSS)
+    if (!element()->isConformToInputMask(proposedValue)) {
+        if (isConformToInputMask(element()->value()))
+            return element->value();
+        return String();
+    }
+#endif
+    return replaceEOLAndLimitLength(proposedValue, HTMLInputElement::maximumLength);
+}
+
+void TextFieldInputType::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event)
+{
+    // Make sure that the text to be inserted will not violate the maxLength.
+
+    // We use RenderTextControlSingleLine::text() instead of InputElement::value()
+    // because they can be mismatched by sanitizeValue() in
+    // RenderTextControlSingleLine::subtreeHasChanged() in some cases.
+    unsigned oldLength = numGraphemeClusters(toRenderTextControlSingleLine(element()->renderer())->text());
+
+    // selectionLength represents the selection length of this text field to be
+    // removed by this insertion.
+    // If the text field has no focus, we don't need to take account of the
+    // selection length. The selection is the source of text drag-and-drop in
+    // that case, and nothing in the text field will be removed.
+    unsigned selectionLength = element()->focused() ? numGraphemeClusters(plainText(element()->document()->frame()->selection()->selection().toNormalizedRange().get())) : 0;
+    ASSERT(oldLength >= selectionLength);
+
+    // Selected characters will be removed by the next text event.
+    unsigned baseLength = oldLength - selectionLength;
+    unsigned maxLength = static_cast<unsigned>(isTextType() ? element()->maxLength() : HTMLInputElement::maximumLength); // maxLength can never be negative.
+    unsigned appendableLength = maxLength > baseLength ? maxLength - baseLength : 0;
+
+    // Truncate the inserted text to avoid violating the maxLength and other constraints.
+#if ENABLE(WCSS)
+    RefPtr<Range> range = element()->document()->frame()->selection()->selection().toNormalizedRange();
+    String candidateString = toRenderTextControlSingleLine(element()->renderer())->text();
+    if (selectionLength)
+        candidateString.replace(range->startOffset(), range->endOffset(), event->text());
+    else
+        candidateString.insert(event->text(), range->startOffset());
+    if (!element()->isConformToInputMask(candidateString)) {
+        event->setText("");
+        return;
+    }
+#endif
+    event->setText(replaceEOLAndLimitLength(event->text(), appendableLength));
 }
 
 bool TextFieldInputType::shouldRespectListAttribute()
index 86ad0ef..f585abb 100644 (file)
@@ -48,11 +48,12 @@ protected:
 private:
     virtual bool isTextField() const;
     virtual bool valueMissing(const String&) const;
+    virtual void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*);
     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 String sanitizeValue(const String&);
     virtual bool shouldRespectListAttribute();
 };
 
index 2adb82a..8da94ba 100644 (file)
@@ -34,7 +34,6 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HitTestResult.h"
-#include "InputElement.h"
 #include "LocalizedStrings.h"
 #include "MouseEvent.h"
 #include "PlatformKeyboardEvent.h"
@@ -75,6 +74,8 @@ RenderTextControlSingleLine::RenderTextControlSingleLine(Node* node, bool placeh
     , m_searchEventTimer(this, &RenderTextControlSingleLine::searchEventTimerFired)
     , m_searchPopup(0)
 {
+    ASSERT(node->isHTMLElement());
+    ASSERT(node->toInputElement());
 }
 
 RenderTextControlSingleLine::~RenderTextControlSingleLine()
@@ -106,8 +107,7 @@ RenderStyle* RenderTextControlSingleLine::textBaseStyle() const
 
 void RenderTextControlSingleLine::addSearchResult()
 {
-    ASSERT(node()->isHTMLElement());
-    HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
+    HTMLInputElement* input = inputElement();
     if (input->maxResults() <= 0)
         return;
 
@@ -138,13 +138,11 @@ void RenderTextControlSingleLine::addSearchResult()
 
 void RenderTextControlSingleLine::stopSearchEventTimer()
 {
-    ASSERT(node()->isHTMLElement());
     m_searchEventTimer.stop();
 }
 
 void RenderTextControlSingleLine::showPopup()
 {
-    ASSERT(node()->isHTMLElement());
     if (m_searchPopupIsVisible)
         return;
 
@@ -160,7 +158,7 @@ void RenderTextControlSingleLine::showPopup()
     m_searchPopup->loadRecentSearches(name, m_recentSearches);
 
     // Trim the recent searches list if the maximum size has changed since we last saved.
-    HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
+    HTMLInputElement* input = inputElement();
     if (static_cast<int>(m_recentSearches.size()) > input->maxResults()) {
         do {
             m_recentSearches.removeLast();
@@ -174,7 +172,6 @@ void RenderTextControlSingleLine::showPopup()
 
 void RenderTextControlSingleLine::hidePopup()
 {
-    ASSERT(node()->isHTMLElement());
     if (m_searchPopup)
         m_searchPopup->popupMenu()->hide();
 }
@@ -188,18 +185,16 @@ void RenderTextControlSingleLine::subtreeHasChanged()
     bool wasChanged = element->wasChangedSinceLastFormControlChangeEvent();
     element->setChangedSinceLastFormControlChangeEvent(true);
 
-    InputElement* input = inputElement();
+    HTMLInputElement* input = inputElement();
     // We don't need to call sanitizeUserInputValue() function here because
-    // InputElement::handleBeforeTextInsertedEvent() has already called
+    // HTMLInputElement::handleBeforeTextInsertedEvent() has already called
     // sanitizeUserInputValue().
     // sanitizeValue() is needed because IME input doesn't dispatch BeforeTextInsertedEvent.
     String value = text();
     if (input->isAcceptableValue(value))
         input->setValueFromRenderer(input->sanitizeValue(input->convertFromVisibleValue(value)));
-    if (node()->isHTMLElement()) {
-        // Recalc for :invalid and hasUnacceptableValue() change.
-        static_cast<HTMLInputElement*>(input)->setNeedsStyleRecalc();
-    }
+    // Recalc for :invalid and hasUnacceptableValue() change.
+    input->setNeedsStyleRecalc();
 
     if (m_cancelButton)
         updateCancelButtonVisibility();
@@ -710,7 +705,7 @@ void RenderTextControlSingleLine::updateFromElement()
             // For HTMLInputElement, update the renderer value if the formControlValueMatchesRenderer()
             // flag is false. It protects an unacceptable renderer value from
             // being overwritten with the DOM value.
-            if (!static_cast<HTMLInputElement*>(node())->formControlValueMatchesRenderer())
+            if (!inputElement()->formControlValueMatchesRenderer())
                 setInnerTextValue(inputElement()->visibleValue());
         }
     }
@@ -755,8 +750,6 @@ PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerTextStyle(const
 
 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerBlockStyle(const RenderStyle* startStyle) const
 {
-    ASSERT(node()->isHTMLElement());
-
     RefPtr<RenderStyle> innerBlockStyle = RenderStyle::create();
     innerBlockStyle->inheritFrom(startStyle);
 
@@ -771,8 +764,7 @@ PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerBlockStyle(const
 
 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createResultsButtonStyle(const RenderStyle* startStyle) const
 {
-    ASSERT(node()->isHTMLElement());
-    HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
+    HTMLInputElement* input = inputElement();
 
     RefPtr<RenderStyle> resultsBlockStyle;
     if (input->maxResults() < 0)
@@ -793,7 +785,6 @@ PassRefPtr<RenderStyle> RenderTextControlSingleLine::createResultsButtonStyle(co
 
 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createCancelButtonStyle(const RenderStyle* startStyle) const
 {
-    ASSERT(node()->isHTMLElement());
     RefPtr<RenderStyle> cancelBlockStyle;
     
     if (RefPtr<RenderStyle> pseudoStyle = getCachedPseudoStyle(SEARCH_CANCEL_BUTTON))
@@ -811,7 +802,6 @@ PassRefPtr<RenderStyle> RenderTextControlSingleLine::createCancelButtonStyle(con
 
 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerSpinButtonStyle() const
 {
-    ASSERT(node()->isHTMLElement());
     RefPtr<RenderStyle> buttonStyle = getCachedPseudoStyle(INNER_SPIN_BUTTON);
     if (!buttonStyle)
         buttonStyle = RenderStyle::create();
@@ -821,7 +811,6 @@ PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerSpinButtonStyle(
 
 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createOuterSpinButtonStyle() const
 {
-    ASSERT(node()->isHTMLElement());
     RefPtr<RenderStyle> buttonStyle = getCachedPseudoStyle(OUTER_SPIN_BUTTON);
     if (!buttonStyle)
         buttonStyle = RenderStyle::create();
@@ -832,7 +821,6 @@ PassRefPtr<RenderStyle> RenderTextControlSingleLine::createOuterSpinButtonStyle(
 #if ENABLE(INPUT_SPEECH)
 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createSpeechButtonStyle() const
 {
-    ASSERT(node()->isHTMLElement());
     RefPtr<RenderStyle> buttonStyle = getCachedPseudoStyle(INPUT_SPEECH_BUTTON);
     if (!buttonStyle)
         buttonStyle = RenderStyle::create();
@@ -858,9 +846,7 @@ void RenderTextControlSingleLine::updateCancelButtonVisibility() const
 
 EVisibility RenderTextControlSingleLine::visibilityForCancelButton() const
 {
-    ASSERT(node()->isHTMLElement());
-    HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
-    return input->value().isEmpty() ? HIDDEN : VISIBLE;
+    return inputElement()->value().isEmpty() ? HIDDEN : VISIBLE;
 }
 
 const AtomicString& RenderTextControlSingleLine::autosaveName() const
@@ -870,13 +856,12 @@ const AtomicString& RenderTextControlSingleLine::autosaveName() const
 
 void RenderTextControlSingleLine::startSearchEventTimer()
 {
-    ASSERT(node()->isHTMLElement());
     unsigned length = text().length();
 
     // If there's no text, fire the event right away.
     if (!length) {
         stopSearchEventTimer();
-        static_cast<HTMLInputElement*>(node())->onSearch();
+        inputElement()->onSearch();
         return;
     }
 
@@ -887,16 +872,14 @@ void RenderTextControlSingleLine::startSearchEventTimer()
 
 void RenderTextControlSingleLine::searchEventTimerFired(Timer<RenderTextControlSingleLine>*)
 {
-    ASSERT(node()->isHTMLElement());
-    static_cast<HTMLInputElement*>(node())->onSearch();
+    inputElement()->onSearch();
 }
 
 // PopupMenuClient methods
 void RenderTextControlSingleLine::valueChanged(unsigned listIndex, bool fireEvents)
 {
-    ASSERT(node()->isHTMLElement());
     ASSERT(static_cast<int>(listIndex) < listSize());
-    HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
+    HTMLInputElement* input = inputElement();
     if (static_cast<int>(listIndex) == (listSize() - 1)) {
         if (fireEvents) {
             m_recentSearches.clear();
@@ -1030,8 +1013,7 @@ bool RenderTextControlSingleLine::itemIsSelected(unsigned) const
 
 void RenderTextControlSingleLine::setTextFromItem(unsigned listIndex)
 {
-    ASSERT(node()->isHTMLElement());
-    static_cast<HTMLInputElement*>(node())->setValue(itemText(listIndex));
+    inputElement()->setValue(itemText(listIndex));
 }
 
 FontSelector* RenderTextControlSingleLine::fontSelector() const
@@ -1118,7 +1100,7 @@ PassRefPtr<Scrollbar> RenderTextControlSingleLine::createScrollbar(ScrollableAre
     return widget.release();
 }
 
-InputElement* RenderTextControlSingleLine::inputElement() const
+HTMLInputElement* RenderTextControlSingleLine::inputElement() const
 {
     return node()->toInputElement();
 }
index 18e5fc8..f43aa1b 100644 (file)
@@ -30,7 +30,7 @@
 
 namespace WebCore {
 
-class InputElement;
+class HTMLInputElement;
 class InputFieldSpeechButtonElement;
 class SearchFieldCancelButtonElement;
 class SearchFieldResultsButtonElement;
@@ -142,7 +142,7 @@ private:
     virtual HostWindow* hostWindow() const;
     virtual PassRefPtr<Scrollbar> createScrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize);
 
-    InputElement* inputElement() const;
+    HTMLInputElement* inputElement() const;
 
     virtual int textBlockInsetLeft() const;
     virtual int textBlockInsetRight() const;
index c2c09ed..4694054 100644 (file)
@@ -751,7 +751,7 @@ bool RenderTheme::isChecked(const RenderObject* o) const
     if (!o->node())
         return false;
 
-    InputElement* inputElement = o->node()->toInputElement();
+    HTMLInputElement* inputElement = o->node()->toInputElement();
     if (!inputElement)
         return false;
 
@@ -763,7 +763,7 @@ bool RenderTheme::isIndeterminate(const RenderObject* o) const
     if (!o->node())
         return false;
 
-    InputElement* inputElement = o->node()->toInputElement();
+    HTMLInputElement* inputElement = o->node()->toInputElement();
     if (!inputElement)
         return false;
 
@@ -965,7 +965,7 @@ void RenderTheme::adjustProgressBarStyle(CSSStyleSelector*, RenderStyle*, Elemen
 }
 #endif
 
-bool RenderTheme::shouldHaveSpinButton(InputElement* inputElement) const
+bool RenderTheme::shouldHaveSpinButton(HTMLInputElement* inputElement) const
 {
     return inputElement->isSteppable() && !inputElement->isRangeControl();
 }
index e13e1ba..157ba3a 100644 (file)
@@ -36,6 +36,7 @@
 namespace WebCore {
 
 class Element;
+class HTMLInputElement;
 class PopupMenu;
 class RenderMenuList;
 #if ENABLE(METER_TAG)
@@ -201,7 +202,7 @@ public:
 #endif
     
     virtual bool shouldShowPlaceholderWhenFocused() const { return false; }
-    virtual bool shouldHaveSpinButton(InputElement*) const;
+    virtual bool shouldHaveSpinButton(HTMLInputElement*) const;
 
 protected:
     // The platform selection color.
index 2fc1059..e46cb1f 100644 (file)
@@ -1,3 +1,16 @@
+2011-05-06  Kent Tamura  <tkent@chromium.org>
+
+        Reviewed by Ryosuke Niwa.
+
+        Eliminate WebCore/dom/InputElement.{cpp,h}
+        https://bugs.webkit.org/show_bug.cgi?id=60262
+
+        * src/WebInputElement.cpp:
+        (WebKit::WebInputElement::defaultMaxLength):
+          Replace InputElement::s_maximumLength with HTMLInputElement::maximumLength.
+        (WebKit::toWebInputElement):
+          Follow the return type change of Node::toInputElement().
+
 2011-05-06  Justin Schuh  <jschuh@chromium.org>
 
         Reviewed by Adam Barth.
index 3448bb6..8a21ed9 100644 (file)
@@ -152,7 +152,7 @@ bool WebInputElement::isChecked() const
 
 int WebInputElement::defaultMaxLength()
 {
-    return HTMLInputElement::s_maximumLength;
+    return HTMLInputElement::maximumLength;
 }
 
 WebInputElement::WebInputElement(const PassRefPtr<HTMLInputElement>& elem)
@@ -173,12 +173,10 @@ WebInputElement::operator PassRefPtr<HTMLInputElement>() const
 
 WebInputElement* toWebInputElement(WebElement* webElement)
 {
-    InputElement* inputElement = webElement->unwrap<Element>()->toInputElement();
+    HTMLInputElement* inputElement = webElement->unwrap<Element>()->toInputElement();
     if (!inputElement)
         return 0;
 
-    ASSERT(webElement->unwrap<Element>()->isHTMLElement());
-
     return static_cast<WebInputElement*>(webElement);
 }
 
index e085e8e..153f2f3 100644 (file)
@@ -1,3 +1,15 @@
+2011-05-06  Kent Tamura  <tkent@chromium.org>
+
+        Reviewed by Ryosuke Niwa.
+
+        Eliminate WebCore/dom/InputElement.{cpp,h}
+        https://bugs.webkit.org/show_bug.cgi?id=60262
+
+        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
+        (DumpRenderTreeSupportGtk::setAutofilled):
+          Follow the return type change of Node::toInputElement().
+        (DumpRenderTreeSupportGtk::setValueForUser): ditto.
+
 2011-05-06  Martin Robinson  <mrobinson@igalia.com>
 
         Reviewed by Xan Lopez.
index 530df66..2b154a2 100644 (file)
@@ -36,7 +36,6 @@
 #include "GCController.h"
 #include "GraphicsContext.h"
 #include "HTMLInputElement.h"
-#include "InputElement.h"
 #include "JSDOMWindow.h"
 #include "JSDocument.h"
 #include "JSElement.h"
@@ -760,11 +759,11 @@ void DumpRenderTreeSupportGtk::setAutofilled(JSContextRef context, JSValueRef no
     Element* element = toElement(toJS(exec, nodeObject));
     if (!element)
         return;
-    InputElement* inputElement = element->toInputElement();
+    HTMLInputElement* inputElement = element->toInputElement();
     if (!inputElement)
         return;
 
-    static_cast<HTMLInputElement*>(inputElement)->setAutofilled(autofilled);
+    inputElement->setAutofilled(autofilled);
 }
 
 void DumpRenderTreeSupportGtk::setValueForUser(JSContextRef context, JSValueRef nodeObject, JSStringRef value)
@@ -773,7 +772,7 @@ void DumpRenderTreeSupportGtk::setValueForUser(JSContextRef context, JSValueRef
     Element* element = toElement(toJS(exec, nodeObject));
     if (!element)
         return;
-    InputElement* inputElement = element->toInputElement();
+    HTMLInputElement* inputElement = element->toInputElement();
     if (!inputElement)
         return;
 
index b459cb2..975c44a 100644 (file)
@@ -1446,7 +1446,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
                         return QVariant(inputElement->maxLength());
                     }
                 }
-                return QVariant(InputElement::s_maximumLength);
+                return QVariant(HTMLInputElement::maximumLength);
             }
             return QVariant(0);
         }
index 9fb73e9..024ac23 100644 (file)
@@ -1,3 +1,17 @@
+2011-05-06  Kent Tamura  <tkent@chromium.org>
+
+        Reviewed by Ryosuke Niwa.
+
+        Eliminate WebCore/dom/InputElement.{cpp,h}
+        https://bugs.webkit.org/show_bug.cgi?id=60262
+
+        * Api/qwebpage.cpp:
+        (QWebPage::inputMethodQuery):
+          Replace InputElement::s_maximumLength with HTMLInputElement::maximumLength.
+        * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
+        (DumpRenderTreeSupportQt::setAutofilled):
+          Follow the return type change of Node::toInputElement().
+
 2011-05-04  Philippe Normand  <pnormand@igalia.com>
 
         Reviewed by Dimitri Glazkov.
index 7300b7b..682b878 100644 (file)
@@ -53,7 +53,6 @@
 #include "GeolocationPosition.h"
 #include "HistoryItem.h"
 #include "HTMLInputElement.h"
-#include "InputElement.h"
 #include "InspectorController.h"
 #include "NodeList.h"
 #include "NotificationPresenterClientQt.h"
@@ -243,11 +242,11 @@ void DumpRenderTreeSupportQt::setAutofilled(const QWebElement& element, bool isA
     WebCore::Element* webElement = element.m_element;
     if (!webElement)
         return;
-    InputElement* inputElement = webElement->toInputElement();
+    HTMLInputElement* inputElement = webElement->toInputElement();
     if (!inputElement)
         return;
 
-    static_cast<HTMLInputElement*>(inputElement)->setAutofilled(isAutofilled);
+    inputElement->setAutofilled(isAutofilled);
 }
 
 void DumpRenderTreeSupportQt::setJavaScriptProfilingEnabled(QWebFrame* frame, bool enabled)