<input type="search"> doesn't correctly handle the "size" attribute
authorgraouts@apple.com <graouts@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Aug 2013 14:58:09 +0000 (14:58 +0000)
committergraouts@apple.com <graouts@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Aug 2013 14:58:09 +0000 (14:58 +0000)
commita69b68314fab51db31dc6b4684c312ec0c25116d
tree4e5e6e582043ae11182bad0829e867eb24ad0d0b
parent01edc7b6eabd902cdaf82f599e5d9b488b667958
<input type="search"> doesn't correctly handle the "size" attribute
https://bugs.webkit.org/show_bug.cgi?id=119174

Source/WebCore:

We weren't taking into account the decorations for search fields (results and close buttons)
when computing the preferred logical width for these fields based on the "size" attribute
and as a result we would not guarantee that we could show the number of characters set by
the "size" attribute.

To make the process of reporting extra width due to decorations cleaner, we add a new decorationWidth()
method for InputType subclasses to override and called through HTMLInputElement::decorationWidth()
and have NumberInputType and SearchInputType return custom decoration widths.

Reviewed by Darin Adler.

Test: fast/forms/search/search-size-with-decorations.html

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::decorationWidth):
* html/HTMLInputElement.h:
* html/InputType.cpp:
(WebCore::InputType::decorationWidth):
* html/InputType.h:
Expose a new method to get the width for the input's decoration through the InputType.

* html/NumberInputType.cpp:
(WebCore::NumberInputType::decorationWidth):
* html/NumberInputType.h:
Override InputType::decorationWidth() to return the decoration width for a number input
using the same code previously used in RenderTextControlSingleLine::preferredContentLogicalWidth().

* html/SearchInputType.cpp:
(WebCore::SearchInputType::sizeShouldIncludeDecoration):
Override InputType::sizeShouldIncludeDecoration() to return true since search fields
have custom decoration adding to the size of the field.

(WebCore::SearchInputType::decorationWidth):
Return the combined size of the results and cancel buttons, as available.
* html/SearchInputType.h:

* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::preferredContentLogicalWidth):
Remove the code specific to NumberInputType (which was moved to InputType::decorationWidth())
and replace it with a call to HTMLInputElement::decorationWidth() since this method will now
return the extra decoration width for an input element should it have any.

LayoutTests:

New test fast/forms/search/search-size-with-decorations.html that checks the different
decorations for search fields and the resulting sizes.

Also rebaselining the following tests since the rendering of search fields changed:

fast/forms/search-cancel-button-style-sharing.html
fast/forms/search-display-none-cancel-button.html
fast/forms/searchfield-heights.html
fast/forms/control-restrict-line-height.html
fast/forms/placeholder-pseudo-style.html
fast/forms/search-rtl.html
fast/css/text-overflow-input.html
fast/forms/placeholder-position.html
fast/repaint/search-field-cancel.html
fast/forms/input-appearance-height.html
fast/forms/search-vertical-alignment.html
fast/forms/box-shadow-override.html
fast/forms/search/search-size-with-decorations.html
fast/css/input-search-padding.html
fast/forms/search-styled.html

Reviewed by Darin Adler.

* fast/forms/placeholder-position-expected.txt:
* fast/forms/search/search-size-with-decorations-expected.txt: Added.
* fast/forms/search/search-size-with-decorations.html: Added.
* fast/repaint/search-field-cancel-expected.txt:
* platform/mac/fast/css/input-search-padding-expected.txt:
* platform/mac/fast/css/text-overflow-input-expected.png:
* platform/mac/fast/css/text-overflow-input-expected.txt:
* platform/mac/fast/forms/box-shadow-override-expected.png:
* platform/mac/fast/forms/box-shadow-override-expected.txt:
* platform/mac/fast/forms/control-restrict-line-height-expected.png:
* platform/mac/fast/forms/control-restrict-line-height-expected.txt:
* platform/mac/fast/forms/input-appearance-height-expected.png:
* platform/mac/fast/forms/input-appearance-height-expected.txt:
* platform/mac/fast/forms/placeholder-position-expected.png:
* platform/mac/fast/forms/placeholder-pseudo-style-expected.png:
* platform/mac/fast/forms/placeholder-pseudo-style-expected.txt:
* platform/mac/fast/forms/search-cancel-button-style-sharing-expected.png:
* platform/mac/fast/forms/search-cancel-button-style-sharing-expected.txt:
* platform/mac/fast/forms/search-display-none-cancel-button-expected.txt:
* platform/mac/fast/forms/search-rtl-expected.png:
* platform/mac/fast/forms/search-rtl-expected.txt:
* platform/mac/fast/forms/search-styled-expected.txt:
* platform/mac/fast/forms/search-vertical-alignment-expected.png:
* platform/mac/fast/forms/search-vertical-alignment-expected.txt:
* platform/mac/fast/forms/search/search-size-with-decorations-expected.png: Added.
* platform/mac/fast/forms/searchfield-heights-expected.png:
* platform/mac/fast/forms/searchfield-heights-expected.txt:
* platform/mac/fast/repaint/search-field-cancel-expected.png:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153647 268f45cc-cd09-0410-ab3c-d52691b4dbfc
39 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/placeholder-position-expected.txt
LayoutTests/fast/forms/search/search-size-with-decorations-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/search/search-size-with-decorations.html [new file with mode: 0644]
LayoutTests/fast/repaint/search-field-cancel-expected.txt
LayoutTests/platform/mac/fast/css/input-search-padding-expected.txt
LayoutTests/platform/mac/fast/css/text-overflow-input-expected.png
LayoutTests/platform/mac/fast/css/text-overflow-input-expected.txt
LayoutTests/platform/mac/fast/forms/box-shadow-override-expected.png
LayoutTests/platform/mac/fast/forms/box-shadow-override-expected.txt
LayoutTests/platform/mac/fast/forms/control-restrict-line-height-expected.png
LayoutTests/platform/mac/fast/forms/control-restrict-line-height-expected.txt
LayoutTests/platform/mac/fast/forms/input-appearance-height-expected.png
LayoutTests/platform/mac/fast/forms/input-appearance-height-expected.txt
LayoutTests/platform/mac/fast/forms/placeholder-position-expected.png
LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.png
LayoutTests/platform/mac/fast/forms/placeholder-pseudo-style-expected.txt
LayoutTests/platform/mac/fast/forms/search-cancel-button-style-sharing-expected.png
LayoutTests/platform/mac/fast/forms/search-cancel-button-style-sharing-expected.txt
LayoutTests/platform/mac/fast/forms/search-display-none-cancel-button-expected.txt
LayoutTests/platform/mac/fast/forms/search-rtl-expected.png
LayoutTests/platform/mac/fast/forms/search-rtl-expected.txt
LayoutTests/platform/mac/fast/forms/search-styled-expected.txt
LayoutTests/platform/mac/fast/forms/search-vertical-alignment-expected.png
LayoutTests/platform/mac/fast/forms/search-vertical-alignment-expected.txt
LayoutTests/platform/mac/fast/forms/search/search-size-with-decorations-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/searchfield-heights-expected.png
LayoutTests/platform/mac/fast/forms/searchfield-heights-expected.txt
LayoutTests/platform/mac/fast/repaint/search-field-cancel-expected.png
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/html/NumberInputType.cpp
Source/WebCore/html/NumberInputType.h
Source/WebCore/html/SearchInputType.cpp
Source/WebCore/html/SearchInputType.h
Source/WebCore/rendering/RenderTextControlSingleLine.cpp