Title: [167562] trunk
Revision
167562
Author
[email protected]
Date
2014-04-19 20:38:09 -0700 (Sat, 19 Apr 2014)

Log Message

Subpixel rendering: RenderLayer's clipping should snap to device pixel boundaries.
https://bugs.webkit.org/show_bug.cgi?id=131466

Reviewed by Simon Fraser.

Fractional pixel clipping can produce cruft on RenderLayers. Since RenderLayer
sizing and painting are snapped, painting clip rect needs to be snapped the same way.

Source/WebCore:
Test: fast/clip/clip-when-rect-has-fractional-pixel-value.html

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::clipToRect):

LayoutTests:
* fast/clip/clip-when-rect-has-fractional-pixel-value-expected.html: Added.
* fast/clip/clip-when-rect-has-fractional-pixel-value.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (167561 => 167562)


--- trunk/LayoutTests/ChangeLog	2014-04-20 03:10:38 UTC (rev 167561)
+++ trunk/LayoutTests/ChangeLog	2014-04-20 03:38:09 UTC (rev 167562)
@@ -1,3 +1,16 @@
+2014-04-19  Zalan Bujtas  <[email protected]>
+
+        Subpixel rendering: RenderLayer's clipping should snap to device pixel boundaries.
+        https://bugs.webkit.org/show_bug.cgi?id=131466
+
+        Reviewed by Simon Fraser.
+
+        Fractional pixel clipping can produce cruft on RenderLayers. Since RenderLayer
+        sizing and painting are snapped, painting clip rect needs to be snapped the same way.
+
+        * fast/clip/clip-when-rect-has-fractional-pixel-value-expected.html: Added.
+        * fast/clip/clip-when-rect-has-fractional-pixel-value.html: Added.
+
 2014-04-19  Chris Fleizach  <[email protected]>
 
         AX: grid rows are not recognized do to lack of explicit role="row", role="gridcell"

Added: trunk/LayoutTests/fast/clip/clip-when-rect-has-fractional-pixel-value-expected.html (0 => 167562)


--- trunk/LayoutTests/fast/clip/clip-when-rect-has-fractional-pixel-value-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/clip/clip-when-rect-has-fractional-pixel-value-expected.html	2014-04-20 03:38:09 UTC (rev 167562)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that clipping a block element does not leave cruft behind.</title>
+<style>
+  div {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100px;
+    height: 72px;
+    background-color: yellow;
+    -webkit-transform: translateZ(0);
+  }
+</style>
+</head>
+<body>
+  <div></div>
+</body>

Added: trunk/LayoutTests/fast/clip/clip-when-rect-has-fractional-pixel-value.html (0 => 167562)


--- trunk/LayoutTests/fast/clip/clip-when-rect-has-fractional-pixel-value.html	                        (rev 0)
+++ trunk/LayoutTests/fast/clip/clip-when-rect-has-fractional-pixel-value.html	2014-04-20 03:38:09 UTC (rev 167562)
@@ -0,0 +1,21 @@
+<html>
+<head>
+<title>This tests that clipping a block element does not leave cruft behind.</title>
+<style>
+  div {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    height: 100%;
+    clip: rect(0, 100, 6.5em, 0);
+    font-size: 11px;
+    background-color: yellow;
+    -webkit-transform: translateZ(0);
+  }
+</style>
+</head>
+<body>
+  <div></div>
+</body>
+ 
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (167561 => 167562)


--- trunk/Source/WebCore/ChangeLog	2014-04-20 03:10:38 UTC (rev 167561)
+++ trunk/Source/WebCore/ChangeLog	2014-04-20 03:38:09 UTC (rev 167562)
@@ -1,3 +1,18 @@
+2014-04-19  Zalan Bujtas  <[email protected]>
+
+        Subpixel rendering: RenderLayer's clipping should snap to device pixel boundaries.
+        https://bugs.webkit.org/show_bug.cgi?id=131466
+
+        Reviewed by Simon Fraser.
+
+        Fractional pixel clipping can produce cruft on RenderLayers. Since RenderLayer
+        sizing and painting are snapped, painting clip rect needs to be snapped the same way.
+
+        Test: fast/clip/clip-when-rect-has-fractional-pixel-value.html
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::clipToRect):
+
 2014-04-19  Brent Fulgham  <[email protected]>
 
         Latched scrolling may interact badly with custom programmatic scrolling

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (167561 => 167562)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-04-20 03:10:38 UTC (rev 167561)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-04-20 03:38:09 UTC (rev 167562)
@@ -3630,9 +3630,10 @@
 void RenderLayer::clipToRect(RenderLayer* rootLayer, GraphicsContext* context, const LayoutRect& paintDirtyRect, const ClipRect& clipRect,
                              BorderRadiusClippingRule rule)
 {
+    float deviceScaleFactor = renderer().document().deviceScaleFactor();
     if (clipRect.rect() != paintDirtyRect || clipRect.hasRadius()) {
         context->save();
-        context->clip(clipRect.rect());
+        context->clip(pixelSnappedForPainting(clipRect.rect(), deviceScaleFactor));
     }
 
     if (!clipRect.hasRadius())
@@ -3645,7 +3646,7 @@
         if (layer->renderer().hasOverflowClip() && layer->renderer().style().hasBorderRadius() && inContainingBlockChain(this, layer)) {
                 LayoutPoint delta;
                 layer->convertToLayerCoords(rootLayer, delta);
-                context->clipRoundedRect(FloatRoundedRect(layer->renderer().style().getRoundedInnerBorderFor(LayoutRect(delta, layer->size()))));
+                context->clipRoundedRect(layer->renderer().style().getRoundedInnerBorderFor(LayoutRect(delta, layer->size())).pixelSnappedRoundedRectForPainting(deviceScaleFactor));
         }
 
         if (layer == rootLayer)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to