Changeset 69495 in webkit


Ignore:
Timestamp:
Oct 11, 2010 8:24:11 AM (14 years ago)
Author:
Martin Robinson
Message:

2010-10-11 Martin Robinson <mrobinson@igalia.com>

Reviewed by Xan Lopez.

[GTK] Search field icons should be centered vertically in the field
https://bugs.webkit.org/show_bug.cgi?id=47441

Add a pixel dump result which tests the fix.

  • platform/gtk/fast/css/text-input-with-webkit-border-radius-expected.checksum: Added.
  • platform/gtk/fast/css/text-input-with-webkit-border-radius-expected.png: Added.

2010-10-11 Martin Robinson <mrobinson@igalia.com>

Reviewed by Xan Lopez.

[GTK] Search field icons should be centered vertically in the field
https://bugs.webkit.org/show_bug.cgi?id=47441

Center search field icons vertically in the search field.

  • platform/gtk/RenderThemeGtk.cpp: (WebCore::centerRectVerticallyInParentInputElement): Added this helper. (WebCore::RenderThemeGtk::paintSearchFieldResultsDecoration): Center the search field icon by adjusting its drawing rect relative to the containing search field. (WebCore::RenderThemeGtk::paintSearchFieldCancelButton): Ditto.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r69489 r69495  
     12010-10-11  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] Search field icons should be centered vertically in the field
     6        https://bugs.webkit.org/show_bug.cgi?id=47441
     7
     8        Add a pixel dump result which tests the fix.
     9
     10        * platform/gtk/fast/css/text-input-with-webkit-border-radius-expected.checksum: Added.
     11        * platform/gtk/fast/css/text-input-with-webkit-border-radius-expected.png: Added.
     12
    1132010-10-10  Antonio Gomes  <agomes@rim.com>
    214
  • trunk/WebCore/ChangeLog

    r69494 r69495  
     12010-10-11  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] Search field icons should be centered vertically in the field
     6        https://bugs.webkit.org/show_bug.cgi?id=47441
     7
     8        Center search field icons vertically in the search field.
     9
     10        * platform/gtk/RenderThemeGtk.cpp:
     11        (WebCore::centerRectVerticallyInParentInputElement): Added this helper.
     12        (WebCore::RenderThemeGtk::paintSearchFieldResultsDecoration): Center the search
     13        field icon by adjusting its drawing rect relative to the containing search field.
     14        (WebCore::RenderThemeGtk::paintSearchFieldCancelButton): Ditto.
     15
    1162010-10-11  Pavel Podivilov  <podivilov@chromium.org>
    217
  • trunk/WebCore/platform/gtk/RenderThemeGtk.cpp

    r69447 r69495  
    499499}
    500500
    501 bool RenderThemeGtk::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& i, const IntRect& rect)
    502 {
    503     GraphicsContext* context = i.context;
    504 
     501static IntRect centerRectVerticallyInParentInputElement(RenderObject* object, const IntRect& rect)
     502{
     503    IntRect centeredRect(rect);
     504    Node* input = object->node()->shadowAncestorNode(); // Get the renderer of <input> element.
     505    if (!input->renderer()->isBox())
     506        return centeredRect;
     507
     508    // If possible center the y-coordinate of the rect vertically in the parent input element.
     509    // We also add one pixel here to ensure that the y coordinate is rounded up for box heights
     510    // that are even, which looks in relation to the box text.
     511    IntRect inputContentBox = toRenderBox(input->renderer())->absoluteContentBox();
     512    centeredRect.setY(inputContentBox.y() + (inputContentBox.height() - centeredRect.height() + 1) / 2);
     513    return centeredRect;
     514}
     515
     516bool RenderThemeGtk::paintSearchFieldResultsDecoration(RenderObject* object, const PaintInfo& i, const IntRect& rect)
     517{
    505518    static Image* searchImage = Image::loadPlatformThemeIcon(GTK_STOCK_FIND, rect.width()).releaseRef();
    506     context->drawImage(searchImage, DeviceColorSpace, rect);
    507 
     519    IntRect centeredRect(centerRectVerticallyInParentInputElement(object, rect));
     520    i.context->drawImage(searchImage, DeviceColorSpace, centeredRect);
    508521    return false;
    509522}
     
    520533}
    521534
    522 bool RenderThemeGtk::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& i, const IntRect& rect)
    523 {
    524     GraphicsContext* context = i.context;
    525 
     535bool RenderThemeGtk::paintSearchFieldCancelButton(RenderObject* object, const PaintInfo& i, const IntRect& rect)
     536{
    526537    // TODO: Brightening up the image on hover is desirable here, I believe.
    527538    static Image* cancelImage = Image::loadPlatformThemeIcon(GTK_STOCK_CLEAR, rect.width()).releaseRef();
    528     context->drawImage(cancelImage, DeviceColorSpace, rect);
    529 
     539    IntRect centeredRect(centerRectVerticallyInParentInputElement(object, rect));
     540    i.context->drawImage(cancelImage, DeviceColorSpace, centeredRect);
    530541    return false;
    531542}
Note: See TracChangeset for help on using the changeset viewer.