Title: [184970] trunk
Revision
184970
Author
za...@apple.com
Date
2015-05-28 17:15:24 -0700 (Thu, 28 May 2015)

Log Message

Subpixel rendering: Pixel crack in text selection of simple text in <textarea>.
https://bugs.webkit.org/show_bug.cgi?id=145393
rdar://problem/19918941

Reviewed by Darin Adler.

Float to LayoutUnit conversion is lossy. To ensure that selection
painting always lines up (snaps) properly, the calculated width needs to
be adjusted by ceiling the float to the next LayoutUnit value.

Source/WebCore:

Test: fast/text/hidpi-text-selection-gap-between-words.html

* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::adjustSelectionRectForSimpleText):
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::FontCascade::adjustSelectionRectForComplexText):

LayoutTests:

* fast/text/hidpi-text-selection-gap-between-words-expected.html: Added.
* fast/text/hidpi-text-selection-gap-between-words.html: Added.
* platform/mac/platform/mac/editing/input/caret-primary-bidi-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (184969 => 184970)


--- trunk/LayoutTests/ChangeLog	2015-05-28 23:51:57 UTC (rev 184969)
+++ trunk/LayoutTests/ChangeLog	2015-05-29 00:15:24 UTC (rev 184970)
@@ -1,3 +1,19 @@
+2015-05-28  Zalan Bujtas  <za...@apple.com>
+
+        Subpixel rendering: Pixel crack in text selection of simple text in <textarea>.
+        https://bugs.webkit.org/show_bug.cgi?id=145393
+        rdar://problem/19918941
+
+        Reviewed by Darin Adler.
+
+        Float to LayoutUnit conversion is lossy. To ensure that selection
+        painting always lines up (snaps) properly, the calculated width needs to
+        be adjusted by ceiling the float to the next LayoutUnit value.
+
+        * fast/text/hidpi-text-selection-gap-between-words-expected.html: Added.
+        * fast/text/hidpi-text-selection-gap-between-words.html: Added.
+        * platform/mac/platform/mac/editing/input/caret-primary-bidi-expected.txt:
+
 2015-05-28  Andreas Kling  <akl...@apple.com>
 
         GraphicsLayerCA should start out with m_intersectsCoverageRect=false

Added: trunk/LayoutTests/fast/text/hidpi-text-selection-gap-between-words-expected.html (0 => 184970)


--- trunk/LayoutTests/fast/text/hidpi-text-selection-gap-between-words-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/hidpi-text-selection-gap-between-words-expected.html	2015-05-29 00:15:24 UTC (rev 184970)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that selection rect does not have gaps inbetween words.</title>
+<style>
+  div {
+    position: absolute;
+    top: 8px;
+    left: 0px;
+    width: 7px;
+    height: 13px;
+    background: rgba(0, 96, 0, 0.8);
+  }
+</style>
+</head>
+<body>
+  <div></div>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text/hidpi-text-selection-gap-between-words.html (0 => 184970)


--- trunk/LayoutTests/fast/text/hidpi-text-selection-gap-between-words.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/hidpi-text-selection-gap-between-words.html	2015-05-29 00:15:24 UTC (rev 184970)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that selection rect does not have gaps inbetween words.</title>
+<style>
+  div {
+    font-family: monospace;
+    font-size: 11px;
+    width: 500px;
+    white-space: pre-wrap;
+    color: white;
+    margin-left: -351px;
+  }
+
+  div::selection {
+    background: green;
+  }
+</style>
+</head>
+<body>
+  <div id=target>Inspector doesn't do this. I have been aware of this </div>
+  <script>
+    var target = document.getElementById("target");
+    getSelection().setBaseAndExtent(target.firstChild, 48, target.firstChild, 53);
+  </script>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/mac/platform/mac/editing/input/caret-primary-bidi-expected.txt (184969 => 184970)


--- trunk/LayoutTests/platform/mac/platform/mac/editing/input/caret-primary-bidi-expected.txt	2015-05-28 23:51:57 UTC (rev 184969)
+++ trunk/LayoutTests/platform/mac/platform/mac/editing/input/caret-primary-bidi-expected.txt	2015-05-29 00:15:24 UTC (rev 184970)
@@ -35,7 +35,7 @@
 34: 32,478,0,28
 35: 18,478,0,28
 36: 47,478,0,28
-37: 60,478,0,28
+37: 61,478,0,28
 38: 76,478,0,28
 39: 88,478,0,28
 40: 113,478,0,28

Modified: trunk/Source/WebCore/ChangeLog (184969 => 184970)


--- trunk/Source/WebCore/ChangeLog	2015-05-28 23:51:57 UTC (rev 184969)
+++ trunk/Source/WebCore/ChangeLog	2015-05-29 00:15:24 UTC (rev 184970)
@@ -1,3 +1,22 @@
+2015-05-28  Zalan Bujtas  <za...@apple.com>
+
+        Subpixel rendering: Pixel crack in text selection of simple text in <textarea>.
+        https://bugs.webkit.org/show_bug.cgi?id=145393
+        rdar://problem/19918941
+
+        Reviewed by Darin Adler.
+
+        Float to LayoutUnit conversion is lossy. To ensure that selection
+        painting always lines up (snaps) properly, the calculated width needs to
+        be adjusted by ceiling the float to the next LayoutUnit value.
+
+        Test: fast/text/hidpi-text-selection-gap-between-words.html
+
+        * platform/graphics/FontCascade.cpp:
+        (WebCore::FontCascade::adjustSelectionRectForSimpleText):
+        * platform/graphics/cocoa/FontCascadeCocoa.mm:
+        (WebCore::FontCascade::adjustSelectionRectForComplexText):
+
 2015-05-28  Andreas Kling  <akl...@apple.com>
 
         GraphicsLayerCA should start out with m_intersectsCoverageRect=false

Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (184969 => 184970)


--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2015-05-28 23:51:57 UTC (rev 184969)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2015-05-29 00:15:24 UTC (rev 184970)
@@ -1476,7 +1476,7 @@
         selectionRect.move(totalWidth - afterWidth, 0);
     } else
         selectionRect.move(beforeWidth, 0);
-    selectionRect.setWidth(afterWidth - beforeWidth);
+    selectionRect.setWidth(LayoutUnit::fromFloatCeil(afterWidth - beforeWidth));
 }
 
 int FontCascade::offsetForPositionForSimpleText(const TextRun& run, float x, bool includePartialGlyphs) const

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (184969 => 184970)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2015-05-28 23:51:57 UTC (rev 184969)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2015-05-29 00:15:24 UTC (rev 184970)
@@ -708,7 +708,7 @@
         selectionRect.move(controller.totalWidth() - afterWidth + controller.leadingExpansion(), 0);
     else
         selectionRect.move(beforeWidth, 0);
-    selectionRect.setWidth(afterWidth - beforeWidth);
+    selectionRect.setWidth(LayoutUnit::fromFloatCeil(afterWidth - beforeWidth));
 }
 
 float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to