Change RenderTableCell to use pixelSnappedSize when painting
authoreae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Mar 2013 16:16:20 +0000 (16:16 +0000)
committereae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Mar 2013 16:16:20 +0000 (16:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=112562

Reviewed by Eric Seidel.

Source/WebCore:

Change the paining code in RenderTableCell to use the pixel snapped size
to ensure consistent rounding given that the location was rounded during
layout.

It is currently constructing a paint rect by taking the rounded location
and the precise size and then pixel snapping it. This causes the size to
be rounded incorrectly. By instead using the pixel snapped size the
rounding problem can be avoided.

Test: fast/sub-pixel/table-cell-background.html

* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::paintCollapsedBorders):
(WebCore::RenderTableCell::paintBackgroundsBehindCell):
(WebCore::RenderTableCell::paintBoxDecorations):
(WebCore::RenderTableCell::paintMask):

LayoutTests:

Add test for painting of cell backgrounds on a sub-pixel boundary.

* fast/sub-pixel/table-cell-background-expected.html: Added.
* fast/sub-pixel/table-cell-background.html: Added.
* platform/chromium-linux/tables/mozilla/bugs/bug73321-expected.png:

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

LayoutTests/ChangeLog
LayoutTests/fast/sub-pixel/table-cell-background-expected.html [new file with mode: 0644]
LayoutTests/fast/sub-pixel/table-cell-background.html [new file with mode: 0644]
LayoutTests/platform/chromium-linux/tables/mozilla/bugs/bug73321-expected.png
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderTableCell.cpp

index 5bc3b62..30618e4 100644 (file)
@@ -1,3 +1,16 @@
+2013-03-18  Emil A Eklund  <eae@chromium.org>
+
+        Change RenderTableCell to use pixelSnappedSize when painting
+        https://bugs.webkit.org/show_bug.cgi?id=112562
+
+        Reviewed by Eric Seidel.
+
+        Add test for painting of cell backgrounds on a sub-pixel boundary.
+
+        * fast/sub-pixel/table-cell-background-expected.html: Added.
+        * fast/sub-pixel/table-cell-background.html: Added.
+        * platform/chromium-linux/tables/mozilla/bugs/bug73321-expected.png:
+
 2013-03-18  Raphael Kubo da Costa  <raphael.kubo.da.costa@intel.com>
 
         [EFL] Unreviewed gardening.
diff --git a/LayoutTests/fast/sub-pixel/table-cell-background-expected.html b/LayoutTests/fast/sub-pixel/table-cell-background-expected.html
new file mode 100644 (file)
index 0000000..4711ca3
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>\r
+<html>\r
+       <head>\r
+       <style>\r
+               body { zoom: 1.25; }\r
+               td { background: white; }\r
+       </style>\r
+       </head>\r
+       <body>\r
+               <div style="height: 35px;">There should be no red line between the rows.</div>\r
+               <table cellpadding="0" cellspacing="0" width="100%">\r
+                       <tr>\r
+                               <td>\r
+                                       <div style="margin-top: 10px">first row</div>\r
+                               </td>\r
+                       </tr>\r
+                       <tr>\r
+                               <td>second row</td>\r
+                       </tr>\r
+               </table>\r
+       </body>\r
+</html>\r
diff --git a/LayoutTests/fast/sub-pixel/table-cell-background.html b/LayoutTests/fast/sub-pixel/table-cell-background.html
new file mode 100644 (file)
index 0000000..da5f218
--- /dev/null
@@ -0,0 +1,23 @@
+<!DOCTYPE html>\r
+<html>\r
+       <head>\r
+       <style>\r
+               body { zoom: 1.25; }\r
+               table { background: red; }\r
+               td { background: white; }\r
+       </style>\r
+       </head>\r
+       <body>\r
+               <div style="height: 35px;">There should be no red line between the rows.</div>\r
+               <table cellpadding="0" cellspacing="0" width="100%">\r
+                       <tr>\r
+                               <td>\r
+                                       <div style="margin-top: 10px">first row</div>\r
+                               </td>\r
+                       </tr>\r
+                       <tr>\r
+                               <td>second row</td>\r
+                       </tr>\r
+               </table>\r
+       </body>\r
+</html>\r
index 51e7752..559e799 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/tables/mozilla/bugs/bug73321-expected.png and b/LayoutTests/platform/chromium-linux/tables/mozilla/bugs/bug73321-expected.png differ
index 16fbd47..240478f 100644 (file)
@@ -1,3 +1,27 @@
+2013-03-18  Emil A Eklund  <eae@chromium.org>
+
+        Change RenderTableCell to use pixelSnappedSize when painting
+        https://bugs.webkit.org/show_bug.cgi?id=112562
+
+        Reviewed by Eric Seidel.
+
+        Change the paining code in RenderTableCell to use the pixel snapped size
+        to ensure consistent rounding given that the location was rounded during
+        layout.
+
+        It is currently constructing a paint rect by taking the rounded location
+        and the precise size and then pixel snapping it. This causes the size to
+        be rounded incorrectly. By instead using the pixel snapped size the
+        rounding problem can be avoided.
+
+        Test: fast/sub-pixel/table-cell-background.html
+
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::paintCollapsedBorders):
+        (WebCore::RenderTableCell::paintBackgroundsBehindCell):
+        (WebCore::RenderTableCell::paintBoxDecorations):
+        (WebCore::RenderTableCell::paintMask):
+
 2013-03-18  Tao Bai  <michaelbai@chromium.org>
 
         Need to use const String in HTMLVideoElement::posterImageURL
index d337fa3..7eaa5c1 100644 (file)
@@ -1105,7 +1105,7 @@ void RenderTableCell::paintCollapsedBorders(PaintInfo& paintInfo, const LayoutPo
     LayoutRect localRepaintRect = paintInfo.rect;
     localRepaintRect.inflate(maximalOutlineSize(paintInfo.phase));
 
-    LayoutRect paintRect = LayoutRect(paintOffset + location(), size());
+    LayoutRect paintRect = LayoutRect(paintOffset + location(), pixelSnappedSize());
     if (paintRect.y() - table()->outerBorderTop() >= localRepaintRect.maxY())
         return;
 
@@ -1192,7 +1192,7 @@ void RenderTableCell::paintBackgroundsBehindCell(PaintInfo& paintInfo, const Lay
                 width() - borderLeft() - borderRight(), height() - borderTop() - borderBottom());
             paintInfo.context->clip(clipRect);
         }
-        paintFillLayers(paintInfo, c, bgLayer, LayoutRect(adjustedPaintOffset, size()), BackgroundBleedNone, CompositeSourceOver, backgroundObject);
+        paintFillLayers(paintInfo, c, bgLayer, LayoutRect(adjustedPaintOffset, pixelSnappedSize()), BackgroundBleedNone, CompositeSourceOver, backgroundObject);
     }
 }
 
@@ -1205,7 +1205,7 @@ void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoin
     if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild())
         return;
 
-    LayoutRect paintRect = LayoutRect(paintOffset, size());
+    LayoutRect paintRect = LayoutRect(paintOffset, pixelSnappedSize());
     paintBoxShadow(paintInfo, paintRect, style(), Normal);
     
     // Paint our cell background.
@@ -1228,7 +1228,7 @@ void RenderTableCell::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOf
     if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild())
         return;
    
-    paintMaskImages(paintInfo, LayoutRect(paintOffset, size()));
+    paintMaskImages(paintInfo, LayoutRect(paintOffset, pixelSnappedSize()));
 }
 
 bool RenderTableCell::boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, InlineFlowBox*) const