Title: [190800] trunk
Revision
190800
Author
wenson_hs...@apple.com
Date
2015-10-09 08:18:42 -0700 (Fri, 09 Oct 2015)

Log Message

Backgrounds bleed out of natively rendered text fields
https://bugs.webkit.org/show_bug.cgi?id=149843
<rdar://problem/22896977>

Reviewed by Darin Adler.

Source/WebCore:

When natively rendering a text field with a background on Mac, the background bleeds out
of the text field's border when the graphics context is scaled (as a result of a retina
display or zoom/scale effects). This is because when we render the text field in bezeled
style within a certain frame, AppKit adds 1 device pixel insets on all sides of the frame,
which renders a text field that is slightly smaller than the frame. To adjust for this, we
inflate the paint rect.

Test: fast/forms/hidpi-textfield-background-bleeding.html

* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintTextField):

LayoutTests:

Add a layout test to check that the background of a natively rendered text field
cell does not bleed.

* TestExpectations:
* fast/forms/hidpi-textfield-background-bleeding-expected.html: Added.
* fast/forms/hidpi-textfield-background-bleeding.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (190799 => 190800)


--- trunk/LayoutTests/ChangeLog	2015-10-09 14:22:26 UTC (rev 190799)
+++ trunk/LayoutTests/ChangeLog	2015-10-09 15:18:42 UTC (rev 190800)
@@ -1,3 +1,18 @@
+2015-10-08  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Backgrounds bleed out of natively rendered text fields
+        https://bugs.webkit.org/show_bug.cgi?id=149843
+        <rdar://problem/22896977>
+
+        Reviewed by Darin Adler.
+
+        Add a layout test to check that the background of a natively rendered text field
+        cell does not bleed.
+
+        * TestExpectations:
+        * fast/forms/hidpi-textfield-background-bleeding-expected.html: Added.
+        * fast/forms/hidpi-textfield-background-bleeding.html: Added.
+
 2015-10-08  Nikita Vasilyev  <nvasil...@apple.com>
 
         Web Inspector: Stack trace view doesn't properly display lines without function names

Added: trunk/LayoutTests/fast/forms/hidpi-textfield-background-bleeding-expected.html (0 => 190800)


--- trunk/LayoutTests/fast/forms/hidpi-textfield-background-bleeding-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/hidpi-textfield-background-bleeding-expected.html	2015-10-09 15:18:42 UTC (rev 190800)
@@ -0,0 +1,24 @@
+<html>
+<head>
+    <style>
+    body {
+        margin: 0;
+    }
+
+    div {
+        position: absolute;
+        top: 0;
+        left: 0;
+        border: 0.5px black solid;
+        width: 99px;
+        height: 99px;
+        background-color: yellow;
+    }
+    </style>
+</head>
+
+<body>
+    <div />
+</body>
+
+</html>

Added: trunk/LayoutTests/fast/forms/hidpi-textfield-background-bleeding.html (0 => 190800)


--- trunk/LayoutTests/fast/forms/hidpi-textfield-background-bleeding.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/hidpi-textfield-background-bleeding.html	2015-10-09 15:18:42 UTC (rev 190800)
@@ -0,0 +1,28 @@
+<html>
+<head>
+    <style>
+    div, input {
+        position: absolute;
+        top: 0;
+        left: 0;
+    }
+
+    input {
+        background-color: yellow;
+        width: 100px;
+        height: 100px;
+    }
+
+    div {
+        border: 0.5px black solid;
+        width: 99px;
+        height: 99px;
+    }
+    </style>
+</head>
+
+<body>
+    <input /><div />
+</body>
+
+</html>

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (190799 => 190800)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2015-10-09 14:22:26 UTC (rev 190799)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2015-10-09 15:18:42 UTC (rev 190800)
@@ -1714,6 +1714,7 @@
 fast/forms/focus-change-on-keypress.html [ Failure ]
 fast/forms/focus-selection-input.html [ Failure ]
 fast/forms/hidpi-textarea-on-subpixel-position.html [ ImageOnlyFailure ]
+fast/forms/hidpi-textfield-background-bleeding.html [ ImageOnlyFailure ]
 fast/forms/implicit-submission.html [ Failure ]
 fast/forms/input-baseline.html [ Failure ]
 fast/forms/input-first-letter-edit.html [ ImageOnlyFailure ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (190799 => 190800)


--- trunk/LayoutTests/platform/mac/TestExpectations	2015-10-09 14:22:26 UTC (rev 190799)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2015-10-09 15:18:42 UTC (rev 190800)
@@ -728,6 +728,9 @@
 
 webkit.org/b/147254 media/restore-from-page-cache.html [ Pass Failure ]
 
+# After Mavericks, native text fields are rendered slightly smaller, causing backgrounds to bleed on platforms.
+[ Mavericks ] fast/forms/hidpi-textfield-background-bleeding.html [ ImageOnlyFailure ]
+
 # These fast/forms/select tests open a pop-up menu (visible on screen even when using run-webkit-tests), and get stuck in its nested event loop.
 webkit.org/b/87748 fast/forms/select/optgroup-clicking.html [ Skip ]
 webkit.org/b/73304 fast/forms/select/menulist-popup-crash.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (190799 => 190800)


--- trunk/Source/WebCore/ChangeLog	2015-10-09 14:22:26 UTC (rev 190799)
+++ trunk/Source/WebCore/ChangeLog	2015-10-09 15:18:42 UTC (rev 190800)
@@ -1,3 +1,23 @@
+2015-10-08  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Backgrounds bleed out of natively rendered text fields
+        https://bugs.webkit.org/show_bug.cgi?id=149843
+        <rdar://problem/22896977>
+
+        Reviewed by Darin Adler.
+
+        When natively rendering a text field with a background on Mac, the background bleeds out
+        of the text field's border when the graphics context is scaled (as a result of a retina
+        display or zoom/scale effects). This is because when we render the text field in bezeled
+        style within a certain frame, AppKit adds 1 device pixel insets on all sides of the frame,
+        which renders a text field that is slightly smaller than the frame. To adjust for this, we
+        inflate the paint rect.
+
+        Test: fast/forms/hidpi-textfield-background-bleeding.html
+
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintTextField):
+
 2015-10-09  Xabier Rodriguez Calvar  <calva...@igalia.com> and Youenn Fablet  <youenn.fab...@crf.canon.fr>
 
         Refactor WebCore JS builtins to prepare for automatic generation

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (190799 => 190800)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2015-10-09 14:22:26 UTC (rev 190799)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2015-10-09 15:18:42 UTC (rev 190800)
@@ -853,12 +853,20 @@
 {
     LocalCurrentGraphicsContext localContext(paintInfo.context());
 
+    // <rdar://problem/22896977> We adjust the paint rect here to account for how AppKit draws the text
+    // field cell slightly smaller than the rect we pass to drawWithFrame.
+    FloatRect adjustedPaintRect(r);
+    AffineTransform transform = paintInfo.context().getCTM();
+    if (transform.xScale() > 1 || transform.yScale() > 1) {
+        adjustedPaintRect.inflateX(1 / transform.xScale());
+        adjustedPaintRect.inflateY(1 / transform.yScale());
+    }
     NSTextFieldCell *textField = this->textField();
 
     GraphicsContextStateSaver stateSaver(paintInfo.context());
 
     [textField setEnabled:(isEnabled(o) && !isReadOnlyControl(o))];
-    [textField drawWithFrame:NSRect(r) inView:documentViewFor(o)];
+    [textField drawWithFrame:NSRect(adjustedPaintRect) inView:documentViewFor(o)];
 
     [textField setControlView:nil];
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to