Make table collapsed borders subpixel aware.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 6 Mar 2016 03:10:21 +0000 (03:10 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 6 Mar 2016 03:10:21 +0000 (03:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150383

Reviewed by Simon Fraser.

This patch enables authors to
- set subpixel width on collapsed borders
- and push those borders to subpixel positions.

Source/WebCore:

Test: fast/table/collapsed-border-with-odd-pixel-width.html

* rendering/RenderTable.cpp:
(WebCore::RenderTable::calcBorderStart):
(WebCore::RenderTable::calcBorderEnd):
(WebCore::RenderTable::outerBorderBefore):
(WebCore::RenderTable::outerBorderAfter):
(WebCore::RenderTable::outerBorderStart):
(WebCore::RenderTable::outerBorderEnd):
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::borderHalfStart):
(WebCore::RenderTableCell::borderHalfEnd):
(WebCore::RenderTableCell::borderHalfBefore):
(WebCore::RenderTableCell::borderHalfAfter):
(WebCore::RenderTableCell::paintCollapsedBorders):
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::calcOuterBorderBefore):
(WebCore::RenderTableSection::calcOuterBorderAfter):
(WebCore::RenderTableSection::calcOuterBorderStart):
(WebCore::RenderTableSection::calcOuterBorderEnd):
* rendering/style/CollapsedBorderValue.h:
(WebCore::CollapsedBorderValue::adjustedCollapsedBorderWidth):

LayoutTests:

* fast/table/collapsed-border-with-odd-pixel-width-expected.html: Added.
* fast/table/collapsed-border-with-odd-pixel-width.html: Added.
* fast/table/hidpi-collapsed-border-with-odd-pixel-width-expected.html:

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

LayoutTests/ChangeLog
LayoutTests/fast/table/collapsed-border-with-odd-pixel-width-expected.html [new file with mode: 0644]
LayoutTests/fast/table/collapsed-border-with-odd-pixel-width.html [new file with mode: 0644]
LayoutTests/fast/table/hidpi-collapsed-border-with-odd-pixel-width-expected.html
LayoutTests/platform/ios-simulator/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderTable.cpp
Source/WebCore/rendering/RenderTableCell.cpp
Source/WebCore/rendering/RenderTableSection.cpp
Source/WebCore/rendering/style/CollapsedBorderValue.h

index 4fc78db..cae419e 100644 (file)
@@ -1,3 +1,18 @@
+2016-03-05  Zalan Bujtas  <zalan@apple.com>
+
+        Make table collapsed borders subpixel aware.
+        https://bugs.webkit.org/show_bug.cgi?id=150383
+
+        Reviewed by Simon Fraser.
+
+        This patch enables authors to 
+        - set subpixel width on collapsed borders
+        - and push those borders to subpixel positions.
+
+        * fast/table/collapsed-border-with-odd-pixel-width-expected.html: Added.
+        * fast/table/collapsed-border-with-odd-pixel-width.html: Added.
+        * fast/table/hidpi-collapsed-border-with-odd-pixel-width-expected.html:
+
 2016-03-05  Sam Weinig  <sam@webkit.org>
 
         Add support for processing the autofill field name out of form control elements ultimately to aid input methods
diff --git a/LayoutTests/fast/table/collapsed-border-with-odd-pixel-width-expected.html b/LayoutTests/fast/table/collapsed-border-with-odd-pixel-width-expected.html
new file mode 100644 (file)
index 0000000..ca823df
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>This test that we can position collapsed border with odd width at device pixel.</title>
+<style>
+
+div {
+  position: absolute;
+  height: 27px;
+  width: 29px;
+  border-color: red;
+  border-style: solid;
+}
+</style>
+</head>
+<body>
+<div style="left: 25px; top: 21px; border-width: 1px"></div><div style="left: 54px; top: 20px; width: 28px; height: 26px; border-width: 2px"></div><div style="left: 84px; top: 20px; width: 28px; height: 25px; border-width: 3px"></div>
+<div style="left: 23px; top: 46px; border-width: 4px; width: 26px; height: 26px"></div><div style="left: 53px; top: 46px; width: 25px; height: 25px; border-width: 5px"></div><div style="left: 82px; top: 45px; width: 25px; height: 24px; border-width: 6px"></div>
+<div style="left: 22px; top: 74px; border-width: 7px; width: 23px; height: 24px;"></div><div style="left: 51px; top: 73px; width: 22px; height: 23px; border-width: 8px"></div><div style="left: 81px; top: 73px; width: 22px; height: 22px; border-width: 9px"></div>
+
+
+<div style="left: 25px; top: 120px; border-width: 1px; width: 22px; height: 26px;"></div><div style="left: 48px; top: 119px; width: 24px; height: 24px; border-width: 3px"></div><div style="left: 73px; top: 118px; width: 22px; height: 22px; border-width: 5px"></div>
+<div style="left: 25px; top: 147px; border-width: 1px; width: 22px; height: 26px;"></div><div style="left: 48px; top: 146px; width: 24px; height: 24px; border-width: 3px"></div><div style="left: 73px; top: 145px; width: 22px; height: 22px; border-width: 5px"></div>
+<div style="left: 25px; top: 174px; border-width: 1px; width: 22px; height: 26px;"></div><div style="left: 48px; top: 173px; width: 24px; height: 24px; border-width: 3px"></div><div style="left: 73px; top: 172px; width: 22px; height: 22px; border-width: 5px"></div>
+
+<div style="left: 25px; top: 211px; border-width: 1px; width: 34px; height: 26px;"></div><div style="left: 60px; top: 210px; width: 34px; height: 24px; border-width: 3px"></div><div style="left: 97px; top: 209px; width: 34px; height: 22px; border-width: 5px"></div>
+<div style="left: 22px; top: 238px; border-width: 7px; width: 30px; height: 26px;"></div><div style="left: 57px; top: 237px; width: 30px; height: 24px; border-width: 9px"></div><div style="left: 94px; top: 236px; width: 28px; height: 22px; border-width: 11px"></div>
+<div style="left: 19px; top: 271px; border-width: 13px; width: 24px; height: 26px;"></div><div style="left: 54px; top: 270px; width: 24px; height: 24px; border-width: 15px"></div><div style="left: 91px; top: 269px; width: 22px; height: 22px; border-width: 17px"></div>
+
+</html>
diff --git a/LayoutTests/fast/table/collapsed-border-with-odd-pixel-width.html b/LayoutTests/fast/table/collapsed-border-with-odd-pixel-width.html
new file mode 100644 (file)
index 0000000..fb161b8
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>This test that we can position collapsed border with odd width at device pixel.</title>
+<style>
+body {
+    margin: 20px;
+}
+
+table {
+    margin: 5px;
+    border-collapse: collapse;
+}
+
+td {
+  height: 20px;
+  width: 20px;
+}
+</style>
+</head>
+<body>
+<table>
+    <tr><td style="border: 1px solid red"></td><td style="border: 2px solid red"></td><td style="border: 3px solid red"></td></tr>
+    <tr><td style="border: 4px solid red"></td><td style="border: 5px solid red"></td><td style="border: 6px solid red"></td></tr>
+    <tr><td style="border: 7px solid red"></td><td style="border: 8px solid red"></td><td style="border: 9px solid red"></td></tr>
+</table>
+<table>
+    <tr><td style="border: 1px solid red"></td><td style="border: 3px solid red"></td><td style="border: 5px solid red"></td></tr>
+    <tr><td style="border: 1px solid red"></td><td style="border: 3px solid red"></td><td style="border: 5px solid red"></td></tr>
+    <tr><td style="border: 1px solid red"></td><td style="border: 3px solid red"></td><td style="border: 5px solid red"></td></tr>
+</table>
+<table>
+    <tr><td style="border: 1px solid red"></td><td style="border: 3px solid red"></td><td style="border: 5px solid red"></td></tr>
+    <tr><td style="border: 7px solid red"></td><td style="border: 9px solid red"></td><td style="border: 11px solid red"></td></tr>
+    <tr><td style="border: 13px solid red"></td><td style="border: 15px solid red"></td><td style="border: 17px solid red"></td></tr>
+</table>
+</body>
+</html>
index 103eee9..fd06269 100644 (file)
@@ -14,17 +14,17 @@ div {
 </style>
 </head>
 <body>
-<div style="left: 24.5px; top: 20.5px; border-width: 1px"></div><div style="left: 54px; top: 20px; width: 28.5px; height: 26.5px; border-width: 2px"></div><div style="left: 83.5px; top: 19.5px; width: 28px; height: 25.5px; border-width: 3px"></div>
-<div style="left: 23px; top: 46px; border-width: 4px; width: 26.5px; height: 26.5px"></div><div style="left: 52.5px; top: 45.5px; width: 25.5px; height: 25.5px; border-width: 5px"></div><div style="left: 82px; top: 45px; width: 25px; height: 24px; border-width: 6px"></div>
-<div style="left: 21.5px; top: 73.5px; border-width: 7px; width: 23.5px; height: 24px;"></div><div style="left: 51px; top: 73px; width: 22px; height: 23px; border-width: 8px"></div><div style="left: 80.5px; top: 72.5px; width: 22px; height: 22px; border-width: 9px"></div>
+<div style="left: 25px; top: 21px; border-width: 1px"></div><div style="left: 54px; top: 20.5px; width: 28.5px; height: 26px; border-width: 2px"></div><div style="left: 84px; top: 20px; width: 28px; height: 25px; border-width: 3px"></div>
+<div style="left: 23.5px; top: 46px; border-width: 4px; width: 26px; height: 26.5px"></div><div style="left: 52.5px; top: 45.5px; width: 25.5px; height: 25.5px; border-width: 5px"></div><div style="left: 82.5px; top: 45px; width: 25px; height: 24px; border-width: 6px"></div>
+<div style="left: 22px; top: 74px; border-width: 7px; width: 23px; height: 24px;"></div><div style="left: 51px; top: 73.5px; width: 22px; height: 23px; border-width: 8px"></div><div style="left: 81px; top: 73px; width: 22px; height: 22px; border-width: 9px"></div>
 
 
-<div style="left: 24.5px; top: 119.5px; border-width: 1px; width: 22px; height: 26px;"></div><div style="left: 47.5px; top: 118.5px; width: 24px; height: 24px; border-width: 3px"></div><div style="left: 72.5px; top: 117.5px; width: 22px; height: 22px; border-width: 5px"></div>
-<div style="left: 24.5px; top: 146.5px; border-width: 1px; width: 22px; height: 26px;"></div><div style="left: 47.5px; top: 145.5px; width: 24px; height: 24px; border-width: 3px"></div><div style="left: 72.5px; top: 144.5px; width: 22px; height: 22px; border-width: 5px"></div>
-<div style="left: 24.5px; top: 173.5px; border-width: 1px; width: 22px; height: 26px;"></div><div style="left: 47.5px; top: 172.5px; width: 24px; height: 24px; border-width: 3px"></div><div style="left: 72.5px; top: 171.5px; width: 22px; height: 22px; border-width: 5px"></div>
+<div style="left: 25px; top: 120px; border-width: 1px; width: 22px; height: 26px;"></div><div style="left: 48px; top: 119px; width: 24px; height: 24px; border-width: 3px"></div><div style="left: 73px; top: 118px; width: 22px; height: 22px; border-width: 5px"></div>
+<div style="left: 25px; top: 147px; border-width: 1px; width: 22px; height: 26px;"></div><div style="left: 48px; top: 146px; width: 24px; height: 24px; border-width: 3px"></div><div style="left: 73px; top: 145px; width: 22px; height: 22px; border-width: 5px"></div>
+<div style="left: 25px; top: 174px; border-width: 1px; width: 22px; height: 26px;"></div><div style="left: 48px; top: 173px; width: 24px; height: 24px; border-width: 3px"></div><div style="left: 73px; top: 172px; width: 22px; height: 22px; border-width: 5px"></div>
 
-<div style="left: 24.5px; top: 210.5px; border-width: 1px; width: 34px; height: 26px;"></div><div style="left: 59.5px; top: 209.5px; width: 34px; height: 24px; border-width: 3px"></div><div style="left: 96.5px; top: 208.5px; width: 34px; height: 22px; border-width: 5px"></div>
-<div style="left: 21.5px; top: 237.5px; border-width: 7px; width: 30px; height: 26px;"></div><div style="left: 56.5px; top: 236.5px; width: 30px; height: 24px; border-width: 9px"></div><div style="left: 93.5px; top: 235.5px; width: 28px; height: 22px; border-width: 11px"></div>
-<div style="left: 18.5px; top: 270.5px; border-width: 13px; width: 24px; height: 26px;"></div><div style="left: 53.5px; top: 269.5px; width: 24px; height: 24px; border-width: 15px"></div><div style="left: 90.5px; top: 268.5px; width: 22px; height: 22px; border-width: 17px"></div>
+<div style="left: 25px; top: 211px; border-width: 1px; width: 34px; height: 26px;"></div><div style="left: 60px; top: 210px; width: 34px; height: 24px; border-width: 3px"></div><div style="left: 97px; top: 209px; width: 34px; height: 22px; border-width: 5px"></div>
+<div style="left: 22px; top: 238px; border-width: 7px; width: 30px; height: 26px;"></div><div style="left: 57px; top: 237px; width: 30px; height: 24px; border-width: 9px"></div><div style="left: 94px; top: 236px; width: 28px; height: 22px; border-width: 11px"></div>
+<div style="left: 19px; top: 271px; border-width: 13px; width: 24px; height: 26px;"></div><div style="left: 54px; top: 270px; width: 24px; height: 24px; border-width: 15px"></div><div style="left: 91px; top: 269px; width: 22px; height: 22px; border-width: 17px"></div>
 
 </html>
\ No newline at end of file
index 8709682..16c742d 100644 (file)
@@ -2953,8 +2953,6 @@ webkit.org/b/76121 imported/blink/fast/events/event-trusted.html [ Skip ]
 
 webkit.org/b/154253 animations/animation-delay-changed.html [ Pass Failure ]
 
-webkit.org/b/155036 fast/table/table-overflow.html [ Skip ]
-
 # Uncategorized reftest failures, uncovered once we made reftests work. Needs triage.
 css3/font-variant-petite-caps-synthesis-coverage.html [ ImageOnlyFailure ]
 css3/font-variant-small-caps-synthesis-coverage.html [ ImageOnlyFailure ]
index bd6fc5c..d066f3b 100644 (file)
@@ -1,3 +1,37 @@
+2016-03-05  Zalan Bujtas  <zalan@apple.com>
+
+        Make table collapsed borders subpixel aware.
+        https://bugs.webkit.org/show_bug.cgi?id=150383
+
+        Reviewed by Simon Fraser.
+
+        This patch enables authors to 
+        - set subpixel width on collapsed borders
+        - and push those borders to subpixel positions.
+
+        Test: fast/table/collapsed-border-with-odd-pixel-width.html
+
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::calcBorderStart):
+        (WebCore::RenderTable::calcBorderEnd):
+        (WebCore::RenderTable::outerBorderBefore):
+        (WebCore::RenderTable::outerBorderAfter):
+        (WebCore::RenderTable::outerBorderStart):
+        (WebCore::RenderTable::outerBorderEnd):
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::borderHalfStart):
+        (WebCore::RenderTableCell::borderHalfEnd):
+        (WebCore::RenderTableCell::borderHalfBefore):
+        (WebCore::RenderTableCell::borderHalfAfter):
+        (WebCore::RenderTableCell::paintCollapsedBorders):
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::calcOuterBorderBefore):
+        (WebCore::RenderTableSection::calcOuterBorderAfter):
+        (WebCore::RenderTableSection::calcOuterBorderStart):
+        (WebCore::RenderTableSection::calcOuterBorderEnd):
+        * rendering/style/CollapsedBorderValue.h:
+        (WebCore::CollapsedBorderValue::adjustedCollapsedBorderWidth):
+
 2016-03-05  Sam Weinig  <sam@webkit.org>
 
         Add support for processing the autofill field name out of form control elements ultimately to aid input methods
index 7348b36..f66b0ad 100644 (file)
@@ -1117,7 +1117,7 @@ LayoutUnit RenderTable::calcBorderStart() const
                 borderWidth = std::max(borderWidth, firstRowAdjoiningBorder.width());
         }
     }
-    return floorToInt((borderWidth + (style().isLeftToRightDirection() ? 0 : 1)) / 2);
+    return CollapsedBorderValue::adjustedCollapsedBorderWidth(borderWidth, document().deviceScaleFactor(), !style().isLeftToRightDirection());
 }
 
 LayoutUnit RenderTable::calcBorderEnd() const
@@ -1172,7 +1172,7 @@ LayoutUnit RenderTable::calcBorderEnd() const
                 borderWidth = std::max(borderWidth, firstRowAdjoiningBorder.width());
         }
     }
-    return floorToInt((borderWidth + (style().isLeftToRightDirection() ? 1 : 0)) / 2);
+    return CollapsedBorderValue::adjustedCollapsedBorderWidth(borderWidth, document().deviceScaleFactor(), style().isLeftToRightDirection());
 }
 
 void RenderTable::recalcBordersInRowDirection()
@@ -1213,8 +1213,10 @@ LayoutUnit RenderTable::outerBorderBefore() const
     const BorderValue& tb = style().borderBefore();
     if (tb.style() == BHIDDEN)
         return 0;
-    if (tb.style() > BHIDDEN)
-        borderWidth = floorToInt(std::max<LayoutUnit>(borderWidth, tb.width() / 2));
+    if (tb.style() > BHIDDEN) {
+        LayoutUnit collapsedBorderWidth = std::max<LayoutUnit>(borderWidth, tb.width() / 2);
+        borderWidth = floorToDevicePixel(collapsedBorderWidth, document().deviceScaleFactor());
+    }
     return borderWidth;
 }
 
@@ -1232,8 +1234,11 @@ LayoutUnit RenderTable::outerBorderAfter() const
     const BorderValue& tb = style().borderAfter();
     if (tb.style() == BHIDDEN)
         return 0;
-    if (tb.style() > BHIDDEN)
-        borderWidth = floorToInt(std::max<LayoutUnit>(borderWidth, (tb.width() + 1) / 2));
+    if (tb.style() > BHIDDEN) {
+        float deviceScaleFactor = document().deviceScaleFactor();
+        LayoutUnit collapsedBorderWidth = std::max<LayoutUnit>(borderWidth, (tb.width() + (1 / deviceScaleFactor)) / 2);
+        borderWidth = floorToDevicePixel(collapsedBorderWidth, deviceScaleFactor);
+    }
     return borderWidth;
 }
 
@@ -1248,7 +1253,7 @@ LayoutUnit RenderTable::outerBorderStart() const
     if (tb.style() == BHIDDEN)
         return 0;
     if (tb.style() > BHIDDEN)
-        borderWidth = floorToInt((tb.width() + (style().isLeftToRightDirection() ? 0 : 1)) / 2);
+        return CollapsedBorderValue::adjustedCollapsedBorderWidth(tb.width(), document().deviceScaleFactor(), !style().isLeftToRightDirection());
 
     bool allHidden = true;
     for (RenderTableSection* section = topSection(); section; section = sectionBelow(section)) {
@@ -1275,7 +1280,7 @@ LayoutUnit RenderTable::outerBorderEnd() const
     if (tb.style() == BHIDDEN)
         return 0;
     if (tb.style() > BHIDDEN)
-        borderWidth = floorToInt((tb.width() + (style().isLeftToRightDirection() ? 1 : 0)) / 2);
+        return CollapsedBorderValue::adjustedCollapsedBorderWidth(tb.width(), document().deviceScaleFactor(), style().isLeftToRightDirection());
 
     bool allHidden = true;
     for (RenderTableSection* section = topSection(); section; section = sectionBelow(section)) {
index f65a636..2f9b11d 100644 (file)
@@ -1054,7 +1054,7 @@ LayoutUnit RenderTableCell::borderHalfStart(bool outer) const
 {
     CollapsedBorderValue border = collapsedStartBorder(DoNotIncludeBorderColor);
     if (border.exists())
-        return floorToInt((border.width() + ((styleForCellFlow().isLeftToRightDirection() ^ outer) ? 1 : 0)) / 2); // Give the extra pixel to top and left.
+        return CollapsedBorderValue::adjustedCollapsedBorderWidth(border.width(), document().deviceScaleFactor(), styleForCellFlow().isLeftToRightDirection() ^ outer);
     return 0;
 }
     
@@ -1062,7 +1062,7 @@ LayoutUnit RenderTableCell::borderHalfEnd(bool outer) const
 {
     CollapsedBorderValue border = collapsedEndBorder(DoNotIncludeBorderColor);
     if (border.exists())
-        return floorToInt((border.width() + ((styleForCellFlow().isLeftToRightDirection() ^ outer) ? 0 : 1)) / 2);
+        return CollapsedBorderValue::adjustedCollapsedBorderWidth(border.width(), document().deviceScaleFactor(), !(styleForCellFlow().isLeftToRightDirection() ^ outer));
     return 0;
 }
 
@@ -1070,7 +1070,7 @@ LayoutUnit RenderTableCell::borderHalfBefore(bool outer) const
 {
     CollapsedBorderValue border = collapsedBeforeBorder(DoNotIncludeBorderColor);
     if (border.exists())
-        return floorToInt((border.width() + ((styleForCellFlow().isFlippedBlocksWritingMode() ^ outer) ? 0 : 1)) / 2); // Give the extra pixel to top and left.
+        return CollapsedBorderValue::adjustedCollapsedBorderWidth(border.width(), document().deviceScaleFactor(), !(styleForCellFlow().isFlippedBlocksWritingMode() ^ outer));
     return 0;
 }
 
@@ -1078,7 +1078,7 @@ LayoutUnit RenderTableCell::borderHalfAfter(bool outer) const
 {
     CollapsedBorderValue border = collapsedAfterBorder(DoNotIncludeBorderColor);
     if (border.exists())
-        return floorToInt((border.width() + ((styleForCellFlow().isFlippedBlocksWritingMode() ^ outer) ? 1 : 0)) / 2);
+        return CollapsedBorderValue::adjustedCollapsedBorderWidth(border.width(), document().deviceScaleFactor(), styleForCellFlow().isFlippedBlocksWritingMode() ^ outer);
     return 0;
 }
 
@@ -1205,20 +1205,25 @@ void RenderTableCell::paintCollapsedBorders(PaintInfo& paintInfo, const LayoutPo
     LayoutUnit rightWidth = rightVal.width();
 
     float deviceScaleFactor = document().deviceScaleFactor();
-    LayoutRect borderRect = LayoutRect(paintRect.x() - floorToDevicePixel(leftWidth / 2, deviceScaleFactor),
-        paintRect.y() - floorToDevicePixel(topWidth / 2, deviceScaleFactor),
-        paintRect.width() + floorToDevicePixel(leftWidth / 2, deviceScaleFactor) + floorToDevicePixel(rightWidth / 2, deviceScaleFactor),
-        paintRect.height() + floorToDevicePixel(topWidth / 2, deviceScaleFactor) + floorToDevicePixel(bottomWidth / 2, deviceScaleFactor));
+    LayoutUnit leftHalfCollapsedBorder = CollapsedBorderValue::adjustedCollapsedBorderWidth(leftWidth , deviceScaleFactor, false);
+    LayoutUnit topHalfCollapsedBorder = CollapsedBorderValue::adjustedCollapsedBorderWidth(topWidth, deviceScaleFactor, false);
+    LayoutUnit righHalftCollapsedBorder = CollapsedBorderValue::adjustedCollapsedBorderWidth(rightWidth, deviceScaleFactor, true);
+    LayoutUnit bottomHalfCollapsedBorder = CollapsedBorderValue::adjustedCollapsedBorderWidth(bottomWidth, deviceScaleFactor, true);
     
+    LayoutRect borderRect = LayoutRect(paintRect.x() - leftHalfCollapsedBorder,
+        paintRect.y() - topHalfCollapsedBorder,
+        paintRect.width() + leftHalfCollapsedBorder + righHalftCollapsedBorder,
+        paintRect.height() + topHalfCollapsedBorder + bottomHalfCollapsedBorder);
+
     EBorderStyle topStyle = collapsedBorderStyle(topVal.style());
     EBorderStyle bottomStyle = collapsedBorderStyle(bottomVal.style());
     EBorderStyle leftStyle = collapsedBorderStyle(leftVal.style());
     EBorderStyle rightStyle = collapsedBorderStyle(rightVal.style());
     
-    bool renderTop = topStyle > BHIDDEN && !topVal.isTransparent() && floorToInt(topWidth);
-    bool renderBottom = bottomStyle > BHIDDEN && !bottomVal.isTransparent() && floorToInt(bottomWidth);
-    bool renderLeft = leftStyle > BHIDDEN && !leftVal.isTransparent() && floorToInt(leftWidth);
-    bool renderRight = rightStyle > BHIDDEN && !rightVal.isTransparent() && floorToInt(rightWidth);
+    bool renderTop = topStyle > BHIDDEN && !topVal.isTransparent() && floorToDevicePixel(topWidth, deviceScaleFactor);
+    bool renderBottom = bottomStyle > BHIDDEN && !bottomVal.isTransparent() && floorToDevicePixel(bottomWidth, deviceScaleFactor);
+    bool renderLeft = leftStyle > BHIDDEN && !leftVal.isTransparent() && floorToDevicePixel(leftWidth, deviceScaleFactor);
+    bool renderRight = rightStyle > BHIDDEN && !rightVal.isTransparent() && floorToDevicePixel(rightWidth, deviceScaleFactor);
 
     // We never paint diagonals at the joins.  We simply let the border with the highest
     // precedence paint on top of borders with lower precedence.  
index 1907657..ef59feb 100644 (file)
@@ -759,8 +759,7 @@ LayoutUnit RenderTableSection::calcOuterBorderBefore() const
     }
     if (allHidden)
         return -1;
-
-    return floorToInt(borderWidth / 2);
+    return CollapsedBorderValue::adjustedCollapsedBorderWidth(borderWidth, document().deviceScaleFactor(), false);
 }
 
 LayoutUnit RenderTableSection::calcOuterBorderAfter() const
@@ -810,8 +809,7 @@ LayoutUnit RenderTableSection::calcOuterBorderAfter() const
     }
     if (allHidden)
         return -1;
-
-    return floorToInt((borderWidth + 1) / 2);
+    return CollapsedBorderValue::adjustedCollapsedBorderWidth(borderWidth, document().deviceScaleFactor(), true);
 }
 
 LayoutUnit RenderTableSection::calcOuterBorderStart() const
@@ -854,8 +852,7 @@ LayoutUnit RenderTableSection::calcOuterBorderStart() const
     }
     if (allHidden)
         return -1;
-
-    return floorToInt((borderWidth + (table()->style().isLeftToRightDirection() ? 0 : 1)) / 2);
+    return CollapsedBorderValue::adjustedCollapsedBorderWidth(borderWidth, document().deviceScaleFactor(), !table()->style().isLeftToRightDirection());
 }
 
 LayoutUnit RenderTableSection::calcOuterBorderEnd() const
@@ -898,8 +895,7 @@ LayoutUnit RenderTableSection::calcOuterBorderEnd() const
     }
     if (allHidden)
         return -1;
-
-    return floorToInt((borderWidth + (table()->style().isLeftToRightDirection() ? 1 : 0)) / 2);
+    return CollapsedBorderValue::adjustedCollapsedBorderWidth(borderWidth, document().deviceScaleFactor(), table()->style().isLeftToRightDirection());
 }
 
 void RenderTableSection::recalcOuterBorder()
index da9c53a..6e9b328 100644 (file)
@@ -62,6 +62,8 @@ public:
         return width() == o.width() && style() == o.style() && precedence() == o.precedence();
     }
 
+    static LayoutUnit adjustedCollapsedBorderWidth(float borderWidth, float deviceScaleFactor, bool roundUp);
+
 private:
     LayoutUnit m_width;
     RGBA32 m_color { 0 };
@@ -71,6 +73,12 @@ private:
     unsigned m_transparent : 1;
 };
 
+inline LayoutUnit CollapsedBorderValue::adjustedCollapsedBorderWidth(float borderWidth, float deviceScaleFactor, bool roundUp)
+{
+    float halfCollapsedBorderWidth = (borderWidth + (roundUp ? (1 / deviceScaleFactor) : 0)) / 2;
+    return floorToDevicePixel(halfCollapsedBorderWidth, deviceScaleFactor);
+}
+
 } // namespace WebCore
 
 #endif // CollapsedBorderValue_h