Title: [168111] trunk
Revision
168111
Author
za...@apple.com
Date
2014-05-01 11:49:37 -0700 (Thu, 01 May 2014)

Log Message

Subpixel rendering: Make selection gaps painting subpixel aware.
https://bugs.webkit.org/show_bug.cgi?id=132169

Reviewed by Simon Fraser.

Push selection gaps painting to device pixel boundaries instead of integral CSS pixel positions.

Source/WebCore:
Test: fast/inline/hidpi-selection-gap-on-subpixel-position.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::blockSelectionGap):
(WebCore::RenderBlock::logicalLeftSelectionGap):
(WebCore::RenderBlock::logicalRightSelectionGap):

LayoutTests:
* fast/inline/hidpi-selection-gap-on-subpixel-position-expected.html: Added.
* fast/inline/hidpi-selection-gap-on-subpixel-position.html: Added. : &nbsp is needed to make
this test pass on WK2. Font rendering reports differences. 0.9 transparency is added so that
text selection code does modify the color's alpha channel and I can properly match it.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (168110 => 168111)


--- trunk/LayoutTests/ChangeLog	2014-05-01 18:31:35 UTC (rev 168110)
+++ trunk/LayoutTests/ChangeLog	2014-05-01 18:49:37 UTC (rev 168111)
@@ -1,3 +1,17 @@
+2014-05-01  Zalan Bujtas  <za...@apple.com>
+
+        Subpixel rendering: Make selection gaps painting subpixel aware.
+        https://bugs.webkit.org/show_bug.cgi?id=132169
+
+        Reviewed by Simon Fraser.
+
+        Push selection gaps painting to device pixel boundaries instead of integral CSS pixel positions.
+
+        * fast/inline/hidpi-selection-gap-on-subpixel-position-expected.html: Added.
+        * fast/inline/hidpi-selection-gap-on-subpixel-position.html: Added. : &nbsp is needed to make
+        this test pass on WK2. Font rendering reports differences. 0.9 transparency is added so that
+        text selection code does modify the color's alpha channel and I can properly match it.
+
 2014-05-01  Javier Fernandez  <jfernan...@igalia.com>
 
         [CSS Grid Layout] Clamping the number of repetitions in repeat()

Added: trunk/LayoutTests/fast/inline/hidpi-selection-gap-on-subpixel-position-expected.html (0 => 168111)


--- trunk/LayoutTests/fast/inline/hidpi-selection-gap-on-subpixel-position-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/hidpi-selection-gap-on-subpixel-position-expected.html	2014-05-01 18:49:37 UTC (rev 168111)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that selection gaps can be painted on subpixel position.</title>
+<style>
+  div {
+    font-size: 16px;
+    height: 20px;
+  }
+
+  .bckg {
+    position: fixed;
+    background: rgba(255, 0, 0, 0.9);
+    z-index: -1000;
+  }
+</style>
+</head>
+<body>
+<p id="container"></p>
+<div class=bckg style="left: 8px; top: 16px; width: 784px; height: 475px;"></div> 
+<div class=bckg style="left: 8px; top: 491px; width: 15.5px; height: 26px;"></div> 
+<script>
+  var container = document.getElementById("container");
+  fontSize = 16;
+  margin = 0;
+  for (i = 0; i < 20; ++i) {
+    var e = document.createElement("div");
+    e.innerHTML = "&nbsp";
+    e.style.fontSize = fontSize + "px";
+    e.style.margin = margin+ "px";
+    container.appendChild(e);
+    fontSize+=0.3;
+    margin+=0.5;
+  }
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/inline/hidpi-selection-gap-on-subpixel-position.html (0 => 168111)


--- trunk/LayoutTests/fast/inline/hidpi-selection-gap-on-subpixel-position.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/hidpi-selection-gap-on-subpixel-position.html	2014-05-01 18:49:37 UTC (rev 168111)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that selection gaps can be painted on subpixel position.</title>
+<style>
+  ::selection {
+    background: rgba(255, 0, 0, 0.9);
+  }
+
+  div {
+    font-size: 16px;
+    height: 20px;
+  }
+
+</style>
+</head>
+<body>
+<p id="container"></p>
+<script>
+  var container = document.getElementById("container");
+  fontSize = 16;
+  margin = 0;
+  for (i = 0; i < 20; ++i) {
+    var e = document.createElement("div");
+    e.innerHTML = "&nbsp";
+    e.style.fontSize = fontSize + "px";
+    e.style.margin = margin + "px";
+    container.appendChild(e);
+    fontSize+=0.3;
+    margin+=0.5;
+  }
+
+  var range = document.createRange(); 
+  range.selectNode(document.getElementById("container")); 
+  window.getSelection().addRange(range);
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (168110 => 168111)


--- trunk/Source/WebCore/ChangeLog	2014-05-01 18:31:35 UTC (rev 168110)
+++ trunk/Source/WebCore/ChangeLog	2014-05-01 18:49:37 UTC (rev 168111)
@@ -1,3 +1,19 @@
+2014-05-01  Zalan Bujtas  <za...@apple.com>
+
+        Subpixel rendering: Make selection gaps painting subpixel aware.
+        https://bugs.webkit.org/show_bug.cgi?id=132169
+
+        Reviewed by Simon Fraser.
+
+        Push selection gaps painting to device pixel boundaries instead of integral CSS pixel positions.
+
+        Test: fast/inline/hidpi-selection-gap-on-subpixel-position.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::blockSelectionGap):
+        (WebCore::RenderBlock::logicalLeftSelectionGap):
+        (WebCore::RenderBlock::logicalRightSelectionGap):
+
 2014-05-01  David Kilzer  <ddkil...@apple.com>
 
         Really remove ENABLE_PLUGIN_PROXY_FOR_VIDEO

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (168110 => 168111)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2014-05-01 18:31:35 UTC (rev 168110)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2014-05-01 18:49:37 UTC (rev 168111)
@@ -2533,7 +2533,7 @@
 
     LayoutRect gapRect = rootBlock.logicalRectToPhysicalRect(rootBlockPhysicalPosition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight));
     if (paintInfo)
-        paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selectionBackgroundColor(), style().colorSpace());
+        paintInfo->context->fillRect(pixelSnappedForPainting(gapRect, document().deviceScaleFactor()), selectionBackgroundColor(), style().colorSpace());
     return gapRect;
 }
 
@@ -2550,7 +2550,7 @@
 
     LayoutRect gapRect = rootBlock.logicalRectToPhysicalRect(rootBlockPhysicalPosition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalWidth, logicalHeight));
     if (paintInfo)
-        paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selObj->selectionBackgroundColor(), selObj->style().colorSpace());
+        paintInfo->context->fillRect(pixelSnappedForPainting(gapRect, document().deviceScaleFactor()), selObj->selectionBackgroundColor(), selObj->style().colorSpace());
     return gapRect;
 }
 
@@ -2567,7 +2567,7 @@
 
     LayoutRect gapRect = rootBlock.logicalRectToPhysicalRect(rootBlockPhysicalPosition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalWidth, logicalHeight));
     if (paintInfo)
-        paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selObj->selectionBackgroundColor(), selObj->style().colorSpace());
+        paintInfo->context->fillRect(pixelSnappedForPainting(gapRect, document().deviceScaleFactor()), selObj->selectionBackgroundColor(), selObj->style().colorSpace());
     return gapRect;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to