Search input results and clear icons are misaligned when padding is added
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Aug 2015 00:23:49 +0000 (00:23 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Aug 2015 00:23:49 +0000 (00:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148146
<rdar://problem/22310951>

Reviewed by Zalan Bujtas.

Source/WebCore:

Use content box rect to determine where to draw the results and cancel buttons
of a search field that has -webkit-appearance: textfield. Previously, we used
the bounding box, which caused the buttons to render in the input's padding
region.

Test: platform/mac/fast/forms/search/search-padding-cancel-results-buttons.html

* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintSearchFieldCancelButton): Use content box to
    compute where to render cancel button.
(WebCore::RenderThemeMac::paintSearchFieldResultsButton): Use content box to
    compute where to render results button.

LayoutTests:

Tests that for a search field with -webkit-appearance: textfield; and padding will not clip
its cancel and results buttons.

* platform/mac/fast/forms/search/search-padding-cancel-results-buttons-expected.txt: Added.
* platform/mac/fast/forms/search/search-padding-cancel-results-buttons.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/fast/forms/search/search-padding-cancel-results-buttons-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/search/search-padding-cancel-results-buttons.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderThemeMac.mm

index a565dfc4b90a26fa53eb6d30e4ed73b7b76e7045..716dccc0ad1881b0e48af29be41549aa7cebbf72 100644 (file)
@@ -1,3 +1,17 @@
+2015-08-18  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Search input results and clear icons are misaligned when padding is added
+        https://bugs.webkit.org/show_bug.cgi?id=148146
+        <rdar://problem/22310951>
+
+        Reviewed by Zalan Bujtas.
+
+        Tests that for a search field with -webkit-appearance: textfield; and padding will not clip
+        its cancel and results buttons.
+
+        * platform/mac/fast/forms/search/search-padding-cancel-results-buttons-expected.txt: Added.
+        * platform/mac/fast/forms/search/search-padding-cancel-results-buttons.html: Added.
+
 2015-08-18  Simon Fraser  <simon.fraser@apple.com>
 
         will-change: backface-visibility should not cause stacking context
diff --git a/LayoutTests/platform/mac/fast/forms/search/search-padding-cancel-results-buttons-expected.txt b/LayoutTests/platform/mac/fast/forms/search/search-padding-cancel-results-buttons-expected.txt
new file mode 100644 (file)
index 0000000..80a6046
--- /dev/null
@@ -0,0 +1,15 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderTextControl {INPUT} at (2,2) size 199x37 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+        RenderFlexibleBox {DIV} at (12,12) size 175x13
+          RenderBlock {DIV} at (0,1) size 22x11
+          RenderBlock {DIV} at (22,0) size 140x13
+          RenderBlock {DIV} at (161,1) size 14x11
+      RenderText {#text} at (0,0) size 0x0
+layer at (44,22) size 139x13
+  RenderBlock {DIV} at (0,0) size 140x13
+    RenderText {#text} at (0,0) size 20x13
+      text run at (0,0) width 20: "test"
diff --git a/LayoutTests/platform/mac/fast/forms/search/search-padding-cancel-results-buttons.html b/LayoutTests/platform/mac/fast/forms/search/search-padding-cancel-results-buttons.html
new file mode 100644 (file)
index 0000000..c379a37
--- /dev/null
@@ -0,0 +1,14 @@
+<html>
+<head>
+    <style>
+    input {
+        -webkit-appearance: textfield;
+        padding: 10px;
+    }
+    </style>
+</head>
+
+<body>
+    <input type="search" value="test" results="5" />
+</body>
+</html>
index 5d3f95c5d17f0aef49c5017677e268e82421a806..8450aa8d9ba6ce152de8e8321f5b8cb802561a76 100644 (file)
@@ -1,3 +1,24 @@
+2015-08-18  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Search input results and clear icons are misaligned when padding is added
+        https://bugs.webkit.org/show_bug.cgi?id=148146
+        <rdar://problem/22310951>
+
+        Reviewed by Zalan Bujtas.
+
+        Use content box rect to determine where to draw the results and cancel buttons
+        of a search field that has -webkit-appearance: textfield. Previously, we used
+        the bounding box, which caused the buttons to render in the input's padding
+        region.
+
+        Test: platform/mac/fast/forms/search/search-padding-cancel-results-buttons.html
+
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintSearchFieldCancelButton): Use content box to
+            compute where to render cancel button.
+        (WebCore::RenderThemeMac::paintSearchFieldResultsButton): Use content box to
+            compute where to render results button.
+
 2015-08-18  Dean Jackson  <dino@apple.com>
 
         CAOpenGLLayer doesn't need an SPI declaration
index 73d67f41160984253c4233925a4c9b849bc1d70e..de22d00c867e4400de4683106f4f476223e0ffa2 100644 (file)
@@ -1699,7 +1699,7 @@ bool RenderThemeMac::paintSearchFieldCancelButton(const RenderObject& o, const P
 
     float zoomLevel = o.style().effectiveZoom();
 
-    FloatRect localBounds = [search cancelButtonRectForBounds:NSRect(snappedIntRect(input->renderBox()->borderBoxRect()))];
+    FloatRect localBounds = [search cancelButtonRectForBounds:NSRect(snappedIntRect(input->renderBox()->contentBoxRect()))];
     localBounds = convertToPaintingRect(*input->renderer(), o, localBounds, r);
 
     FloatRect unzoomedRect(localBounds);
@@ -1810,7 +1810,7 @@ bool RenderThemeMac::paintSearchFieldResultsButton(const RenderObject& o, const
     GraphicsContextStateSaver stateSaver(*paintInfo.context);
     float zoomLevel = o.style().effectiveZoom();
 
-    FloatRect localBounds = [search searchButtonRectForBounds:NSRect(snappedIntRect(input->renderBox()->borderBoxRect()))];
+    FloatRect localBounds = [search searchButtonRectForBounds:NSRect(snappedIntRect(input->renderBox()->contentBoxRect()))];
     localBounds = convertToPaintingRect(*input->renderer(), o, localBounds, r);
 
     IntRect unzoomedRect(localBounds);