2011-02-04 Carlos Garcia Campos <cgarcia@igalia.com>
authormrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Feb 2011 03:37:22 +0000 (03:37 +0000)
committermrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Feb 2011 03:37:22 +0000 (03:37 +0000)
        Reviewed by Martin Robinson.

        Update expected results reflecting the change to search icon rendering.

        * platform/gtk/fast/css/input-search-padding-expected.checksum:
        * platform/gtk/fast/css/input-search-padding-expected.png:
        * platform/gtk/fast/css/input-search-padding-expected.txt:
        * platform/gtk/fast/forms/search-styled-expected.checksum:
        * platform/gtk/fast/forms/search-styled-expected.png:
        * platform/gtk/fast/forms/search-styled-expected.txt:
        * platform/gtk/fast/forms/search-vertical-alignment-expected.checksum:
        * platform/gtk/fast/forms/search-vertical-alignment-expected.png:
        * platform/gtk/fast/forms/search-zoomed-expected.checksum:
        * platform/gtk/fast/forms/search-zoomed-expected.png:
        * platform/gtk/fast/forms/search-zoomed-expected.txt:
        * platform/gtk/fast/forms/searchfield-heights-expected.checksum:
        * platform/gtk/fast/forms/searchfield-heights-expected.png:
        * platform/gtk/fast/forms/searchfield-heights-expected.txt:
2011-02-04  Carlos Garcia Campos  <cgarcia@igalia.com>

        Reviewed by Martin Robinson.

        [GTK] Don't use a fixed size for search field icons
        https://bugs.webkit.org/show_bug.cgi?id=50624

        Use the parent input content box to make sure the icon fits in the
        search field, scaling it down when needed.

        * platform/gtk/RenderThemeGtk.cpp:
        (WebCore::paintGdkPixbuf):
        (WebCore::getIconSizeForPixelSize):
        (WebCore::adjustSearchFieldIconStyle):
        (WebCore::RenderThemeGtk::adjustSearchFieldResultsDecorationStyle):
        (WebCore::centerRectVerticallyInParentInputElement):
        (WebCore::RenderThemeGtk::paintSearchFieldResultsDecoration):
        (WebCore::RenderThemeGtk::adjustSearchFieldCancelButtonStyle):
        (WebCore::RenderThemeGtk::paintSearchFieldCancelButton):
        (WebCore::RenderThemeGtk::paintCapsLockIndicator):
        (WebCore::RenderThemeGtk::paintMediaButton):

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

17 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/gtk/fast/css/input-search-padding-expected.checksum
LayoutTests/platform/gtk/fast/css/input-search-padding-expected.png
LayoutTests/platform/gtk/fast/css/input-search-padding-expected.txt
LayoutTests/platform/gtk/fast/forms/search-styled-expected.checksum
LayoutTests/platform/gtk/fast/forms/search-styled-expected.png
LayoutTests/platform/gtk/fast/forms/search-styled-expected.txt
LayoutTests/platform/gtk/fast/forms/search-vertical-alignment-expected.checksum
LayoutTests/platform/gtk/fast/forms/search-vertical-alignment-expected.png
LayoutTests/platform/gtk/fast/forms/search-zoomed-expected.checksum
LayoutTests/platform/gtk/fast/forms/search-zoomed-expected.png
LayoutTests/platform/gtk/fast/forms/search-zoomed-expected.txt
LayoutTests/platform/gtk/fast/forms/searchfield-heights-expected.checksum
LayoutTests/platform/gtk/fast/forms/searchfield-heights-expected.png
LayoutTests/platform/gtk/fast/forms/searchfield-heights-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/gtk/RenderThemeGtk.cpp

index fd6223c3600c7bfdda3a508a788c508981d77d57..f997d08cc7b13b30738e877520ee4d66a1605a1e 100644 (file)
@@ -1,3 +1,24 @@
+2011-02-04  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        Update expected results reflecting the change to search icon rendering.
+
+        * platform/gtk/fast/css/input-search-padding-expected.checksum:
+        * platform/gtk/fast/css/input-search-padding-expected.png:
+        * platform/gtk/fast/css/input-search-padding-expected.txt:
+        * platform/gtk/fast/forms/search-styled-expected.checksum:
+        * platform/gtk/fast/forms/search-styled-expected.png:
+        * platform/gtk/fast/forms/search-styled-expected.txt:
+        * platform/gtk/fast/forms/search-vertical-alignment-expected.checksum:
+        * platform/gtk/fast/forms/search-vertical-alignment-expected.png:
+        * platform/gtk/fast/forms/search-zoomed-expected.checksum:
+        * platform/gtk/fast/forms/search-zoomed-expected.png:
+        * platform/gtk/fast/forms/search-zoomed-expected.txt:
+        * platform/gtk/fast/forms/searchfield-heights-expected.checksum:
+        * platform/gtk/fast/forms/searchfield-heights-expected.png:
+        * platform/gtk/fast/forms/searchfield-heights-expected.txt:
+
 2011-02-04  Hironori Bono  <hbono@chromium.org>
 
         Reviewed by Adam Barth.
index 84b3201ec492b5e1ec5567a8e8b674fd5050d4ab..999a9ff380d02c56fbf3cf2eb8b8f8b55c4dc483 100644 (file)
@@ -1 +1 @@
-e7bb0679f2e1a99c7c72620a135cff11
\ No newline at end of file
+434a7e234ff944aad09f6f46b099b448
\ No newline at end of file
index 91eeba021fb944676eb9cf35421f783e31401b2b..0f8fd35cc2ef5181d91db3d9f6a4c6268dc79193 100644 (file)
Binary files a/LayoutTests/platform/gtk/fast/css/input-search-padding-expected.png and b/LayoutTests/platform/gtk/fast/css/input-search-padding-expected.png differ
index a9002e5cf8ff2b460c12d86a2144d573fa91118f..58cb308bddd5a92bc513f441bebb50c34edcba12 100644 (file)
@@ -6,23 +6,23 @@ layer at (0,0) size 800x600
       RenderTextControl {INPUT} at (2,2) size 463x81 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
         RenderBlock {DIV} at (3,17) size 457x46
           RenderBlock {DIV} at (0,37) size 0x0
-          RenderBlock {DIV} at (441,21) size 16x16
+          RenderBlock {DIV} at (425,5) size 32x32
       RenderBR {BR} at (467,85) size 0x0
       RenderTextControl {INPUT} at (2,87) size 463x81 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
       RenderBR {BR} at (467,170) size 0x0
       RenderTextControl {INPUT} at (2,170) size 242x25 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
-        RenderBlock {DIV} at (6,0) size 230x24
-          RenderBlock {DIV} at (0,19) size 0x0
-          RenderBlock {DIV} at (214,3) size 16x16
-layer at (13,27) size 441x46
-  RenderBlock {DIV} at (0,0) size 441x46
+        RenderBlock {DIV} at (6,6) size 230x25
+          RenderBlock {DIV} at (0,20) size 0x0
+          RenderBlock {DIV} at (210,0) size 20x20
+layer at (13,27) size 425x46
+  RenderBlock {DIV} at (0,0) size 425x46
     RenderText {#text} at (1,0) size 362x46
       text run at (1,0) width 362: "value jgq not clipped"
 layer at (13,112) size 457x46
   RenderBlock {DIV} at (3,17) size 457x46
     RenderText {#text} at (1,0) size 362x46
       text run at (1,0) width 362: "value jgq not clipped"
-layer at (16,178) size 214x24
-  RenderBlock {DIV} at (0,0) size 214x24
+layer at (16,185) size 210x24
+  RenderBlock {DIV} at (0,1) size 210x24
     RenderText {#text} at (1,0) size 118x24
       text run at (1,0) width 118: "Sample Input"
index 2823a5bb8c20c165a4db28415b36e941d032e899..6fb3c95cdef5c7d4ae94a130ed637d49b2b96777 100644 (file)
@@ -1 +1 @@
-86e13189d4c16b16f9165d003d6438b9
\ No newline at end of file
+9aab6590917dd4dad4e655cd51741e54
\ No newline at end of file
index 7a5f98175f50a049f53750689072469c95565552..b8581d1759e40f4e0292dbcb7babad1207e4a9ec 100644 (file)
Binary files a/LayoutTests/platform/gtk/fast/forms/search-styled-expected.png and b/LayoutTests/platform/gtk/fast/forms/search-styled-expected.png differ
index acc3095c652af7812cb36ce64913d26341f9b869..0e300c7d554b3e12eff31d77cd45494609135cf1 100644 (file)
@@ -1,12 +1,12 @@
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
-layer at (0,0) size 800x44
-  RenderBlock {HTML} at (0,0) size 800x44
-    RenderBody {BODY} at (8,8) size 784x28
-      RenderTextControl {INPUT} at (2,2) size 148x24 [bgcolor=#FFFFFF] [border: (1px solid #BDC7D8)]
-        RenderBlock {DIV} at (18,2) size 126x19
-          RenderBlock {DIV} at (0,0) size 16x16
-          RenderBlock {DIV} at (110,0) size 16x16
+layer at (0,0) size 800x41
+  RenderBlock {HTML} at (0,0) size 800x41
+    RenderBody {BODY} at (8,8) size 784x25
+      RenderTextControl {INPUT} at (2,2) size 148x21 [bgcolor=#FFFFFF] [border: (1px solid #BDC7D8)]
+        RenderBlock {DIV} at (18,3) size 126x14
+          RenderBlock {DIV} at (0,0) size 11x11
+          RenderBlock {DIV} at (115,0) size 11x11
       RenderText {#text} at (0,0) size 0x0
-layer at (44,18) size 94x13
-  RenderBlock {DIV} at (16,6) size 94x13
+layer at (39,14) size 104x13
+  RenderBlock {DIV} at (11,1) size 104x13
index 823efdd2a7bfecb7f287ba41b7a34a4ac80e0ac0..7e4a8e262372c657599296d5221e23952ff7674c 100644 (file)
@@ -1 +1 @@
-f55e3b1bddaab3e264f8d67a78d546a6
\ No newline at end of file
+5a567c9dfcbcaebaf1b4f7aad43f4eaa
\ No newline at end of file
index 0c165bb269ba461a8acc963795aea941f0508c56..53710223fc75eb02f432a5cfeed9f4824b4e9d20 100644 (file)
Binary files a/LayoutTests/platform/gtk/fast/forms/search-vertical-alignment-expected.png and b/LayoutTests/platform/gtk/fast/forms/search-vertical-alignment-expected.png differ
index 020e44784d8bc22a1dc918ebd68879aa6c3362ab..50a5b0964a6ea433667060b75187986a50a5660e 100644 (file)
@@ -1 +1 @@
-a97ebb8a8534c65a1678ea894d901a91
\ No newline at end of file
+f9fbb41d054efa505ba7f5b6177040c2
\ No newline at end of file
index 0a0e4d27b12d881215704f7b7bb07c0391b35f6e..f0e561575c6809243097fe4196c597564c69b86a 100644 (file)
Binary files a/LayoutTests/platform/gtk/fast/forms/search-zoomed-expected.png and b/LayoutTests/platform/gtk/fast/forms/search-zoomed-expected.png differ
index 3918ff71bcd8e20ce41b9b85759dfe3d570e408c..779e79db18adeb3004978b76ecb3266cd43d118e 100644 (file)
@@ -17,14 +17,14 @@ layer at (0,0) size 800x600
       RenderBlock {P} at (0,63) size 782x33
         RenderTextControl {INPUT} at (2,2) size 235x29 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
           RenderBlock {DIV} at (3,3) size 229x23
-            RenderBlock {DIV} at (0,2) size 16x16
-            RenderBlock {DIV} at (213,2) size 16x16
+            RenderBlock {DIV} at (0,0) size 18x18
+            RenderBlock {DIV} at (211,0) size 18x18
         RenderText {#text} at (0,0) size 0x0
       RenderBlock {P} at (0,168) size 782x22
         RenderText {#text} at (0,0) size 47x22
           text run at (0,0) width 47: "PASS"
-layer at (30,77) size 197x23
-  RenderBlock {DIV} at (16,0) size 197x23
+layer at (32,77) size 193x23
+  RenderBlock {DIV} at (18,0) size 193x23
     RenderText {#text} at (1,0) size 136x23
       text run at (1,0) width 136: "Some other text"
 caret: position 15 of child 0 {#text} of child 1 {DIV} of child 0 {DIV} of child 1 {INPUT} of child 3 {P} of body
index 047c8b867845bf5113c9c566e6cb3f86d7f535ae..c9e8351cffafe0c12f8e5c398e80b420b93aa9b5 100644 (file)
@@ -1 +1 @@
-c74757a22b240e32735eb20a1c5441e5
\ No newline at end of file
+633819bde2a9230efc75bab31c624db5
\ No newline at end of file
index 059dc03a5e97abe543403acb163a9a5e3d7928b5..76fb9ce84b2f91207fac8863af3e437e08a0e8d4 100644 (file)
Binary files a/LayoutTests/platform/gtk/fast/forms/searchfield-heights-expected.png and b/LayoutTests/platform/gtk/fast/forms/searchfield-heights-expected.png differ
index f15c236d612275796e9d5e4531d4e6349f4ffc29..c2f7d999951b013987fb8e6263d4ac9ce2f3e9ad 100644 (file)
@@ -7,31 +7,31 @@ layer at (0,0) size 800x600
         text run at (0,0) width 368: "This tests that aqua-style search fields do not honor height."
       RenderBR {BR} at (368,15) size 0x0
       RenderTextControl {INPUT} at (0,122) size 71x6 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
-        RenderBlock {DIV} at (3,3) size 65x18
-          RenderBlock {DIV} at (0,16) size 0x0
-          RenderBlock {DIV} at (49,0) size 16x16
+        RenderBlock {DIV} at (3,3) size 65x8
+          RenderBlock {DIV} at (0,6) size 0x0
+          RenderBlock {DIV} at (59,0) size 6x6
       RenderText {#text} at (71,113) size 4x19
         text run at (71,113) width 4: " "
-      RenderTextControl {INPUT} at (77,102) size 174x40 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
-        RenderBlock {DIV} at (3,10) size 168x20
-          RenderBlock {DIV} at (0,16) size 0x0
-          RenderBlock {DIV} at (152,0) size 16x16
+      RenderTextControl {INPUT} at (77,103) size 174x40 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+        RenderBlock {DIV} at (3,10) size 168x19
+          RenderBlock {DIV} at (0,15) size 0x0
+          RenderBlock {DIV} at (153,0) size 15x15
       RenderText {#text} at (253,113) size 4x19
         text run at (253,113) width 4: " "
       RenderTextControl {INPUT} at (259,19) size 318x200 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
         RenderBlock {DIV} at (3,84) size 312x31
           RenderBlock {DIV} at (0,25) size 0x0
-          RenderBlock {DIV} at (296,9) size 16x16
+          RenderBlock {DIV} at (288,1) size 24x24
       RenderText {#text} at (0,0) size 0x0
-layer at (11,143) size 49x8
-  RenderBlock {DIV} at (0,10) size 49x8
+layer at (11,133) size 59x8
+  RenderBlock {DIV} at (0,0) size 59x8
     RenderText {#text} at (1,0) size 10x8
       text run at (1,0) width 10: "mini"
-layer at (88,122) size 152x18
-  RenderBlock {DIV} at (0,2) size 152x18
+layer at (88,122) size 153x18
+  RenderBlock {DIV} at (0,1) size 153x18
     RenderText {#text} at (1,0) size 35x18
       text run at (1,0) width 35: "small"
-layer at (270,111) size 296x31
-  RenderBlock {DIV} at (0,0) size 296x31
+layer at (270,111) size 288x31
+  RenderBlock {DIV} at (0,0) size 288x31
     RenderText {#text} at (1,0) size 84x31
       text run at (1,0) width 84: "regular"
index fac585bf178908b3e8d54e12b1be43323cb7d9f6..bcf8a67a595f55d57b4c05a03cc88fc0172c266e 100644 (file)
@@ -1,3 +1,25 @@
+2011-02-04  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [GTK] Don't use a fixed size for search field icons
+        https://bugs.webkit.org/show_bug.cgi?id=50624
+
+        Use the parent input content box to make sure the icon fits in the
+        search field, scaling it down when needed.
+
+        * platform/gtk/RenderThemeGtk.cpp:
+        (WebCore::paintGdkPixbuf):
+        (WebCore::getIconSizeForPixelSize):
+        (WebCore::adjustSearchFieldIconStyle):
+        (WebCore::RenderThemeGtk::adjustSearchFieldResultsDecorationStyle):
+        (WebCore::centerRectVerticallyInParentInputElement):
+        (WebCore::RenderThemeGtk::paintSearchFieldResultsDecoration):
+        (WebCore::RenderThemeGtk::adjustSearchFieldCancelButtonStyle):
+        (WebCore::RenderThemeGtk::paintSearchFieldCancelButton):
+        (WebCore::RenderThemeGtk::paintCapsLockIndicator):
+        (WebCore::RenderThemeGtk::paintMediaButton):
+
 2011-02-04  Hironori Bono  <hbono@chromium.org>
 
         Reviewed by Adam Barth.
index 4d3cc6caf40a41b7eabf09e4a8e27925a730783e..1e9f159491fc030edeeb9228690c0c67103b6989 100644 (file)
@@ -224,15 +224,47 @@ bool RenderThemeGtk::paintTextArea(RenderObject* o, const PaintInfo& i, const In
     return paintTextField(o, i, r);
 }
 
-static void paintGdkPixbuf(GraphicsContext* context, const GdkPixbuf* icon, const IntPoint& iconPoint)
-{
+static void paintGdkPixbuf(GraphicsContext* context, const GdkPixbuf* icon, const IntRect& iconRect)
+{
+    IntSize iconSize(gdk_pixbuf_get_width(icon), gdk_pixbuf_get_height(icon));
+    if (iconRect.size() != iconSize) {
+        // We could use cairo_scale() here but cairo/pixman downscale quality is quite bad.
+        GRefPtr<GdkPixbuf> scaledIcon = gdk_pixbuf_scale_simple(icon, iconRect.width(), iconRect.height(),
+                                                                GDK_INTERP_BILINEAR);
+        icon = scaledIcon.get();
+    }
+
     cairo_t* cr = context->platformContext();
     cairo_save(cr);
-    gdk_cairo_set_source_pixbuf(cr, icon, iconPoint.x(), iconPoint.y());
+    gdk_cairo_set_source_pixbuf(cr, icon, iconRect.x(), iconRect.y());
     cairo_paint(cr);
     cairo_restore(cr);
 }
 
+// Defined in GTK+ (gtk/gtkiconfactory.c)
+static const gint gtkIconSizeMenu = 16;
+static const gint gtkIconSizeSmallToolbar = 18;
+static const gint gtkIconSizeButton = 20;
+static const gint gtkIconSizeLargeToolbar = 24;
+static const gint gtkIconSizeDnd = 32;
+static const gint gtkIconSizeDialog = 48;
+
+static GtkIconSize getIconSizeForPixelSize(gint pixelSize)
+{
+    if (pixelSize < gtkIconSizeSmallToolbar)
+        return GTK_ICON_SIZE_MENU;
+    if (pixelSize >= gtkIconSizeSmallToolbar && pixelSize < gtkIconSizeButton)
+        return GTK_ICON_SIZE_SMALL_TOOLBAR;
+    if (pixelSize >= gtkIconSizeButton && pixelSize < gtkIconSizeLargeToolbar)
+        return GTK_ICON_SIZE_BUTTON;
+    if (pixelSize >= gtkIconSizeLargeToolbar && pixelSize < gtkIconSizeDnd)
+        return GTK_ICON_SIZE_LARGE_TOOLBAR;
+    if (pixelSize >= gtkIconSizeDnd && pixelSize < gtkIconSizeDialog)
+        return GTK_ICON_SIZE_DND;
+
+    return GTK_ICON_SIZE_DIALOG;
+}
+
 void RenderThemeGtk::adjustSearchFieldResultsButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
 {
     adjustSearchFieldCancelButtonStyle(selector, style, e);
@@ -243,57 +275,77 @@ bool RenderThemeGtk::paintSearchFieldResultsButton(RenderObject* o, const PaintI
     return paintSearchFieldResultsDecoration(o, i, rect);
 }
 
-void RenderThemeGtk::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+static void adjustSearchFieldIconStyle(RenderStyle* style)
 {
     style->resetBorder();
     style->resetPadding();
 
+    // Get the icon size based on the font size.
+    int fontSize = style->fontSize();
+    if (fontSize < gtkIconSizeMenu) {
+        style->setWidth(Length(fontSize, Fixed));
+        style->setHeight(Length(fontSize, Fixed));
+        return;
+    }
     gint width = 0, height = 0;
-    gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
+    gtk_icon_size_lookup(getIconSizeForPixelSize(fontSize), &width, &height);
     style->setWidth(Length(width, Fixed));
     style->setHeight(Length(height, Fixed));
 }
 
-static IntPoint centerRectVerticallyInParentInputElement(RenderObject* object, const IntRect& rect)
+void RenderThemeGtk::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+    adjustSearchFieldIconStyle(style);
+}
+
+static IntRect centerRectVerticallyInParentInputElement(RenderObject* renderObject, const IntRect& rect)
 {
-    Node* input = object->node()->shadowAncestorNode(); // Get the renderer of <input> element.
+    // Get the renderer of <input> element.
+    Node* input = renderObject->node()->shadowAncestorNode();
     if (!input->renderer()->isBox())
-        return rect.location();
+        return IntRect();
 
     // If possible center the y-coordinate of the rect vertically in the parent input element.
     // We also add one pixel here to ensure that the y coordinate is rounded up for box heights
     // that are even, which looks in relation to the box text.
     IntRect inputContentBox = toRenderBox(input->renderer())->absoluteContentBox();
 
-    return IntPoint(rect.x(), inputContentBox.y() + (inputContentBox.height() - rect.height() + 1) / 2);
+    // Make sure the scaled decoration stays square and will fit in its parent's box.
+    int iconSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), rect.height()));
+    IntRect scaledRect(rect.x(), inputContentBox.y() + (inputContentBox.height() - iconSize + 1) / 2, iconSize, iconSize);
+    return scaledRect;
 }
 
 bool RenderThemeGtk::paintSearchFieldResultsDecoration(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect)
 {
+    IntRect iconRect = centerRectVerticallyInParentInputElement(renderObject, rect);
+    if (iconRect.isEmpty())
+        return false;
+
     GRefPtr<GdkPixbuf> icon = getStockIcon(GTK_TYPE_ENTRY, GTK_STOCK_FIND,
                                            gtkTextDirection(renderObject->style()->direction()),
-                                           gtkIconState(this, renderObject), GTK_ICON_SIZE_MENU);
-    paintGdkPixbuf(paintInfo.context, icon.get(), centerRectVerticallyInParentInputElement(renderObject, rect));
+                                           gtkIconState(this, renderObject),
+                                           getIconSizeForPixelSize(rect.height()));
+    paintGdkPixbuf(paintInfo.context, icon.get(), iconRect);
     return false;
 }
 
 void RenderThemeGtk::adjustSearchFieldCancelButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
 {
-    style->resetBorder();
-    style->resetPadding();
-
-    gint width = 0, height = 0;
-    gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
-    style->setWidth(Length(width, Fixed));
-    style->setHeight(Length(height, Fixed));
+    adjustSearchFieldIconStyle(style);
 }
 
 bool RenderThemeGtk::paintSearchFieldCancelButton(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect)
 {
+    IntRect iconRect = centerRectVerticallyInParentInputElement(renderObject, rect);
+    if (iconRect.isEmpty())
+        return false;
+
     GRefPtr<GdkPixbuf> icon = getStockIcon(GTK_TYPE_ENTRY, GTK_STOCK_CLEAR,
                                            gtkTextDirection(renderObject->style()->direction()),
-                                           gtkIconState(this, renderObject), GTK_ICON_SIZE_MENU);
-    paintGdkPixbuf(paintInfo.context, icon.get(), centerRectVerticallyInParentInputElement(renderObject, rect));
+                                           gtkIconState(this, renderObject),
+                                           getIconSizeForPixelSize(rect.height()));
+    paintGdkPixbuf(paintInfo.context, icon.get(), iconRect);
     return false;
 }
 
@@ -316,14 +368,21 @@ bool RenderThemeGtk::paintCapsLockIndicator(RenderObject* renderObject, const Pa
     if (paintInfo.context->paintingDisabled())
         return true;
 
+    int iconSize = std::min(rect.width(), rect.height());
     GRefPtr<GdkPixbuf> icon = getStockIcon(GTK_TYPE_ENTRY, GTK_STOCK_CAPS_LOCK_WARNING,
                                            gtkTextDirection(renderObject->style()->direction()),
-                                           gtkIconState(this, renderObject), GTK_ICON_SIZE_MENU);
+                                           0, getIconSizeForPixelSize(iconSize));
+
+    // Only re-scale the icon when it's smaller than the minimum icon size.
+    if (iconSize >= gtkIconSizeMenu)
+        iconSize = gdk_pixbuf_get_height(icon.get());
 
     // GTK+ locates the icon right aligned in the entry. The given rectangle is already
     // centered vertically by RenderTextControlSingleLine.
-    IntPoint iconPosition(rect.x() + rect.width() - gdk_pixbuf_get_width(icon.get()), rect.y());
-    paintGdkPixbuf(paintInfo.context, icon.get(), iconPosition);
+    IntRect iconRect(rect.x() + rect.width() - iconSize,
+                     rect.y() + (rect.height() - iconSize) / 2,
+                     iconSize, iconSize);
+    paintGdkPixbuf(paintInfo.context, icon.get(), iconRect);
     return true;
 }
 
@@ -421,10 +480,11 @@ bool RenderThemeGtk::paintMediaButton(RenderObject* renderObject, GraphicsContex
                                            gtkTextDirection(renderObject->style()->direction()),
                                            gtkIconState(this, renderObject),
                                            getMediaButtonIconSize(m_mediaIconSize));
-    IntPoint iconPoint(rect.x() + (rect.width() - m_mediaIconSize) / 2,
-                       rect.y() + (rect.height() - m_mediaIconSize) / 2);
+    IntRect iconRect(rect.x() + (rect.width() - m_mediaIconSize) / 2,
+                     rect.y() + (rect.height() - m_mediaIconSize) / 2,
+                     m_mediaIconSize, m_mediaIconSize);
     context->fillRect(FloatRect(rect), m_panelColor, ColorSpaceDeviceRGB);
-    paintGdkPixbuf(context, icon.get(), iconPoint);
+    paintGdkPixbuf(context, icon.get(), iconRect);
     return false;
 }