Subpixel rendering: RenderBox's content clipping should clip on device pixel boundary.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jun 2014 00:14:21 +0000 (00:14 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jun 2014 00:14:21 +0000 (00:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133767
<rdar://problem/17272365>

Reviewed by Simon Fraser.

Push RenderBox's content clipping to device pixel boundaries. Integral snapping makes
content cut off prematurely.

Source/WebCore:
Test: fast/inline-block/hidpi-margin-top-with-subpixel-value-and-overflow-hidden.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::pushContentsClip):

LayoutTests:
* fast/inline-block/hidpi-margin-top-with-subpixel-value-and-overflow-hidden-expected.html: Added.
* fast/inline-block/hidpi-margin-top-with-subpixel-value-and-overflow-hidden.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/inline-block/hidpi-margin-top-with-subpixel-value-and-overflow-hidden-expected.html [new file with mode: 0644]
LayoutTests/fast/inline-block/hidpi-margin-top-with-subpixel-value-and-overflow-hidden.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp

index 6a44f51..6892b0b 100644 (file)
@@ -1,3 +1,17 @@
+2014-06-11  Zalan Bujtas  <zalan@apple.com>
+
+        Subpixel rendering: RenderBox's content clipping should clip on device pixel boundary.
+        https://bugs.webkit.org/show_bug.cgi?id=133767
+        <rdar://problem/17272365>
+
+        Reviewed by Simon Fraser.
+
+        Push RenderBox's content clipping to device pixel boundaries. Integral snapping makes
+        content cut off prematurely.
+
+        * fast/inline-block/hidpi-margin-top-with-subpixel-value-and-overflow-hidden-expected.html: Added.
+        * fast/inline-block/hidpi-margin-top-with-subpixel-value-and-overflow-hidden.html: Added.
+
 2014-06-11  David Kilzer  <ddkilzer@apple.com>
 
         WindowFeatures arguments shoud ignore invalid characters in values
diff --git a/LayoutTests/fast/inline-block/hidpi-margin-top-with-subpixel-value-and-overflow-hidden-expected.html b/LayoutTests/fast/inline-block/hidpi-margin-top-with-subpixel-value-and-overflow-hidden-expected.html
new file mode 100644 (file)
index 0000000..e92d522
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<head>
+<title>This tests that text with subpixel margin-top value does not get cut off prematurely.</title>
+<style>
+  .outer {
+    display: inline-block;
+    font-family: '.LucidaGrandeUI';
+    margin-top: 0.5px;
+  }
+
+  .inner {
+    overflow: hidden;
+  }
+</style>
+</head>
+<body>
+  <div class=outer>
+    <div class=inner>ggggg</div>
+  </div>
+<body>
diff --git a/LayoutTests/fast/inline-block/hidpi-margin-top-with-subpixel-value-and-overflow-hidden.html b/LayoutTests/fast/inline-block/hidpi-margin-top-with-subpixel-value-and-overflow-hidden.html
new file mode 100644 (file)
index 0000000..96dbda5
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<head>
+<title>This tests that text with subpixel margin-top value does not get cut off prematurely.</title>
+<style>
+  .outer {
+    display: inline-block;
+    font-family: '.LucidaGrandeUI';
+    margin-top: 0.3px;
+  }
+
+  .inner {
+    overflow: hidden;
+  }
+</style>
+</head>
+<body>
+  <div class=outer>
+    <div class=inner>ggggg</div>
+  </div>
+<body>
index 2b2b27f..c068c61 100644 (file)
@@ -1,3 +1,19 @@
+2014-06-11  Zalan Bujtas  <zalan@apple.com>
+
+        Subpixel rendering: RenderBox's content clipping should clip on device pixel boundary.
+        https://bugs.webkit.org/show_bug.cgi?id=133767
+        <rdar://problem/17272365>
+
+        Reviewed by Simon Fraser.
+
+        Push RenderBox's content clipping to device pixel boundaries. Integral snapping makes
+        content cut off prematurely.
+
+        Test: fast/inline-block/hidpi-margin-top-with-subpixel-value-and-overflow-hidden.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::pushContentsClip):
+
 2014-06-11  Anders Carlsson  <andersca@apple.com>
 
         Remove XHRReplayData::addHeader
index 181a823..3f6d1ac 100644 (file)
@@ -1691,10 +1691,11 @@ bool RenderBox::pushContentsClip(PaintInfo& paintInfo, const LayoutPoint& accumu
         paintObject(paintInfo, accumulatedOffset);
         paintInfo.phase = PaintPhaseChildBlockBackgrounds;
     }
-    IntRect clipRect = pixelSnappedIntRect(isControlClip ? controlClipRect(accumulatedOffset) : overflowClipRect(accumulatedOffset, currentRenderNamedFlowFragment(), IgnoreOverlayScrollbarSize, paintInfo.phase));
+    float deviceScaleFactor = document().deviceScaleFactor();
+    FloatRect clipRect = pixelSnappedForPainting((isControlClip ? controlClipRect(accumulatedOffset) : overflowClipRect(accumulatedOffset, currentRenderNamedFlowFragment(), IgnoreOverlayScrollbarSize, paintInfo.phase)), deviceScaleFactor);
     paintInfo.context->save();
     if (style().hasBorderRadius())
-        paintInfo.context->clipRoundedRect(FloatRoundedRect(style().getRoundedInnerBorderFor(LayoutRect(accumulatedOffset, size()))));
+        paintInfo.context->clipRoundedRect(style().getRoundedInnerBorderFor(LayoutRect(accumulatedOffset, size())).pixelSnappedRoundedRectForPainting(deviceScaleFactor));
     paintInfo.context->clip(clipRect);
     return true;
 }