Unreviewed, rolling out r120432.
authoryosin@chromium.org <yosin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Jun 2012 02:06:40 +0000 (02:06 +0000)
committeryosin@chromium.org <yosin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Jun 2012 02:06:40 +0000 (02:06 +0000)
http://trac.webkit.org/changeset/120432
https://bugs.webkit.org/show_bug.cgi?id=88980

Failed to copy merge history to RenderSerachField.{cpp,h}

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::subtreeHasChanged):
(WebCore::HTMLInputElement::searchEventsShouldBeDispatched):
(WebCore):
(WebCore::HTMLInputElement::addSearchResult):
* html/HTMLInputElement.h:
(HTMLInputElement):
* html/InputType.cpp:
* html/InputType.h:
(InputType):
* html/SearchInputType.cpp:
* html/SearchInputType.h:
(SearchInputType):
* html/shadow/TextControlInnerElements.cpp:
(WebCore::SearchFieldResultsButtonElement::defaultEventHandler):
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* rendering/RenderSearchField.cpp:
(WebCore::RenderTextControlInnerBlock::positionForPoint):
(WebCore):
(WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
(WebCore::RenderTextControlSingleLine::~RenderTextControlSingleLine):
(WebCore::RenderTextControlSingleLine::containerElement):
(WebCore::RenderTextControlSingleLine::innerBlockElement):
(WebCore::RenderTextControlSingleLine::innerSpinButtonElement):
(WebCore::RenderTextControlSingleLine::resultsButtonElement):
(WebCore::RenderTextControlSingleLine::cancelButtonElement):
(WebCore::RenderTextControlSingleLine::textBaseStyle):
(WebCore::RenderTextControlSingleLine::addSearchResult):
(WebCore::RenderTextControlSingleLine::showPopup):
(WebCore::RenderTextControlSingleLine::hidePopup):
(WebCore::RenderTextControlSingleLine::paint):
(WebCore::RenderTextControlSingleLine::layout):
(WebCore::RenderTextControlSingleLine::nodeAtPoint):
(WebCore::RenderTextControlSingleLine::styleDidChange):
(WebCore::RenderTextControlSingleLine::capsLockStateMayHaveChanged):
(WebCore::RenderTextControlSingleLine::hasControlClip):
(WebCore::RenderTextControlSingleLine::controlClipRect):
(WebCore::RenderTextControlSingleLine::getAvgCharWidth):
(WebCore::RenderTextControlSingleLine::preferredContentWidth):
(WebCore::RenderTextControlSingleLine::computeControlHeight):
(WebCore::RenderTextControlSingleLine::updateFromElement):
(WebCore::RenderTextControlSingleLine::createInnerTextStyle):
(WebCore::RenderTextControlSingleLine::createInnerBlockStyle):
(WebCore::RenderTextControlSingleLine::updateCancelButtonVisibility):
(WebCore::RenderTextControlSingleLine::visibilityForCancelButton):
(WebCore::RenderTextControlSingleLine::textShouldBeTruncated):
(WebCore::RenderTextControlSingleLine::autosaveName):
(WebCore::RenderTextControlSingleLine::valueChanged):
(WebCore::RenderTextControlSingleLine::itemText):
(WebCore::RenderTextControlSingleLine::itemLabel):
(WebCore::RenderTextControlSingleLine::itemIcon):
(WebCore::RenderTextControlSingleLine::itemIsEnabled):
(WebCore::RenderTextControlSingleLine::itemStyle):
(WebCore::RenderTextControlSingleLine::menuStyle):
(WebCore::RenderTextControlSingleLine::clientInsetLeft):
(WebCore::RenderTextControlSingleLine::clientInsetRight):
(WebCore::RenderTextControlSingleLine::clientPaddingLeft):
(WebCore::RenderTextControlSingleLine::clientPaddingRight):
(WebCore::RenderTextControlSingleLine::listSize):
(WebCore::RenderTextControlSingleLine::selectedIndex):
(WebCore::RenderTextControlSingleLine::popupDidHide):
(WebCore::RenderTextControlSingleLine::itemIsSeparator):
(WebCore::RenderTextControlSingleLine::itemIsLabel):
(WebCore::RenderTextControlSingleLine::itemIsSelected):
(WebCore::RenderTextControlSingleLine::setTextFromItem):
(WebCore::RenderTextControlSingleLine::fontSelector):
(WebCore::RenderTextControlSingleLine::hostWindow):
(WebCore::RenderTextControlSingleLine::autoscroll):
(WebCore::RenderTextControlSingleLine::scrollWidth):
(WebCore::RenderTextControlSingleLine::scrollHeight):
(WebCore::RenderTextControlSingleLine::scrollLeft):
(WebCore::RenderTextControlSingleLine::scrollTop):
(WebCore::RenderTextControlSingleLine::setScrollLeft):
(WebCore::RenderTextControlSingleLine::setScrollTop):
(WebCore::RenderTextControlSingleLine::scroll):
(WebCore::RenderTextControlSingleLine::logicalScroll):
(WebCore::RenderTextControlSingleLine::createScrollbar):
(WebCore::RenderTextControlSingleLine::inputElement):
* rendering/RenderSearchField.h:
(RenderTextControlSingleLine):
(WebCore::RenderTextControlSingleLine::isTextField):
(WebCore::toRenderTextControlSingleLine):
(WebCore):
(RenderTextControlInnerBlock):
(WebCore::RenderTextControlInnerBlock::RenderTextControlInnerBlock):
(WebCore::RenderTextControlInnerBlock::hasLineIfEmpty):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
(WebCore::RenderTextControlSingleLine::~RenderTextControlSingleLine):
(WebCore):
(WebCore::RenderTextControlSingleLine::containerElement):
(WebCore::RenderTextControlSingleLine::innerBlockElement):
(WebCore::RenderTextControlSingleLine::resultsButtonElement):
(WebCore::RenderTextControlSingleLine::cancelButtonElement):
(WebCore::RenderTextControlSingleLine::addSearchResult):
(WebCore::RenderTextControlSingleLine::showPopup):
(WebCore::RenderTextControlSingleLine::hidePopup):
(WebCore::RenderTextControlSingleLine::layout):
(WebCore::RenderTextControlSingleLine::computeControlHeight):
(WebCore::RenderTextControlSingleLine::updateFromElement):
(WebCore::RenderTextControlSingleLine::updateCancelButtonVisibility):
(WebCore::RenderTextControlSingleLine::visibilityForCancelButton):
(WebCore::RenderTextControlSingleLine::autosaveName):
(WebCore::RenderTextControlSingleLine::valueChanged):
(WebCore::RenderTextControlSingleLine::itemText):
(WebCore::RenderTextControlSingleLine::itemLabel):
(WebCore::RenderTextControlSingleLine::itemIcon):
(WebCore::RenderTextControlSingleLine::itemIsEnabled):
(WebCore::RenderTextControlSingleLine::itemStyle):
(WebCore::RenderTextControlSingleLine::menuStyle):
(WebCore::RenderTextControlSingleLine::clientInsetLeft):
(WebCore::RenderTextControlSingleLine::clientInsetRight):
(WebCore::RenderTextControlSingleLine::clientPaddingLeft):
(WebCore::RenderTextControlSingleLine::clientPaddingRight):
(WebCore::RenderTextControlSingleLine::listSize):
(WebCore::RenderTextControlSingleLine::selectedIndex):
(WebCore::RenderTextControlSingleLine::popupDidHide):
(WebCore::RenderTextControlSingleLine::itemIsSeparator):
(WebCore::RenderTextControlSingleLine::itemIsLabel):
(WebCore::RenderTextControlSingleLine::itemIsSelected):
(WebCore::RenderTextControlSingleLine::setTextFromItem):
(WebCore::RenderTextControlSingleLine::fontSelector):
(WebCore::RenderTextControlSingleLine::hostWindow):
(WebCore::RenderTextControlSingleLine::createScrollbar):
* rendering/RenderTextControlSingleLine.h:
(WebCore):
(RenderTextControlSingleLine):
(WebCore::RenderTextControlSingleLine::popupIsVisible):
* rendering/RenderingAllInOne.cpp:

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

20 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/html/SearchInputType.cpp
Source/WebCore/html/SearchInputType.h
Source/WebCore/html/shadow/TextControlInnerElements.cpp
Source/WebCore/loader/FormSubmission.cpp
Source/WebCore/rendering/RenderSearchField.cpp
Source/WebCore/rendering/RenderSearchField.h
Source/WebCore/rendering/RenderTextControlSingleLine.cpp
Source/WebCore/rendering/RenderTextControlSingleLine.h
Source/WebCore/rendering/RenderingAllInOne.cpp

index 9ad85bb..e273c0f 100644 (file)
@@ -1387,7 +1387,6 @@ SET(WebCore_SOURCES
     rendering/RenderScrollbar.cpp
     rendering/RenderScrollbarPart.cpp
     rendering/RenderScrollbarTheme.cpp
-    rendering/RenderSearchField.cpp
     rendering/RenderSlider.cpp
     rendering/RenderTable.cpp
     rendering/RenderTableCaption.cpp
index cb932cf..c4a8da7 100644 (file)
@@ -1,3 +1,148 @@
+2012-06-17  Yoshifumi Inoue  <yosin@chromium.org>
+
+        Unreviewed, rolling out r120432.
+        http://trac.webkit.org/changeset/120432
+        https://bugs.webkit.org/show_bug.cgi?id=88980
+
+        Failed to copy merge history to RenderSerachField.{cpp,h}
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::subtreeHasChanged):
+        (WebCore::HTMLInputElement::searchEventsShouldBeDispatched):
+        (WebCore):
+        (WebCore::HTMLInputElement::addSearchResult):
+        * html/HTMLInputElement.h:
+        (HTMLInputElement):
+        * html/InputType.cpp:
+        * html/InputType.h:
+        (InputType):
+        * html/SearchInputType.cpp:
+        * html/SearchInputType.h:
+        (SearchInputType):
+        * html/shadow/TextControlInnerElements.cpp:
+        (WebCore::SearchFieldResultsButtonElement::defaultEventHandler):
+        * loader/FormSubmission.cpp:
+        (WebCore::FormSubmission::create):
+        * rendering/RenderSearchField.cpp:
+        (WebCore::RenderTextControlInnerBlock::positionForPoint):
+        (WebCore):
+        (WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
+        (WebCore::RenderTextControlSingleLine::~RenderTextControlSingleLine):
+        (WebCore::RenderTextControlSingleLine::containerElement):
+        (WebCore::RenderTextControlSingleLine::innerBlockElement):
+        (WebCore::RenderTextControlSingleLine::innerSpinButtonElement):
+        (WebCore::RenderTextControlSingleLine::resultsButtonElement):
+        (WebCore::RenderTextControlSingleLine::cancelButtonElement):
+        (WebCore::RenderTextControlSingleLine::textBaseStyle):
+        (WebCore::RenderTextControlSingleLine::addSearchResult):
+        (WebCore::RenderTextControlSingleLine::showPopup):
+        (WebCore::RenderTextControlSingleLine::hidePopup):
+        (WebCore::RenderTextControlSingleLine::paint):
+        (WebCore::RenderTextControlSingleLine::layout):
+        (WebCore::RenderTextControlSingleLine::nodeAtPoint):
+        (WebCore::RenderTextControlSingleLine::styleDidChange):
+        (WebCore::RenderTextControlSingleLine::capsLockStateMayHaveChanged):
+        (WebCore::RenderTextControlSingleLine::hasControlClip):
+        (WebCore::RenderTextControlSingleLine::controlClipRect):
+        (WebCore::RenderTextControlSingleLine::getAvgCharWidth):
+        (WebCore::RenderTextControlSingleLine::preferredContentWidth):
+        (WebCore::RenderTextControlSingleLine::computeControlHeight):
+        (WebCore::RenderTextControlSingleLine::updateFromElement):
+        (WebCore::RenderTextControlSingleLine::createInnerTextStyle):
+        (WebCore::RenderTextControlSingleLine::createInnerBlockStyle):
+        (WebCore::RenderTextControlSingleLine::updateCancelButtonVisibility):
+        (WebCore::RenderTextControlSingleLine::visibilityForCancelButton):
+        (WebCore::RenderTextControlSingleLine::textShouldBeTruncated):
+        (WebCore::RenderTextControlSingleLine::autosaveName):
+        (WebCore::RenderTextControlSingleLine::valueChanged):
+        (WebCore::RenderTextControlSingleLine::itemText):
+        (WebCore::RenderTextControlSingleLine::itemLabel):
+        (WebCore::RenderTextControlSingleLine::itemIcon):
+        (WebCore::RenderTextControlSingleLine::itemIsEnabled):
+        (WebCore::RenderTextControlSingleLine::itemStyle):
+        (WebCore::RenderTextControlSingleLine::menuStyle):
+        (WebCore::RenderTextControlSingleLine::clientInsetLeft):
+        (WebCore::RenderTextControlSingleLine::clientInsetRight):
+        (WebCore::RenderTextControlSingleLine::clientPaddingLeft):
+        (WebCore::RenderTextControlSingleLine::clientPaddingRight):
+        (WebCore::RenderTextControlSingleLine::listSize):
+        (WebCore::RenderTextControlSingleLine::selectedIndex):
+        (WebCore::RenderTextControlSingleLine::popupDidHide):
+        (WebCore::RenderTextControlSingleLine::itemIsSeparator):
+        (WebCore::RenderTextControlSingleLine::itemIsLabel):
+        (WebCore::RenderTextControlSingleLine::itemIsSelected):
+        (WebCore::RenderTextControlSingleLine::setTextFromItem):
+        (WebCore::RenderTextControlSingleLine::fontSelector):
+        (WebCore::RenderTextControlSingleLine::hostWindow):
+        (WebCore::RenderTextControlSingleLine::autoscroll):
+        (WebCore::RenderTextControlSingleLine::scrollWidth):
+        (WebCore::RenderTextControlSingleLine::scrollHeight):
+        (WebCore::RenderTextControlSingleLine::scrollLeft):
+        (WebCore::RenderTextControlSingleLine::scrollTop):
+        (WebCore::RenderTextControlSingleLine::setScrollLeft):
+        (WebCore::RenderTextControlSingleLine::setScrollTop):
+        (WebCore::RenderTextControlSingleLine::scroll):
+        (WebCore::RenderTextControlSingleLine::logicalScroll):
+        (WebCore::RenderTextControlSingleLine::createScrollbar):
+        (WebCore::RenderTextControlSingleLine::inputElement):
+        * rendering/RenderSearchField.h:
+        (RenderTextControlSingleLine):
+        (WebCore::RenderTextControlSingleLine::isTextField):
+        (WebCore::toRenderTextControlSingleLine):
+        (WebCore):
+        (RenderTextControlInnerBlock):
+        (WebCore::RenderTextControlInnerBlock::RenderTextControlInnerBlock):
+        (WebCore::RenderTextControlInnerBlock::hasLineIfEmpty):
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
+        (WebCore::RenderTextControlSingleLine::~RenderTextControlSingleLine):
+        (WebCore):
+        (WebCore::RenderTextControlSingleLine::containerElement):
+        (WebCore::RenderTextControlSingleLine::innerBlockElement):
+        (WebCore::RenderTextControlSingleLine::resultsButtonElement):
+        (WebCore::RenderTextControlSingleLine::cancelButtonElement):
+        (WebCore::RenderTextControlSingleLine::addSearchResult):
+        (WebCore::RenderTextControlSingleLine::showPopup):
+        (WebCore::RenderTextControlSingleLine::hidePopup):
+        (WebCore::RenderTextControlSingleLine::layout):
+        (WebCore::RenderTextControlSingleLine::computeControlHeight):
+        (WebCore::RenderTextControlSingleLine::updateFromElement):
+        (WebCore::RenderTextControlSingleLine::updateCancelButtonVisibility):
+        (WebCore::RenderTextControlSingleLine::visibilityForCancelButton):
+        (WebCore::RenderTextControlSingleLine::autosaveName):
+        (WebCore::RenderTextControlSingleLine::valueChanged):
+        (WebCore::RenderTextControlSingleLine::itemText):
+        (WebCore::RenderTextControlSingleLine::itemLabel):
+        (WebCore::RenderTextControlSingleLine::itemIcon):
+        (WebCore::RenderTextControlSingleLine::itemIsEnabled):
+        (WebCore::RenderTextControlSingleLine::itemStyle):
+        (WebCore::RenderTextControlSingleLine::menuStyle):
+        (WebCore::RenderTextControlSingleLine::clientInsetLeft):
+        (WebCore::RenderTextControlSingleLine::clientInsetRight):
+        (WebCore::RenderTextControlSingleLine::clientPaddingLeft):
+        (WebCore::RenderTextControlSingleLine::clientPaddingRight):
+        (WebCore::RenderTextControlSingleLine::listSize):
+        (WebCore::RenderTextControlSingleLine::selectedIndex):
+        (WebCore::RenderTextControlSingleLine::popupDidHide):
+        (WebCore::RenderTextControlSingleLine::itemIsSeparator):
+        (WebCore::RenderTextControlSingleLine::itemIsLabel):
+        (WebCore::RenderTextControlSingleLine::itemIsSelected):
+        (WebCore::RenderTextControlSingleLine::setTextFromItem):
+        (WebCore::RenderTextControlSingleLine::fontSelector):
+        (WebCore::RenderTextControlSingleLine::hostWindow):
+        (WebCore::RenderTextControlSingleLine::createScrollbar):
+        * rendering/RenderTextControlSingleLine.h:
+        (WebCore):
+        (RenderTextControlSingleLine):
+        (WebCore::RenderTextControlSingleLine::popupIsVisible):
+        * rendering/RenderingAllInOne.cpp:
+
 2012-06-15  Darin Adler  <darin@apple.com>
 
         REGRESSION (r111041): Missing element type check in RenderThemeMac::paintMediaFullscreenButton
index 37b7e5a..4a45c7f 100644 (file)
@@ -3906,8 +3906,6 @@ webcore_sources += \
        Source/WebCore/rendering/RenderScrollbarPart.h \
        Source/WebCore/rendering/RenderScrollbarTheme.cpp \
        Source/WebCore/rendering/RenderScrollbarTheme.h \
-       Source/WebCore/rendering/RenderSearchField.cpp \
-       Source/WebCore/rendering/RenderSearchField.h \
        Source/WebCore/rendering/RenderSelectionInfo.h \
        Source/WebCore/rendering/RenderSlider.cpp \
        Source/WebCore/rendering/RenderSlider.h \
index 69baa92..14f7ed1 100644 (file)
@@ -1309,7 +1309,6 @@ SOURCES += \
     rendering/RenderScrollbar.cpp \
     rendering/RenderScrollbarPart.cpp \
     rendering/RenderScrollbarTheme.cpp \
-    rendering/RenderSearchField.cpp \
     rendering/RenderSlider.cpp \
     rendering/RenderTable.cpp \
     rendering/RenderTableCaption.cpp \
@@ -2515,7 +2514,6 @@ HEADERS += \
     rendering/RenderScrollbar.h \
     rendering/RenderScrollbarPart.h \
     rendering/RenderScrollbarTheme.h \
-    rendering/RenderSearchField.h \
     rendering/RenderSlider.h \
     rendering/RenderTableCaption.h \
     rendering/RenderTableCell.h \
index 7c2ba7f..ff3a3a8 100644 (file)
             'rendering/RenderScrollbarPart.h',
             'rendering/RenderScrollbarTheme.cpp',
             'rendering/RenderScrollbarTheme.h',
-            'rendering/RenderSearchField.cpp',
-            'rendering/RenderSearchField.h',
             'rendering/RenderSelectionInfo.h',
             'rendering/RenderSlider.cpp',
             'rendering/RenderSlider.h',
index d06ddaa..17ae0df 100755 (executable)
                                >
                        </File>
                        <File
-                               RelativePath="..\rendering\RenderSearchField.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="..\rendering\RenderSearchField.h"
-                               >
-                       </File>
-                       <File
                                RelativePath="..\rendering\RenderSelectionInfo.h"
                                >
                        </File>
index df8d5a8..ec3666d 100644 (file)
                45099C411370A7800058D513 /* IconURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 45099C401370A7800058D513 /* IconURL.cpp */; };
                450CEBF015073BBE002BB149 /* LabelableElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 450CEBEE15073BBE002BB149 /* LabelableElement.cpp */; };
                450CEBF115073BBE002BB149 /* LabelableElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 450CEBEF15073BBE002BB149 /* LabelableElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               458FE4091589DF0B005609E6 /* RenderSearchField.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 458FE4071589DF0B005609E6 /* RenderSearchField.cpp */; };
-               458FE40A1589DF0B005609E6 /* RenderSearchField.h in Headers */ = {isa = PBXBuildFile; fileRef = 458FE4081589DF0B005609E6 /* RenderSearchField.h */; };
                45BAC2B01360BBAB005DA258 /* IconURL.h in Headers */ = {isa = PBXBuildFile; fileRef = 45BAC2AF1360BBAB005DA258 /* IconURL.h */; settings = {ATTRIBUTES = (Private, ); }; };
                45FEA5CF156DDE8C00654101 /* Decimal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 45FEA5CD156DDE8C00654101 /* Decimal.cpp */; };
                45FEA5D0156DDE8C00654101 /* Decimal.h in Headers */ = {isa = PBXBuildFile; fileRef = 45FEA5CE156DDE8C00654101 /* Decimal.h */; settings = {ATTRIBUTES = (Private, ); }; };
                45099C401370A7800058D513 /* IconURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IconURL.cpp; sourceTree = "<group>"; };
                450CEBEE15073BBE002BB149 /* LabelableElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LabelableElement.cpp; sourceTree = "<group>"; };
                450CEBEF15073BBE002BB149 /* LabelableElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelableElement.h; sourceTree = "<group>"; };
-               458FE4071589DF0B005609E6 /* RenderSearchField.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSearchField.cpp; sourceTree = "<group>"; };
-               458FE4081589DF0B005609E6 /* RenderSearchField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSearchField.h; sourceTree = "<group>"; };
                45BAC2AF1360BBAB005DA258 /* IconURL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IconURL.h; sourceTree = "<group>"; };
                45FEA5CD156DDE8C00654101 /* Decimal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Decimal.cpp; sourceTree = "<group>"; };
                45FEA5CE156DDE8C00654101 /* Decimal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Decimal.h; sourceTree = "<group>"; };
                                BC3BE9920E9C1C7C00835588 /* RenderScrollbarPart.h */,
                                BC3BE9A40E9C239600835588 /* RenderScrollbarTheme.cpp */,
                                BC3BE9980E9C1E5D00835588 /* RenderScrollbarTheme.h */,
-                               458FE4071589DF0B005609E6 /* RenderSearchField.cpp */,
-                               458FE4081589DF0B005609E6 /* RenderSearchField.h */,
                                0F11A54E0F39233100C37884 /* RenderSelectionInfo.h */,
                                AB247A6A0AFD6383003FA5FD /* RenderSlider.cpp */,
                                AB247A6B0AFD6383003FA5FD /* RenderSlider.h */,
                                BC3BE9940E9C1C7C00835588 /* RenderScrollbar.h in Headers */,
                                BC3BE9950E9C1C7C00835588 /* RenderScrollbarPart.h in Headers */,
                                BC3BE9990E9C1E5D00835588 /* RenderScrollbarTheme.h in Headers */,
-                               458FE40A1589DF0B005609E6 /* RenderSearchField.h in Headers */,
                                0F11A54F0F39233100C37884 /* RenderSelectionInfo.h in Headers */,
                                AB247A6D0AFD6383003FA5FD /* RenderSlider.h in Headers */,
                                BC8C8FAE0DDCD31B00B592F4 /* RenderStyle.h in Headers */,
                                BC3BE9930E9C1C7C00835588 /* RenderScrollbar.cpp in Sources */,
                                BC3BE9AB0E9C242000835588 /* RenderScrollbarPart.cpp in Sources */,
                                BC3BE9A50E9C239600835588 /* RenderScrollbarTheme.cpp in Sources */,
-                               458FE4091589DF0B005609E6 /* RenderSearchField.cpp in Sources */,
                                AB247A6C0AFD6383003FA5FD /* RenderSlider.cpp in Sources */,
                                BC8C8FAD0DDCD31B00B592F4 /* RenderStyle.cpp in Sources */,
                                0F4E57171313276200CF85AF /* RenderSVGAllInOne.cpp in Sources */,
index 8d15ca2..5c6bf16 100644 (file)
@@ -457,6 +457,7 @@ void HTMLInputElement::subtreeHasChanged()
 {
     ASSERT(isTextField());
     ASSERT(renderer());
+    RenderTextControlSingleLine* renderTextControl = toRenderTextControlSingleLine(renderer());
 
     bool wasChanged = wasChangedSinceLastFormControlChangeEvent();
     setChangedSinceLastFormControlChangeEvent(true);
@@ -472,7 +473,12 @@ void HTMLInputElement::subtreeHasChanged()
     // Recalc for :invalid and hasUnacceptableValue() change.
     setNeedsStyleRecalc();
 
-    m_inputType->subtreeHasChanged();
+    if (cancelButtonElement())
+        renderTextControl->updateCancelButtonVisibility();
+
+    // If the incremental attribute is set, then dispatch the search event
+    if (searchEventsShouldBeDispatched() && isSearchField() && m_inputType)
+        static_cast<SearchInputType*>(m_inputType.get())->startSearchEventTimer();
 
     if (!wasChanged && focused()) {
         if (Frame* frame = document()->frame())
@@ -966,6 +972,11 @@ void HTMLInputElement::setPlaceholder(const String& value)
     setAttribute(placeholderAttr, value);
 }
 
+bool HTMLInputElement::searchEventsShouldBeDispatched() const
+{
+    return hasAttribute(incrementalAttr);
+}
+
 void HTMLInputElement::setValueFromRenderer(const String& value)
 {
     // File upload controls will never use this.
@@ -1322,7 +1333,9 @@ bool HTMLInputElement::isRequiredFormControl() const
 
 void HTMLInputElement::addSearchResult()
 {
-    m_inputType->addSearchResult();
+    ASSERT(isSearchField());
+    if (renderer())
+        toRenderTextControlSingleLine(renderer())->addSearchResult();
 }
 
 void HTMLInputElement::onSearch()
index cb5231f..986d91e 100644 (file)
@@ -227,6 +227,7 @@ public:
 
     void addSearchResult();
     void onSearch();
+    bool searchEventsShouldBeDispatched() const;
 
 #if ENABLE(DATALIST)
     HTMLElement* list() const;
index dae03f3..dfc50e0 100644 (file)
@@ -523,10 +523,6 @@ void InputType::accessKeyAction(bool)
     element()->focus(false);
 }
 
-void InputType::addSearchResult()
-{
-}
-
 void InputType::attach()
 {
 }
@@ -856,10 +852,6 @@ void InputType::readonlyAttributeChanged()
 {
 }
 
-void InputType::subtreeHasChanged()
-{
-}
-
 String InputType::defaultToolTip() const
 {
     return String();
index b68d97f..386051f 100644 (file)
@@ -200,7 +200,7 @@ public:
     virtual void handleBlurEvent();
     virtual void accessKeyAction(bool sendMouseEvents);
     virtual bool canBeSuccessfulSubmitButton();
-    virtual void subtreeHasChanged();
+
 
     // Shadow tree handling
 
@@ -222,7 +222,6 @@ public:
 
     virtual bool rendererIsNeeded();
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
-    virtual void addSearchResult();
     virtual void attach();
     virtual void detach();
     virtual void minOrMaxAttributeChanged();
index 958878c..6f500da 100644 (file)
 #include "SearchInputType.h"
 
 #include "HTMLInputElement.h"
-#include "HTMLNames.h"
 #include "KeyboardEvent.h"
-#include "RenderSearchField.h"
+#include "RenderTextControlSingleLine.h"
 #include "ShadowRoot.h"
 #include "TextControlInnerElements.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
 
-using namespace HTMLNames;
-
 inline SearchInputType::SearchInputType(HTMLInputElement* element)
     : BaseTextInputType(element)
     , m_searchEventTimer(this, &SearchInputType::searchEventTimerFired)
@@ -54,17 +51,6 @@ PassOwnPtr<InputType> SearchInputType::create(HTMLInputElement* element)
     return adoptPtr(new SearchInputType(element));
 }
 
-void SearchInputType::addSearchResult()
-{
-    if (RenderObject* renderer = element()->renderer())
-        toRenderSearchField(renderer)->addSearchResult();
-}
-
-RenderObject* SearchInputType::createRenderer(RenderArena* arena, RenderStyle*) const
-{
-    return new (arena) RenderSearchField(element());
-}
-
 const AtomicString& SearchInputType::formControlType() const
 {
     return InputTypeNames::search();
@@ -165,19 +151,5 @@ void SearchInputType::searchEventTimerFired(Timer<SearchInputType>*)
     element()->onSearch();
 }
 
-bool SearchInputType::searchEventsShouldBeDispatched() const
-{
-    return element()->hasAttribute(incrementalAttr);
-}
-
-void SearchInputType::subtreeHasChanged()
-{
-    if (m_cancelButton.get())
-        toRenderSearchField(element()->renderer())->updateCancelButtonVisibility();
-
-    // If the incremental attribute is set, then dispatch the search event
-    if (searchEventsShouldBeDispatched())
-        startSearchEventTimer();
-}
 
 } // namespace WebCore
index ece35a2..ab19103 100644 (file)
@@ -43,12 +43,11 @@ class SearchInputType : public BaseTextInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
+    void startSearchEventTimer();
     void stopSearchEventTimer();
 
 private:
     SearchInputType(HTMLInputElement*);
-    virtual void addSearchResult() OVERRIDE;
-    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE;
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual bool shouldRespectSpeechAttribute() OVERRIDE;
     virtual bool isSearchField() const OVERRIDE;
@@ -58,11 +57,8 @@ private:
     virtual HTMLElement* resultsButtonElement() const OVERRIDE;
     virtual HTMLElement* cancelButtonElement() const OVERRIDE;
     virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE;
-    virtual void subtreeHasChanged();
 
     void searchEventTimerFired(Timer<SearchInputType>*);
-    bool searchEventsShouldBeDispatched() const;
-    void startSearchEventTimer();
 
     RefPtr<HTMLElement> m_resultsButton;
     RefPtr<HTMLElement> m_cancelButton;
index 5d26841..100daeb 100644 (file)
@@ -37,7 +37,7 @@
 #include "HTMLTextAreaElement.h"
 #include "MouseEvent.h"
 #include "Page.h"
-#include "RenderSearchField.h"
+#include "RenderTextControlSingleLine.h"
 #include "RenderView.h"
 #include "ScriptController.h"
 #include "ScrollbarTheme.h"
@@ -151,7 +151,7 @@ void SearchFieldResultsButtonElement::defaultEventHandler(Event* event)
     if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
         input->focus();
         input->select();
-        RenderSearchField* renderer = toRenderSearchField(input->renderer());
+        RenderTextControlSingleLine* renderer = toRenderTextControlSingleLine(input->renderer());
         if (renderer->popupIsVisible())
             renderer->hidePopup();
         else if (input->maxResults() > 0)
index 247ce40..da03987 100644 (file)
@@ -190,7 +190,8 @@ PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const A
             HTMLInputElement* input = static_cast<HTMLInputElement*>(control);
             if (input->isTextField()) {
                 formValues.append(pair<String, String>(input->name().string(), input->value()));
-                input->addSearchResult();
+                if (input->isSearchField())
+                    input->addSearchResult();
             }
             if (input->isPasswordField() && !input->value().isEmpty())
                 containsPasswordData = true;
index 2704cdc..848fc21 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 #include "config.h"
-#include "RenderSearchField.h"
+#include "RenderTextControlSingleLine.h"
 
 #include "CSSFontSelector.h"
 #include "CSSValueKeywords.h"
@@ -51,19 +51,35 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
+VisiblePosition RenderTextControlInnerBlock::positionForPoint(const LayoutPoint& point)
+{
+    LayoutPoint contentsPoint(point);
+
+    // Multiline text controls have the scroll on shadowAncestorNode, so we need to take that
+    // into account here.
+    if (m_multiLine) {
+        RenderTextControl* renderer = toRenderTextControl(node()->shadowAncestorNode()->renderer());
+        if (renderer->hasOverflowClip())
+            contentsPoint += renderer->scrolledContentOffset();
+    }
+
+    return RenderBlock::positionForPoint(contentsPoint);
+}
+
 // ----------------------------
 
-RenderSearchField::RenderSearchField(Node* node)
-    : RenderTextControlSingleLine(node)
+RenderTextControlSingleLine::RenderTextControlSingleLine(Node* node)
+    : RenderTextControl(node)
     , m_searchPopupIsVisible(false)
+    , m_shouldDrawCapsLockIndicator(false)
+    , m_desiredInnerTextHeight(-1)
     , m_searchPopup(0)
 {
     ASSERT(node->isHTMLElement());
     ASSERT(node->toInputElement());
-    ASSERT(node->toInputElement()->isSearchField());
 }
 
-RenderSearchField::~RenderSearchField()
+RenderTextControlSingleLine::~RenderTextControlSingleLine()
 {
     if (m_searchPopup) {
         m_searchPopup->popupMenu()->disconnectClient();
@@ -71,17 +87,38 @@ RenderSearchField::~RenderSearchField()
     }
 }
 
-inline HTMLElement* RenderSearchField::resultsButtonElement() const
+inline HTMLElement* RenderTextControlSingleLine::containerElement() const
+{
+    return inputElement()->containerElement();
+}
+
+inline HTMLElement* RenderTextControlSingleLine::innerBlockElement() const
+{
+    return inputElement()->innerBlockElement();
+}
+
+inline HTMLElement* RenderTextControlSingleLine::innerSpinButtonElement() const
+{
+    return inputElement()->innerSpinButtonElement();
+}
+
+inline HTMLElement* RenderTextControlSingleLine::resultsButtonElement() const
 {
     return inputElement()->resultsButtonElement();
 }
 
-inline HTMLElement* RenderSearchField::cancelButtonElement() const
+inline HTMLElement* RenderTextControlSingleLine::cancelButtonElement() const
 {
     return inputElement()->cancelButtonElement();
 }
 
-void RenderSearchField::addSearchResult()
+RenderStyle* RenderTextControlSingleLine::textBaseStyle() const
+{
+    HTMLElement* innerBlock = innerBlockElement();
+    return innerBlock ? innerBlock->renderer()->style() : style();
+}
+
+void RenderTextControlSingleLine::addSearchResult()
 {
     HTMLInputElement* input = inputElement();
     if (input->maxResults() <= 0)
@@ -112,7 +149,7 @@ void RenderSearchField::addSearchResult()
     m_searchPopup->saveRecentSearches(name, m_recentSearches);
 }
 
-void RenderSearchField::showPopup()
+void RenderTextControlSingleLine::showPopup()
 {
     if (m_searchPopupIsVisible)
         return;
@@ -141,13 +178,258 @@ void RenderSearchField::showPopup()
     m_searchPopup->popupMenu()->show(pixelSnappedIntRect(absoluteBoundingBoxRect()), document()->view(), -1);
 }
 
-void RenderSearchField::hidePopup()
+void RenderTextControlSingleLine::hidePopup()
 {
     if (m_searchPopup)
         m_searchPopup->popupMenu()->hide();
 }
 
-LayoutUnit RenderSearchField::computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
+void RenderTextControlSingleLine::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+    RenderTextControl::paint(paintInfo, paintOffset);
+
+    if (paintInfo.phase == PaintPhaseBlockBackground && m_shouldDrawCapsLockIndicator) {
+        LayoutRect contentsRect = contentBoxRect();
+
+        // Center vertically like the text.
+        contentsRect.setY((height() - contentsRect.height()) / 2);
+
+        // Convert the rect into the coords used for painting the content
+        contentsRect.moveBy(paintOffset + location());
+        theme()->paintCapsLockIndicator(this, paintInfo, pixelSnappedIntRect(contentsRect));
+    }
+}
+
+void RenderTextControlSingleLine::layout()
+{
+    // FIXME: We should remove the height-related hacks in layout() and
+    // styleDidChange(). We need them because
+    // - Center the inner elements vertically if the input height is taller than
+    //   the intrinsic height of the inner elements.
+    // - Shrink the inner elment heights if the input height is samller than the
+    //   intrinsic heights of the inner elements.
+
+    // We don't honor paddings and borders for textfields without decorations
+    // and type=search if the text height is taller than the contentHeight()
+    // because of compability.
+
+    RenderBlock::layoutBlock(false);
+
+    RenderBox* innerTextRenderer = innerTextElement()->renderBox();
+    ASSERT(innerTextRenderer);
+    RenderBox* innerBlockRenderer = innerBlockElement() ? innerBlockElement()->renderBox() : 0;
+    HTMLElement* container = containerElement();
+    RenderBox* containerRenderer = container ? container->renderBox() : 0;
+
+    // Set the text block height
+    LayoutUnit desiredHeight = textBlockHeight();
+    LayoutUnit currentHeight = innerTextRenderer->height();
+
+    LayoutUnit heightLimit = (inputElement()->isSearchField() || !container) ? height() : contentHeight();
+    if (currentHeight > heightLimit) {
+        if (desiredHeight != currentHeight)
+            setNeedsLayout(true, MarkOnlyThis);
+
+        innerTextRenderer->style()->setHeight(Length(desiredHeight, Fixed));
+        m_desiredInnerTextHeight = desiredHeight;
+        if (innerBlockRenderer)
+            innerBlockRenderer->style()->setHeight(Length(desiredHeight, Fixed));
+    }
+    // The container might be taller because of decoration elements.
+    if (containerRenderer) {
+        containerRenderer->layoutIfNeeded();
+        LayoutUnit containerHeight = containerRenderer->height();
+        if (containerHeight > heightLimit) {
+            containerRenderer->style()->setHeight(Length(heightLimit, Fixed));
+            setNeedsLayout(true, MarkOnlyThis);
+        } else if (containerRenderer->height() < contentHeight()) {
+            containerRenderer->style()->setHeight(Length(contentHeight(), Fixed));
+            setNeedsLayout(true, MarkOnlyThis);
+        } else
+            containerRenderer->style()->setHeight(Length(containerHeight, Fixed));
+    }
+
+    // If we need another layout pass, we have changed one of children's height so we need to relayout them.
+    if (needsLayout())
+        RenderBlock::layoutBlock(true);
+
+    // Center the child block vertically
+    currentHeight = innerTextRenderer->height();
+    if (!container && currentHeight != contentHeight()) {
+        LayoutUnit heightDiff = currentHeight - contentHeight();
+        innerTextRenderer->setY(innerTextRenderer->y() - (heightDiff / 2 + layoutMod(heightDiff, 2)));
+    } else if (inputElement()->isSearchField() && containerRenderer && containerRenderer->height() > contentHeight()) {
+        // A quirk for find-in-page box on Safari Windows.
+        // http://webkit.org/b/63157
+        LayoutUnit heightDiff = containerRenderer->height() - contentHeight();
+        containerRenderer->setY(containerRenderer->y() - (heightDiff / 2 + layoutMod(heightDiff, 2)));
+    }
+
+    // Ignores the paddings for the inner spin button.
+    if (RenderBox* innerSpinBox = innerSpinButtonElement() ? innerSpinButtonElement()->renderBox() : 0) {
+        RenderBox* parentBox = innerSpinBox->parentBox();
+        if (containerRenderer && !containerRenderer->style()->isLeftToRightDirection())
+            innerSpinBox->setLocation(LayoutPoint(-paddingLeft(), -paddingTop()));
+        else
+            innerSpinBox->setLocation(LayoutPoint(parentBox->width() - innerSpinBox->width() + paddingRight(), -paddingTop()));
+        innerSpinBox->setHeight(height() - borderTop() - borderBottom());
+    }
+
+    HTMLElement* placeholderElement = inputElement()->placeholderElement();
+    if (RenderBox* placeholderBox = placeholderElement ? placeholderElement->renderBox() : 0) {
+        placeholderBox->style()->setWidth(Length(innerTextRenderer->width() - placeholderBox->borderAndPaddingWidth(), Fixed));
+        placeholderBox->style()->setHeight(Length(innerTextRenderer->height() - placeholderBox->borderAndPaddingHeight(), Fixed));
+        bool placeholderBoxHadLayout = placeholderBox->everHadLayout();
+        placeholderBox->layoutIfNeeded();
+        LayoutPoint textOffset = innerTextRenderer->location();
+        if (innerBlockElement() && innerBlockElement()->renderBox())
+            textOffset += toLayoutSize(innerBlockElement()->renderBox()->location());
+        if (containerRenderer)
+            textOffset += toLayoutSize(containerRenderer->location());
+        placeholderBox->setLocation(textOffset);
+
+        if (!placeholderBoxHadLayout && placeholderBox->checkForRepaintDuringLayout()) {
+            // This assumes a shadow tree without floats. If floats are added, the
+            // logic should be shared with RenderBlock::layoutBlockChild.
+            placeholderBox->repaint();
+        }
+    }
+}
+
+bool RenderTextControlSingleLine::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
+{
+    if (!RenderTextControl::nodeAtPoint(request, result, pointInContainer, accumulatedOffset, hitTestAction))
+        return false;
+
+    // Say that we hit the inner text element if
+    //  - we hit a node inside the inner text element,
+    //  - we hit the <input> element (e.g. we're over the border or padding), or
+    //  - we hit regions not in any decoration buttons.
+    HTMLElement* container = containerElement();
+    if (result.innerNode()->isDescendantOf(innerTextElement()) || result.innerNode() == node() || (container && container == result.innerNode())) {
+        LayoutPoint pointInParent = pointInContainer;
+        if (container && innerBlockElement()) {
+            if (innerBlockElement()->renderBox())
+                pointInParent -= toLayoutSize(innerBlockElement()->renderBox()->location());
+            if (container->renderBox())
+                pointInParent -= toLayoutSize(container->renderBox()->location());
+        }
+        hitInnerTextElement(result, pointInParent, accumulatedOffset);
+    }
+    return true;
+}
+
+void RenderTextControlSingleLine::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
+{
+    m_desiredInnerTextHeight = -1;
+    RenderTextControl::styleDidChange(diff, oldStyle);
+
+    // We may have set the width and the height in the old style in layout().
+    // Reset them now to avoid getting a spurious layout hint.
+    HTMLElement* innerBlock = innerBlockElement();
+    if (RenderObject* innerBlockRenderer = innerBlock ? innerBlock->renderer() : 0) {
+        innerBlockRenderer->style()->setHeight(Length());
+        innerBlockRenderer->style()->setWidth(Length());
+    }
+    HTMLElement* container = containerElement();
+    if (RenderObject* containerRenderer = container ? container->renderer() : 0) {
+        containerRenderer->style()->setHeight(Length());
+        containerRenderer->style()->setWidth(Length());
+    }
+    if (HTMLElement* placeholder = inputElement()->placeholderElement())
+        placeholder->setInlineStyleProperty(CSSPropertyTextOverflow, textShouldBeTruncated() ? CSSValueEllipsis : CSSValueClip);
+    setHasOverflowClip(false);
+}
+
+void RenderTextControlSingleLine::capsLockStateMayHaveChanged()
+{
+    if (!node() || !document())
+        return;
+
+    // Only draw the caps lock indicator if these things are true:
+    // 1) The field is a password field
+    // 2) The frame is active
+    // 3) The element is focused
+    // 4) The caps lock is on
+    bool shouldDrawCapsLockIndicator = false;
+
+    if (Frame* frame = document()->frame())
+        shouldDrawCapsLockIndicator = inputElement()->isPasswordField()
+                                      && frame->selection()->isFocusedAndActive()
+                                      && document()->focusedNode() == node()
+                                      && PlatformKeyboardEvent::currentCapsLockState();
+
+    if (shouldDrawCapsLockIndicator != m_shouldDrawCapsLockIndicator) {
+        m_shouldDrawCapsLockIndicator = shouldDrawCapsLockIndicator;
+        repaint();
+    }
+}
+
+bool RenderTextControlSingleLine::hasControlClip() const
+{
+    // Apply control clip for text fields with decorations.
+    return !!containerElement();
+}
+
+LayoutRect RenderTextControlSingleLine::controlClipRect(const LayoutPoint& additionalOffset) const
+{
+    ASSERT(hasControlClip());
+    LayoutRect clipRect = unionRect(contentBoxRect(), containerElement()->renderBox()->frameRect());
+    clipRect.moveBy(additionalOffset);
+    return clipRect;
+}
+
+float RenderTextControlSingleLine::getAvgCharWidth(AtomicString family)
+{
+    // Since Lucida Grande is the default font, we want this to match the width
+    // of MS Shell Dlg, the default font for textareas in Firefox, Safari Win and
+    // IE for some encodings (in IE, the default font is encoding specific).
+    // 901 is the avgCharWidth value in the OS/2 table for MS Shell Dlg.
+    if (family == AtomicString("Lucida Grande"))
+        return scaleEmToUnits(901);
+
+    return RenderTextControl::getAvgCharWidth(family);
+}
+
+LayoutUnit RenderTextControlSingleLine::preferredContentWidth(float charWidth) const
+{
+    int factor;
+    bool includesDecoration = inputElement()->sizeShouldIncludeDecoration(factor);
+    if (factor <= 0)
+        factor = 20;
+
+    LayoutUnit result = static_cast<LayoutUnit>(ceiledLayoutUnit(charWidth * factor));
+
+    float maxCharWidth = 0.f;
+    AtomicString family = style()->font().family().family();
+    // Since Lucida Grande is the default font, we want this to match the width
+    // of MS Shell Dlg, the default font for textareas in Firefox, Safari Win and
+    // IE for some encodings (in IE, the default font is encoding specific).
+    // 4027 is the (xMax - xMin) value in the "head" font table for MS Shell Dlg.
+    if (family == AtomicString("Lucida Grande"))
+        maxCharWidth = scaleEmToUnits(4027);
+    else if (hasValidAvgCharWidth(family))
+        maxCharWidth = roundf(style()->font().primaryFont()->maxCharWidth());
+
+    // For text inputs, IE adds some extra width.
+    if (maxCharWidth > 0.f)
+        result += maxCharWidth - charWidth;
+
+    if (includesDecoration) {
+        HTMLElement* spinButton = innerSpinButtonElement();
+        if (RenderBox* spinRenderer = spinButton ? spinButton->renderBox() : 0) {
+            result += spinRenderer->borderLeft() + spinRenderer->borderRight() +
+                  spinRenderer->paddingLeft() + spinRenderer->paddingRight();
+            // Since the width of spinRenderer is not calculated yet, spinRenderer->width() returns 0.
+            // So computedStyle()->width() is used instead.
+            result += spinButton->computedStyle()->width().value();
+        }
+    }
+
+    return result;
+}
+
+LayoutUnit RenderTextControlSingleLine::computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
 {
     HTMLElement* resultsButton = resultsButtonElement();
     if (RenderBox* resultsRenderer = resultsButton ? resultsButton->renderBox() : 0) {
@@ -165,9 +447,9 @@ LayoutUnit RenderSearchField::computeControlHeight(LayoutUnit lineHeight, Layout
     return lineHeight + nonContentHeight;
 }
 
-void RenderSearchField::updateFromElement()
+void RenderTextControlSingleLine::updateFromElement()
 {
-    RenderTextControlSingleLine::updateFromElement();
+    RenderTextControl::updateFromElement();
 
     if (cancelButtonElement())
         updateCancelButtonVisibility();
@@ -176,7 +458,45 @@ void RenderSearchField::updateFromElement()
         m_searchPopup->popupMenu()->updateFromElement();
 }
 
-void RenderSearchField::updateCancelButtonVisibility() const
+PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerTextStyle(const RenderStyle* startStyle) const
+{
+    RefPtr<RenderStyle> textBlockStyle = RenderStyle::create();   
+    textBlockStyle->inheritFrom(startStyle);
+    adjustInnerTextStyle(startStyle, textBlockStyle.get());
+
+    textBlockStyle->setWhiteSpace(PRE);
+    textBlockStyle->setWordWrap(NormalWordWrap);
+    textBlockStyle->setOverflowX(OHIDDEN);
+    textBlockStyle->setOverflowY(OHIDDEN);
+    textBlockStyle->setTextOverflow(textShouldBeTruncated() ? TextOverflowEllipsis : TextOverflowClip);
+
+    if (m_desiredInnerTextHeight >= 0)
+        textBlockStyle->setHeight(Length(m_desiredInnerTextHeight, Fixed));
+    // Do not allow line-height to be smaller than our default.
+    if (textBlockStyle->fontMetrics().lineSpacing() > lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes))
+        textBlockStyle->setLineHeight(Length(-100.0f, Percent));
+
+    textBlockStyle->setDisplay(BLOCK);
+
+    return textBlockStyle.release();
+}
+
+PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerBlockStyle(const RenderStyle* startStyle) const
+{
+    RefPtr<RenderStyle> innerBlockStyle = RenderStyle::create();
+    innerBlockStyle->inheritFrom(startStyle);
+
+    innerBlockStyle->setBoxFlex(1);
+    innerBlockStyle->setDisplay(BLOCK);
+    innerBlockStyle->setDirection(LTR);
+
+    // We don't want the shadow dom to be editable, so we set this block to read-only in case the input itself is editable.
+    innerBlockStyle->setUserModify(READ_ONLY);
+
+    return innerBlockStyle.release();
+}
+
+void RenderTextControlSingleLine::updateCancelButtonVisibility() const
 {
     RenderObject* cancelButtonRenderer = cancelButtonElement()->renderer();
     if (!cancelButtonRenderer)
@@ -192,18 +512,24 @@ void RenderSearchField::updateCancelButtonVisibility() const
     cancelButtonRenderer->setStyle(cancelButtonStyle);
 }
 
-EVisibility RenderSearchField::visibilityForCancelButton() const
+EVisibility RenderTextControlSingleLine::visibilityForCancelButton() const
 {
     return (style()->visibility() == HIDDEN || inputElement()->value().isEmpty()) ? HIDDEN : VISIBLE;
 }
 
-const AtomicString& RenderSearchField::autosaveName() const
+bool RenderTextControlSingleLine::textShouldBeTruncated() const
+{
+    return document()->focusedNode() != node()
+        && style()->textOverflow() == TextOverflowEllipsis;
+}
+
+const AtomicString& RenderTextControlSingleLine::autosaveName() const
 {
     return static_cast<Element*>(node())->getAttribute(autosaveAttr);
 }
 
 // PopupMenuClient methods
-void RenderSearchField::valueChanged(unsigned listIndex, bool fireEvents)
+void RenderTextControlSingleLine::valueChanged(unsigned listIndex, bool fireEvents)
 {
     ASSERT(static_cast<int>(listIndex) < listSize());
     HTMLInputElement* input = inputElement();
@@ -225,7 +551,7 @@ void RenderSearchField::valueChanged(unsigned listIndex, bool fireEvents)
     }
 }
 
-String RenderSearchField::itemText(unsigned listIndex) const
+String RenderTextControlSingleLine::itemText(unsigned listIndex) const
 {
     int size = listSize();
     if (size == 1) {
@@ -241,42 +567,42 @@ String RenderSearchField::itemText(unsigned listIndex) const
     return m_recentSearches[listIndex - 1];
 }
 
-String RenderSearchField::itemLabel(unsigned) const
+String RenderTextControlSingleLine::itemLabel(unsigned) const
 {
     return String();
 }
 
-String RenderSearchField::itemIcon(unsigned) const
+String RenderTextControlSingleLine::itemIcon(unsigned) const
 {
     return String();
 }
 
-bool RenderSearchField::itemIsEnabled(unsigned listIndex) const
+bool RenderTextControlSingleLine::itemIsEnabled(unsigned listIndex) const
 {
      if (!listIndex || itemIsSeparator(listIndex))
         return false;
     return true;
 }
 
-PopupMenuStyle RenderSearchField::itemStyle(unsigned) const
+PopupMenuStyle RenderTextControlSingleLine::itemStyle(unsigned) const
 {
     return menuStyle();
 }
 
-PopupMenuStyle RenderSearchField::menuStyle() const
+PopupMenuStyle RenderTextControlSingleLine::menuStyle() const
 {
     return PopupMenuStyle(style()->visitedDependentColor(CSSPropertyColor), style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->font(), style()->visibility() == VISIBLE,
         style()->display() == NONE, style()->textIndent(), style()->direction(), isOverride(style()->unicodeBidi()));
 }
 
-int RenderSearchField::clientInsetLeft() const
+int RenderTextControlSingleLine::clientInsetLeft() const
 {
     // Inset the menu by the radius of the cap on the left so that
     // it only runs along the straight part of the bezel.
     return height() / 2;
 }
 
-int RenderSearchField::clientInsetRight() const
+int RenderTextControlSingleLine::clientInsetRight() const
 {
     // Inset the menu by the radius of the cap on the right so that
     // it only runs along the straight part of the bezel (unless it needs
@@ -284,7 +610,7 @@ int RenderSearchField::clientInsetRight() const
     return height() / 2;
 }
 
-LayoutUnit RenderSearchField::clientPaddingLeft() const
+LayoutUnit RenderTextControlSingleLine::clientPaddingLeft() const
 {
     LayoutUnit padding = paddingLeft();
     if (RenderBox* box = innerBlockElement() ? innerBlockElement()->renderBox() : 0)
@@ -292,7 +618,7 @@ LayoutUnit RenderSearchField::clientPaddingLeft() const
     return padding;
 }
 
-LayoutUnit RenderSearchField::clientPaddingRight() const
+LayoutUnit RenderTextControlSingleLine::clientPaddingRight() const
 {
     LayoutUnit padding = paddingRight();
     if (RenderBox* containerBox = containerElement() ? containerElement()->renderBox() : 0) {
@@ -302,7 +628,7 @@ LayoutUnit RenderSearchField::clientPaddingRight() const
     return padding;
 }
 
-int RenderSearchField::listSize() const
+int RenderTextControlSingleLine::listSize() const
 {
     // If there are no recent searches, then our menu will have 1 "No recent searches" item.
     if (!m_recentSearches.size())
@@ -311,48 +637,111 @@ int RenderSearchField::listSize() const
     return m_recentSearches.size() + 3;
 }
 
-int RenderSearchField::selectedIndex() const
+int RenderTextControlSingleLine::selectedIndex() const
 {
     return -1;
 }
 
-void RenderSearchField::popupDidHide()
+void RenderTextControlSingleLine::popupDidHide()
 {
     m_searchPopupIsVisible = false;
 }
 
-bool RenderSearchField::itemIsSeparator(unsigned listIndex) const
+bool RenderTextControlSingleLine::itemIsSeparator(unsigned listIndex) const
 {
     // The separator will be the second to last item in our list.
     return static_cast<int>(listIndex) == (listSize() - 2);
 }
 
-bool RenderSearchField::itemIsLabel(unsigned listIndex) const
+bool RenderTextControlSingleLine::itemIsLabel(unsigned listIndex) const
 {
-    return !listIndex;
+    return listIndex == 0;
 }
 
-bool RenderSearchField::itemIsSelected(unsigned) const
+bool RenderTextControlSingleLine::itemIsSelected(unsigned) const
 {
     return false;
 }
 
-void RenderSearchField::setTextFromItem(unsigned listIndex)
+void RenderTextControlSingleLine::setTextFromItem(unsigned listIndex)
 {
     inputElement()->setValue(itemText(listIndex));
 }
 
-FontSelector* RenderSearchField::fontSelector() const
+FontSelector* RenderTextControlSingleLine::fontSelector() const
 {
     return document()->styleResolver()->fontSelector();
 }
 
-HostWindow* RenderSearchField::hostWindow() const
+HostWindow* RenderTextControlSingleLine::hostWindow() const
 {
     return document()->view()->hostWindow();
 }
 
-PassRefPtr<Scrollbar> RenderSearchField::createScrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize)
+void RenderTextControlSingleLine::autoscroll()
+{
+    RenderLayer* layer = innerTextElement()->renderBox()->layer();
+    if (layer)
+        layer->autoscroll();
+}
+
+int RenderTextControlSingleLine::scrollWidth() const
+{
+    if (innerTextElement())
+        return innerTextElement()->scrollWidth();
+    return RenderBlock::scrollWidth();
+}
+
+int RenderTextControlSingleLine::scrollHeight() const
+{
+    if (innerTextElement())
+        return innerTextElement()->scrollHeight();
+    return RenderBlock::scrollHeight();
+}
+
+int RenderTextControlSingleLine::scrollLeft() const
+{
+    if (innerTextElement())
+        return innerTextElement()->scrollLeft();
+    return RenderBlock::scrollLeft();
+}
+
+int RenderTextControlSingleLine::scrollTop() const
+{
+    if (innerTextElement())
+        return innerTextElement()->scrollTop();
+    return RenderBlock::scrollTop();
+}
+
+void RenderTextControlSingleLine::setScrollLeft(int newLeft)
+{
+    if (innerTextElement())
+        innerTextElement()->setScrollLeft(newLeft);
+}
+
+void RenderTextControlSingleLine::setScrollTop(int newTop)
+{
+    if (innerTextElement())
+        innerTextElement()->setScrollTop(newTop);
+}
+
+bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)
+{
+    RenderLayer* layer = innerTextElement()->renderBox()->layer();
+    if (layer && layer->scroll(direction, granularity, multiplier))
+        return true;
+    return RenderBlock::scroll(direction, granularity, multiplier, stopNode);
+}
+
+bool RenderTextControlSingleLine::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)
+{
+    RenderLayer* layer = innerTextElement()->renderBox()->layer();
+    if (layer && layer->scroll(logicalToPhysical(direction, style()->isHorizontalWritingMode(), style()->isFlippedBlocksWritingMode()), granularity, multiplier))
+        return true;
+    return RenderBlock::logicalScroll(direction, granularity, multiplier, stopNode);
+}
+
+PassRefPtr<Scrollbar> RenderTextControlSingleLine::createScrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize)
 {
     RefPtr<Scrollbar> widget;
     bool hasCustomScrollbarStyle = style()->hasPseudoStyle(SCROLLBAR);
@@ -363,23 +752,9 @@ PassRefPtr<Scrollbar> RenderSearchField::createScrollbar(ScrollableArea* scrolla
     return widget.release();
 }
 
-LayoutUnit RenderSearchField::computeHeightLimit() const
-{
-    return height();
-}
-
-void RenderSearchField::centerContainerIfNeeded(RenderBox* containerRenderer) const
+HTMLInputElement* RenderTextControlSingleLine::inputElement() const
 {
-    if (!containerRenderer)
-        return;
-
-    if (containerRenderer->height() <= contentHeight())
-        return;
-
-    // A quirk for find-in-page box on Safari Windows.
-    // http://webkit.org/b/63157
-    LayoutUnit heightDiff = containerRenderer->height() - contentHeight();
-    containerRenderer->setY(containerRenderer->y() - (heightDiff / 2 + layoutMod(heightDiff, 2)));
+    return node()->toInputElement();
 }
 
 }
index 967335d..6e21c85 100644 (file)
  *
  */
 
-#ifndef RenderSearchField_h
-#define RenderSearchField_h
+#ifndef RenderTextControlSingleLine_h
+#define RenderTextControlSingleLine_h
 
 #include "PopupMenuClient.h"
-#include "RenderTextControlSingleLine.h"
+#include "RenderTextControl.h"
 
 namespace WebCore {
 
 class HTMLInputElement;
 class SearchPopupMenu;
 
-class RenderSearchField : public RenderTextControlSingleLine, private PopupMenuClient {
+class RenderTextControlSingleLine : public RenderTextControl, private PopupMenuClient {
 public:
-    RenderSearchField(Node*);
-    virtual ~RenderSearchField();
-
+    RenderTextControlSingleLine(Node*);
+    virtual ~RenderTextControlSingleLine();
+    // FIXME: Move create*Style() to their classes.
+    virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const;
+    PassRefPtr<RenderStyle> createInnerBlockStyle(const RenderStyle* startStyle) const;
     void updateCancelButtonVisibility() const;
 
     void addSearchResult();
@@ -45,12 +47,42 @@ public:
     void showPopup();
     void hidePopup();
 
+    void capsLockStateMayHaveChanged();
+
 private:
-    virtual void centerContainerIfNeeded(RenderBox*) const OVERRIDE;
+    virtual bool hasControlClip() const;
+    virtual LayoutRect controlClipRect(const LayoutPoint&) const;
+    virtual bool isTextField() const { return true; }
+
+    virtual void paint(PaintInfo&, const LayoutPoint&);
+    virtual void layout();
+
+    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
+
+    virtual void autoscroll();
+
+    // Subclassed to forward to our inner div.
+    virtual int scrollLeft() const;
+    virtual int scrollTop() const;
+    virtual int scrollWidth() const;
+    virtual int scrollHeight() const;
+    virtual void setScrollLeft(int);
+    virtual void setScrollTop(int);
+    virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
+    virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
+
+    int textBlockWidth() const;
+    virtual float getAvgCharWidth(AtomicString family);
+    virtual LayoutUnit preferredContentWidth(float charWidth) const;
     virtual LayoutUnit computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE;
-    virtual LayoutUnit computeHeightLimit() const OVERRIDE;
-    virtual void updateFromElement() OVERRIDE;
+    
+    virtual void updateFromElement();
+    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
+
+    virtual RenderStyle* textBaseStyle() const;
+
     EVisibility visibilityForCancelButton() const;
+    bool textShouldBeTruncated() const;
     const AtomicString& autosaveName() const;
 
     // PopupMenuClient methods
@@ -82,22 +114,42 @@ private:
     virtual HostWindow* hostWindow() const OVERRIDE;
     virtual PassRefPtr<Scrollbar> createScrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize) OVERRIDE;
 
+    HTMLInputElement* inputElement() const;
+
+    HTMLElement* containerElement() const;
+    HTMLElement* innerBlockElement() const;
+    HTMLElement* innerSpinButtonElement() const;
     HTMLElement* resultsButtonElement() const;
     HTMLElement* cancelButtonElement() const;
 
     bool m_searchPopupIsVisible;
+    bool m_shouldDrawCapsLockIndicator;
+    LayoutUnit m_desiredInnerTextHeight;
     RefPtr<SearchPopupMenu> m_searchPopup;
     Vector<String> m_recentSearches;
 };
 
-inline RenderSearchField* toRenderSearchField(RenderObject* object)
+inline RenderTextControlSingleLine* toRenderTextControlSingleLine(RenderObject* object)
 {
     ASSERT(!object || object->isTextField());
-    return static_cast<RenderSearchField*>(object);
+    return static_cast<RenderTextControlSingleLine*>(object);
 }
 
 // This will catch anyone doing an unnecessary cast.
-void toRenderSearchField(const RenderSearchField*);
+void toRenderTextControlSingleLine(const RenderTextControlSingleLine*);
+
+// ----------------------------
+
+class RenderTextControlInnerBlock : public RenderBlock {
+public:
+    RenderTextControlInnerBlock(Node* node, bool isMultiLine) : RenderBlock(node), m_multiLine(isMultiLine) { }
+
+private:
+    virtual bool hasLineIfEmpty() const { return true; }
+    virtual VisiblePosition positionForPoint(const LayoutPoint&);
+
+    bool m_multiLine;
+};
 
 }
 
index 31f1f28..848fc21 100644 (file)
@@ -30,6 +30,7 @@
 #include "Frame.h"
 #include "FrameSelection.h"
 #include "FrameView.h"
+#include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HitTestResult.h"
 #include "LocalizedStrings.h"
@@ -38,6 +39,7 @@
 #include "RenderLayer.h"
 #include "RenderScrollbar.h"
 #include "RenderTheme.h"
+#include "SearchPopupMenu.h"
 #include "Settings.h"
 #include "SimpleFontData.h"
 #include "StyleResolver.h"
@@ -68,8 +70,10 @@ VisiblePosition RenderTextControlInnerBlock::positionForPoint(const LayoutPoint&
 
 RenderTextControlSingleLine::RenderTextControlSingleLine(Node* node)
     : RenderTextControl(node)
+    , m_searchPopupIsVisible(false)
     , m_shouldDrawCapsLockIndicator(false)
     , m_desiredInnerTextHeight(-1)
+    , m_searchPopup(0)
 {
     ASSERT(node->isHTMLElement());
     ASSERT(node->toInputElement());
@@ -77,6 +81,20 @@ RenderTextControlSingleLine::RenderTextControlSingleLine(Node* node)
 
 RenderTextControlSingleLine::~RenderTextControlSingleLine()
 {
+    if (m_searchPopup) {
+        m_searchPopup->popupMenu()->disconnectClient();
+        m_searchPopup = 0;
+    }
+}
+
+inline HTMLElement* RenderTextControlSingleLine::containerElement() const
+{
+    return inputElement()->containerElement();
+}
+
+inline HTMLElement* RenderTextControlSingleLine::innerBlockElement() const
+{
+    return inputElement()->innerBlockElement();
 }
 
 inline HTMLElement* RenderTextControlSingleLine::innerSpinButtonElement() const
@@ -84,12 +102,88 @@ inline HTMLElement* RenderTextControlSingleLine::innerSpinButtonElement() const
     return inputElement()->innerSpinButtonElement();
 }
 
+inline HTMLElement* RenderTextControlSingleLine::resultsButtonElement() const
+{
+    return inputElement()->resultsButtonElement();
+}
+
+inline HTMLElement* RenderTextControlSingleLine::cancelButtonElement() const
+{
+    return inputElement()->cancelButtonElement();
+}
+
 RenderStyle* RenderTextControlSingleLine::textBaseStyle() const
 {
     HTMLElement* innerBlock = innerBlockElement();
     return innerBlock ? innerBlock->renderer()->style() : style();
 }
 
+void RenderTextControlSingleLine::addSearchResult()
+{
+    HTMLInputElement* input = inputElement();
+    if (input->maxResults() <= 0)
+        return;
+
+    String value = input->value();
+    if (value.isEmpty())
+        return;
+
+    Settings* settings = document()->settings();
+    if (!settings || settings->privateBrowsingEnabled())
+        return;
+
+    int size = static_cast<int>(m_recentSearches.size());
+    for (int i = size - 1; i >= 0; --i) {
+        if (m_recentSearches[i] == value)
+            m_recentSearches.remove(i);
+    }
+
+    m_recentSearches.insert(0, value);
+    while (static_cast<int>(m_recentSearches.size()) > input->maxResults())
+        m_recentSearches.removeLast();
+
+    const AtomicString& name = autosaveName();
+    if (!m_searchPopup)
+        m_searchPopup = document()->page()->chrome()->createSearchPopupMenu(this);
+
+    m_searchPopup->saveRecentSearches(name, m_recentSearches);
+}
+
+void RenderTextControlSingleLine::showPopup()
+{
+    if (m_searchPopupIsVisible)
+        return;
+
+    if (!m_searchPopup)
+        m_searchPopup = document()->page()->chrome()->createSearchPopupMenu(this);
+
+    if (!m_searchPopup->enabled())
+        return;
+
+    m_searchPopupIsVisible = true;
+
+    const AtomicString& name = autosaveName();
+    m_searchPopup->loadRecentSearches(name, m_recentSearches);
+
+    // Trim the recent searches list if the maximum size has changed since we last saved.
+    HTMLInputElement* input = inputElement();
+    if (static_cast<int>(m_recentSearches.size()) > input->maxResults()) {
+        do {
+            m_recentSearches.removeLast();
+        } while (static_cast<int>(m_recentSearches.size()) > input->maxResults());
+
+        m_searchPopup->saveRecentSearches(name, m_recentSearches);
+    }
+
+    m_searchPopup->popupMenu()->show(pixelSnappedIntRect(absoluteBoundingBoxRect()), document()->view(), -1);
+}
+
+void RenderTextControlSingleLine::hidePopup()
+{
+    if (m_searchPopup)
+        m_searchPopup->popupMenu()->hide();
+}
+
 void RenderTextControlSingleLine::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
     RenderTextControl::paint(paintInfo, paintOffset);
@@ -106,11 +200,6 @@ void RenderTextControlSingleLine::paint(PaintInfo& paintInfo, const LayoutPoint&
     }
 }
 
-LayoutUnit RenderTextControlSingleLine::computeHeightLimit() const
-{
-    return containerElement() ? contentHeight() : height();
-}
-
 void RenderTextControlSingleLine::layout()
 {
     // FIXME: We should remove the height-related hacks in layout() and
@@ -136,7 +225,7 @@ void RenderTextControlSingleLine::layout()
     LayoutUnit desiredHeight = textBlockHeight();
     LayoutUnit currentHeight = innerTextRenderer->height();
 
-    LayoutUnit heightLimit = computeHeightLimit();
+    LayoutUnit heightLimit = (inputElement()->isSearchField() || !container) ? height() : contentHeight();
     if (currentHeight > heightLimit) {
         if (desiredHeight != currentHeight)
             setNeedsLayout(true, MarkOnlyThis);
@@ -169,8 +258,12 @@ void RenderTextControlSingleLine::layout()
     if (!container && currentHeight != contentHeight()) {
         LayoutUnit heightDiff = currentHeight - contentHeight();
         innerTextRenderer->setY(innerTextRenderer->y() - (heightDiff / 2 + layoutMod(heightDiff, 2)));
-    } else
-        centerContainerIfNeeded(containerRenderer);
+    } else if (inputElement()->isSearchField() && containerRenderer && containerRenderer->height() > contentHeight()) {
+        // A quirk for find-in-page box on Safari Windows.
+        // http://webkit.org/b/63157
+        LayoutUnit heightDiff = containerRenderer->height() - contentHeight();
+        containerRenderer->setY(containerRenderer->y() - (heightDiff / 2 + layoutMod(heightDiff, 2)));
+    }
 
     // Ignores the paddings for the inner spin button.
     if (RenderBox* innerSpinBox = innerSpinButtonElement() ? innerSpinButtonElement()->renderBox() : 0) {
@@ -338,12 +431,31 @@ LayoutUnit RenderTextControlSingleLine::preferredContentWidth(float charWidth) c
 
 LayoutUnit RenderTextControlSingleLine::computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
 {
+    HTMLElement* resultsButton = resultsButtonElement();
+    if (RenderBox* resultsRenderer = resultsButton ? resultsButton->renderBox() : 0) {
+        resultsRenderer->computeLogicalHeight();
+        nonContentHeight = max(nonContentHeight, resultsRenderer->borderAndPaddingHeight() + resultsRenderer->marginHeight());
+        lineHeight = max(lineHeight, resultsRenderer->height());
+    }
+    HTMLElement* cancelButton = cancelButtonElement();
+    if (RenderBox* cancelRenderer = cancelButton ? cancelButton->renderBox() : 0) {
+        cancelRenderer->computeLogicalHeight();
+        nonContentHeight = max(nonContentHeight, cancelRenderer->borderAndPaddingHeight() + cancelRenderer->marginHeight());
+        lineHeight = max(lineHeight, cancelRenderer->height());
+    }
+
     return lineHeight + nonContentHeight;
 }
 
 void RenderTextControlSingleLine::updateFromElement()
 {
     RenderTextControl::updateFromElement();
+
+    if (cancelButtonElement())
+        updateCancelButtonVisibility();
+
+    if (m_searchPopupIsVisible)
+        m_searchPopup->popupMenu()->updateFromElement();
 }
 
 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerTextStyle(const RenderStyle* startStyle) const
@@ -384,12 +496,188 @@ PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerBlockStyle(const
     return innerBlockStyle.release();
 }
 
+void RenderTextControlSingleLine::updateCancelButtonVisibility() const
+{
+    RenderObject* cancelButtonRenderer = cancelButtonElement()->renderer();
+    if (!cancelButtonRenderer)
+        return;
+
+    const RenderStyle* curStyle = cancelButtonRenderer->style();
+    EVisibility buttonVisibility = visibilityForCancelButton();
+    if (curStyle->visibility() == buttonVisibility)
+        return;
+
+    RefPtr<RenderStyle> cancelButtonStyle = RenderStyle::clone(curStyle);
+    cancelButtonStyle->setVisibility(buttonVisibility);
+    cancelButtonRenderer->setStyle(cancelButtonStyle);
+}
+
+EVisibility RenderTextControlSingleLine::visibilityForCancelButton() const
+{
+    return (style()->visibility() == HIDDEN || inputElement()->value().isEmpty()) ? HIDDEN : VISIBLE;
+}
+
 bool RenderTextControlSingleLine::textShouldBeTruncated() const
 {
     return document()->focusedNode() != node()
         && style()->textOverflow() == TextOverflowEllipsis;
 }
 
+const AtomicString& RenderTextControlSingleLine::autosaveName() const
+{
+    return static_cast<Element*>(node())->getAttribute(autosaveAttr);
+}
+
+// PopupMenuClient methods
+void RenderTextControlSingleLine::valueChanged(unsigned listIndex, bool fireEvents)
+{
+    ASSERT(static_cast<int>(listIndex) < listSize());
+    HTMLInputElement* input = inputElement();
+    if (static_cast<int>(listIndex) == (listSize() - 1)) {
+        if (fireEvents) {
+            m_recentSearches.clear();
+            const AtomicString& name = autosaveName();
+            if (!name.isEmpty()) {
+                if (!m_searchPopup)
+                    m_searchPopup = document()->page()->chrome()->createSearchPopupMenu(this);
+                m_searchPopup->saveRecentSearches(name, m_recentSearches);
+            }
+        }
+    } else {
+        input->setValue(itemText(listIndex));
+        if (fireEvents)
+            input->onSearch();
+        input->select();
+    }
+}
+
+String RenderTextControlSingleLine::itemText(unsigned listIndex) const
+{
+    int size = listSize();
+    if (size == 1) {
+        ASSERT(!listIndex);
+        return searchMenuNoRecentSearchesText();
+    }
+    if (!listIndex)
+        return searchMenuRecentSearchesText();
+    if (itemIsSeparator(listIndex))
+        return String();
+    if (static_cast<int>(listIndex) == (size - 1))
+        return searchMenuClearRecentSearchesText();
+    return m_recentSearches[listIndex - 1];
+}
+
+String RenderTextControlSingleLine::itemLabel(unsigned) const
+{
+    return String();
+}
+
+String RenderTextControlSingleLine::itemIcon(unsigned) const
+{
+    return String();
+}
+
+bool RenderTextControlSingleLine::itemIsEnabled(unsigned listIndex) const
+{
+     if (!listIndex || itemIsSeparator(listIndex))
+        return false;
+    return true;
+}
+
+PopupMenuStyle RenderTextControlSingleLine::itemStyle(unsigned) const
+{
+    return menuStyle();
+}
+
+PopupMenuStyle RenderTextControlSingleLine::menuStyle() const
+{
+    return PopupMenuStyle(style()->visitedDependentColor(CSSPropertyColor), style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->font(), style()->visibility() == VISIBLE,
+        style()->display() == NONE, style()->textIndent(), style()->direction(), isOverride(style()->unicodeBidi()));
+}
+
+int RenderTextControlSingleLine::clientInsetLeft() const
+{
+    // Inset the menu by the radius of the cap on the left so that
+    // it only runs along the straight part of the bezel.
+    return height() / 2;
+}
+
+int RenderTextControlSingleLine::clientInsetRight() const
+{
+    // Inset the menu by the radius of the cap on the right so that
+    // it only runs along the straight part of the bezel (unless it needs
+    // to be wider).
+    return height() / 2;
+}
+
+LayoutUnit RenderTextControlSingleLine::clientPaddingLeft() const
+{
+    LayoutUnit padding = paddingLeft();
+    if (RenderBox* box = innerBlockElement() ? innerBlockElement()->renderBox() : 0)
+        padding += box->x();
+    return padding;
+}
+
+LayoutUnit RenderTextControlSingleLine::clientPaddingRight() const
+{
+    LayoutUnit padding = paddingRight();
+    if (RenderBox* containerBox = containerElement() ? containerElement()->renderBox() : 0) {
+        if (RenderBox* innerBlockBox = innerBlockElement() ? innerBlockElement()->renderBox() : 0)
+            padding += containerBox->width() - (innerBlockBox->x() + innerBlockBox->width());
+    }
+    return padding;
+}
+
+int RenderTextControlSingleLine::listSize() const
+{
+    // If there are no recent searches, then our menu will have 1 "No recent searches" item.
+    if (!m_recentSearches.size())
+        return 1;
+    // Otherwise, leave room in the menu for a header, a separator, and the "Clear recent searches" item.
+    return m_recentSearches.size() + 3;
+}
+
+int RenderTextControlSingleLine::selectedIndex() const
+{
+    return -1;
+}
+
+void RenderTextControlSingleLine::popupDidHide()
+{
+    m_searchPopupIsVisible = false;
+}
+
+bool RenderTextControlSingleLine::itemIsSeparator(unsigned listIndex) const
+{
+    // The separator will be the second to last item in our list.
+    return static_cast<int>(listIndex) == (listSize() - 2);
+}
+
+bool RenderTextControlSingleLine::itemIsLabel(unsigned listIndex) const
+{
+    return listIndex == 0;
+}
+
+bool RenderTextControlSingleLine::itemIsSelected(unsigned) const
+{
+    return false;
+}
+
+void RenderTextControlSingleLine::setTextFromItem(unsigned listIndex)
+{
+    inputElement()->setValue(itemText(listIndex));
+}
+
+FontSelector* RenderTextControlSingleLine::fontSelector() const
+{
+    return document()->styleResolver()->fontSelector();
+}
+
+HostWindow* RenderTextControlSingleLine::hostWindow() const
+{
+    return document()->view()->hostWindow();
+}
+
 void RenderTextControlSingleLine::autoscroll()
 {
     RenderLayer* layer = innerTextElement()->renderBox()->layer();
@@ -453,6 +741,17 @@ bool RenderTextControlSingleLine::logicalScroll(ScrollLogicalDirection direction
     return RenderBlock::logicalScroll(direction, granularity, multiplier, stopNode);
 }
 
+PassRefPtr<Scrollbar> RenderTextControlSingleLine::createScrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, ScrollbarControlSize controlSize)
+{
+    RefPtr<Scrollbar> widget;
+    bool hasCustomScrollbarStyle = style()->hasPseudoStyle(SCROLLBAR);
+    if (hasCustomScrollbarStyle)
+        widget = RenderScrollbar::createCustomScrollbar(scrollableArea, orientation, this->node());
+    else
+        widget = Scrollbar::createNativeScrollbar(scrollableArea, orientation, controlSize);
+    return widget.release();
+}
+
 HTMLInputElement* RenderTextControlSingleLine::inputElement() const
 {
     return node()->toInputElement();
index ffc50a3..6e21c85 100644 (file)
 #ifndef RenderTextControlSingleLine_h
 #define RenderTextControlSingleLine_h
 
-#include "HTMLInputElement.h"
+#include "PopupMenuClient.h"
 #include "RenderTextControl.h"
 
 namespace WebCore {
 
 class HTMLInputElement;
+class SearchPopupMenu;
 
-class RenderTextControlSingleLine : public RenderTextControl {
+class RenderTextControlSingleLine : public RenderTextControl, private PopupMenuClient {
 public:
     RenderTextControlSingleLine(Node*);
     virtual ~RenderTextControlSingleLine();
     // FIXME: Move create*Style() to their classes.
     virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const;
     PassRefPtr<RenderStyle> createInnerBlockStyle(const RenderStyle* startStyle) const;
+    void updateCancelButtonVisibility() const;
 
-    void capsLockStateMayHaveChanged();
+    void addSearchResult();
+    void stopSearchEventTimer();
 
-protected:
-    virtual void centerContainerIfNeeded(RenderBox*) const { }
-    virtual LayoutUnit computeHeightLimit() const;
-    HTMLElement* containerElement() const;
-    HTMLElement* innerBlockElement() const;
-    HTMLInputElement* inputElement() const;
-    virtual void updateFromElement() OVERRIDE;
+    bool popupIsVisible() const { return m_searchPopupIsVisible; }
+    void showPopup();
+    void hidePopup();
+
+    void capsLockStateMayHaveChanged();
 
 private:
     virtual bool hasControlClip() const;
@@ -75,28 +76,59 @@ private:
     virtual LayoutUnit preferredContentWidth(float charWidth) const;
     virtual LayoutUnit computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE;
     
+    virtual void updateFromElement();
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
 
     virtual RenderStyle* textBaseStyle() const;
 
+    EVisibility visibilityForCancelButton() const;
     bool textShouldBeTruncated() const;
+    const AtomicString& autosaveName() const;
+
+    // PopupMenuClient methods
+    virtual void valueChanged(unsigned listIndex, bool fireEvents = true) OVERRIDE;
+    virtual void selectionChanged(unsigned, bool) OVERRIDE { }
+    virtual void selectionCleared() OVERRIDE { }
+    virtual String itemText(unsigned listIndex) const OVERRIDE;
+    virtual String itemLabel(unsigned listIndex) const OVERRIDE;
+    virtual String itemIcon(unsigned listIndex) const OVERRIDE;
+    virtual String itemToolTip(unsigned) const OVERRIDE { return String(); }
+    virtual String itemAccessibilityText(unsigned) const OVERRIDE { return String(); }
+    virtual bool itemIsEnabled(unsigned listIndex) const OVERRIDE;
+    virtual PopupMenuStyle itemStyle(unsigned listIndex) const OVERRIDE;
+    virtual PopupMenuStyle menuStyle() const OVERRIDE;
+    virtual int clientInsetLeft() const OVERRIDE;
+    virtual int clientInsetRight() const OVERRIDE;
+    virtual LayoutUnit clientPaddingLeft() const OVERRIDE;
+    virtual LayoutUnit clientPaddingRight() const OVERRIDE;
+    virtual int listSize() const OVERRIDE;
+    virtual int selectedIndex() const OVERRIDE;
+    virtual void popupDidHide() OVERRIDE;
+    virtual bool itemIsSeparator(unsigned listIndex) const OVERRIDE;
+    virtual bool itemIsLabel(unsigned listIndex) const OVERRIDE;
+    virtual bool itemIsSelected(unsigned listIndex) const OVERRIDE;
+    virtual bool shouldPopOver() const OVERRIDE { return false; }
+    virtual bool valueShouldChangeOnHotTrack() const OVERRIDE { return false; }
+    virtual void setTextFromItem(unsigned listIndex) OVERRIDE;
+    virtual FontSelector* fontSelector() const OVERRIDE;
+    virtual HostWindow* hostWindow() const OVERRIDE;
+    virtual PassRefPtr<Scrollbar> createScrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize) OVERRIDE;
+
+    HTMLInputElement* inputElement() const;
 
+    HTMLElement* containerElement() const;
+    HTMLElement* innerBlockElement() const;
     HTMLElement* innerSpinButtonElement() const;
+    HTMLElement* resultsButtonElement() const;
+    HTMLElement* cancelButtonElement() const;
 
+    bool m_searchPopupIsVisible;
     bool m_shouldDrawCapsLockIndicator;
     LayoutUnit m_desiredInnerTextHeight;
+    RefPtr<SearchPopupMenu> m_searchPopup;
+    Vector<String> m_recentSearches;
 };
 
-inline HTMLElement* RenderTextControlSingleLine::containerElement() const
-{
-    return inputElement()->containerElement();
-}
-
-inline HTMLElement* RenderTextControlSingleLine::innerBlockElement() const
-{
-    return inputElement()->innerBlockElement();
-}
-
 inline RenderTextControlSingleLine* toRenderTextControlSingleLine(RenderObject* object)
 {
     ASSERT(!object || object->isTextField());
index 1f0a4a3..d17bd31 100644 (file)
@@ -91,7 +91,6 @@
 #include "RenderScrollbar.cpp"
 #include "RenderScrollbarPart.cpp"
 #include "RenderScrollbarTheme.cpp"
-#include "RenderSearchField.cpp"
 #include "RenderSlider.cpp"
 #include "RenderTable.cpp"
 #include "RenderTableCaption.cpp"