Bug 23335 - Update <input type="search"> for RenderThemeWin
Summary: Update <input type="search"> for RenderThemeWin
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows Vista
: P2 Normal
Assignee: Adele Peterson
Depends on:
Reported: 2009-01-14 17:14 PST by Adele Peterson
Modified: 2009-01-14 18:05 PST (History)
0 users

See Also:

patch (24.57 KB, patch)
2009-01-14 17:22 PST, Adele Peterson
adele: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adele Peterson 2009-01-14 17:14:20 PST
Update <input type="search"> for RenderThemeWin
Comment 1 Adele Peterson 2009-01-14 17:22:45 PST
Created attachment 26739 [details]
Comment 2 Darin Adler 2009-01-14 17:34:18 PST
Comment on attachment 26739 [details]

> +static const float defaultCancelButtonSize = 9.0f;
> +static const float minCancelButtonSize = 5.0f;
> +static const float maxCancelButtonSize = 21.0f;
> +static const float defaultSearchFieldResultsDecorationSize = 13.0f;
> +static const float minSearchFieldResultsDecorationSize = 9.0f;
> +static const float maxSearchFieldResultsDecorationSize = 30.0f;
> +static const float defaultSearchFieldResultsButtonWidth = 18.0f;

The .0f suffixes don't add anything. I suggest just leaving them out.

> +using std::min;
> +using std::max;

Normally I use "using namespace std" unless there's some reason I want only certain symbols.

> +    bounds.setWidth(min(parentBox.width(), bounds.height()));

I think you mean bounds.width, not bounds.height.

> +    // Center the button vertically.  Round up though, so if it has to be one pixel off-center, it will
> +    // be one pixel closer to the bottom of the field.  This tends to look better with the text.
> +    bounds.setY(parentBox.y() + ceil(static_cast<float>(parentBox.height()) / 2.0f - static_cast<float>(bounds.height()) / 2.0f));

To do ceil on a float, you want ceilf, not ceil, which takes a double.

The 2.0f is sufficient to get the math done as float -- you don't have to cast to float explicitly.

> +    DEFINE_STATIC_LOCAL(RefPtr<Image>, cancelImage, (Image::loadPlatformResource("searchCancel")));
> +    DEFINE_STATIC_LOCAL(RefPtr<Image>, cancelPressedImage, (Image::loadPlatformResource("searchCancelPressed")));

Since we just want to leak these images, maybe we should just have the initialization expression do a releaseRef() and make the globals be Image*. Then you could use a plain old static instead of DEFINE_STATIC_LOCAL. I'm not sure what the best style is for these.

> +    int magnifierSize = roundf(min(max(minSearchFieldResultsDecorationSize, defaultSearchFieldResultsDecorationSize * fontScale), 
> +                                     maxSearchFieldResultsDecorationSize));

Since you want an integer result, maybe this should be lroundf instead of roundf, which gives a float result.

> +    bounds.setWidth(min(parentBox.width(), bounds.height()));

Same height/width comment.

> +    bounds.setY(parentBox.y() + ceil(static_cast<float>(parentBox.height()) / 2.0f - static_cast<float>(bounds.height()) / 2.0f));

Same cast to float comment.

> +    DEFINE_STATIC_LOCAL(RefPtr<Image>, magnifierImage, (Image::loadPlatformResource("searchMagnifier")));

Same releaseRef comment.

Nothing more except the same comments over again since these issues affect multiple functions.
Comment 3 Adele Peterson 2009-01-14 18:03:39 PST
Comment on attachment 26739 [details]

Darin came by and reviewed a revised version in person
Comment 4 Adele Peterson 2009-01-14 18:05:39 PST
Committed revision 39924.