- Revision
- 201907
- Author
- [email protected]
- Date
- 2016-06-09 22:27:11 -0700 (Thu, 09 Jun 2016)
Log Message
Hairline borders do not show up on 3x displays.
https://bugs.webkit.org/show_bug.cgi?id=158604
<rdar://problem/26511679>
Reviewed by Simon Fraser.
On a 3x display, when we convert a 1/3px hairline border from float
to LayoutUnit and pixel floor the result, we end up with a 0px width border.
It's because float to LayoutUnit is lossy and since the current kFixedPointDenominator % 3 != 0,
flooring LayoutUnit(1/3px) ends up being 0px. (float: 1/3 -> LayoutUnit: (1/3 - 1/kFixedPointDenominator) -> floor: 0)
This patch eliminates the (unnecessary) float -> LayoutUnit - float conversion on border width.
Source/WebCore:
Test: fast/borders/hidpi-3x-input-hairline-border.html
* rendering/BorderEdge.cpp:
(WebCore::BorderEdge::BorderEdge):
* rendering/BorderEdge.h:
LayoutTests:
* fast/borders/hidpi-3x-input-hairline-border-expected-mismatch.html: Added.
* fast/borders/hidpi-3x-input-hairline-border.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (201906 => 201907)
--- trunk/LayoutTests/ChangeLog 2016-06-10 05:24:46 UTC (rev 201906)
+++ trunk/LayoutTests/ChangeLog 2016-06-10 05:27:11 UTC (rev 201907)
@@ -1,3 +1,20 @@
+2016-06-09 Zalan Bujtas <[email protected]>
+
+ Hairline borders do not show up on 3x displays.
+ https://bugs.webkit.org/show_bug.cgi?id=158604
+ <rdar://problem/26511679>
+
+ Reviewed by Simon Fraser.
+
+ On a 3x display, when we convert a 1/3px hairline border from float
+ to LayoutUnit and pixel floor the result, we end up with a 0px width border.
+ It's because float to LayoutUnit is lossy and since the current kFixedPointDenominator % 3 != 0,
+ flooring LayoutUnit(1/3px) ends up being 0px. (float: 1/3 -> LayoutUnit: (1/3 - 1/kFixedPointDenominator) -> floor: 0)
+ This patch eliminates the (unnecessary) float -> LayoutUnit - float conversion on border width.
+
+ * fast/borders/hidpi-3x-input-hairline-border-expected-mismatch.html: Added.
+ * fast/borders/hidpi-3x-input-hairline-border.html: Added.
+
2016-06-09 Commit Queue <[email protected]>
Unreviewed, rolling out r201887.
Added: trunk/LayoutTests/fast/borders/hidpi-3x-input-hairline-border-expected-mismatch.html (0 => 201907)
--- trunk/LayoutTests/fast/borders/hidpi-3x-input-hairline-border-expected-mismatch.html (rev 0)
+++ trunk/LayoutTests/fast/borders/hidpi-3x-input-hairline-border-expected-mismatch.html 2016-06-10 05:27:11 UTC (rev 201907)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we draw hairline borders on 3x display.</title>
+</head>
+<body></body>
+</html>
Added: trunk/LayoutTests/fast/borders/hidpi-3x-input-hairline-border.html (0 => 201907)
--- trunk/LayoutTests/fast/borders/hidpi-3x-input-hairline-border.html (rev 0)
+++ trunk/LayoutTests/fast/borders/hidpi-3x-input-hairline-border.html 2016-06-10 05:27:11 UTC (rev 201907)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we draw hairline borders on 3x display.</title>
+<style>
+div {
+ width: 10px;
+ height: 10px;
+ margin: 1px;
+ border-style: solid;
+ border-color: green;
+}
+</style>
+</head>
+<body>
+<script>
+for (var i = 0.34; i < 0.66; i = i + 0.01) {
+ var element = document.createElement("div");
+ element.style.borderWidth = i + "px";
+ document.body.appendChild(element);
+}
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (201906 => 201907)
--- trunk/Source/WebCore/ChangeLog 2016-06-10 05:24:46 UTC (rev 201906)
+++ trunk/Source/WebCore/ChangeLog 2016-06-10 05:27:11 UTC (rev 201907)
@@ -1,3 +1,23 @@
+2016-06-09 Zalan Bujtas <[email protected]>
+
+ Hairline borders do not show up on 3x displays.
+ https://bugs.webkit.org/show_bug.cgi?id=158604
+ <rdar://problem/26511679>
+
+ Reviewed by Simon Fraser.
+
+ On a 3x display, when we convert a 1/3px hairline border from float
+ to LayoutUnit and pixel floor the result, we end up with a 0px width border.
+ It's because float to LayoutUnit is lossy and since the current kFixedPointDenominator % 3 != 0,
+ flooring LayoutUnit(1/3px) ends up being 0px. (float: 1/3 -> LayoutUnit: (1/3 - 1/kFixedPointDenominator) -> floor: 0)
+ This patch eliminates the (unnecessary) float -> LayoutUnit - float conversion on border width.
+
+ Test: fast/borders/hidpi-3x-input-hairline-border.html
+
+ * rendering/BorderEdge.cpp:
+ (WebCore::BorderEdge::BorderEdge):
+ * rendering/BorderEdge.h:
+
2016-06-09 Commit Queue <[email protected]>
Unreviewed, rolling out r201887.
Modified: trunk/Source/WebCore/rendering/BorderEdge.cpp (201906 => 201907)
--- trunk/Source/WebCore/rendering/BorderEdge.cpp 2016-06-10 05:24:46 UTC (rev 201906)
+++ trunk/Source/WebCore/rendering/BorderEdge.cpp 2016-06-10 05:27:11 UTC (rev 201907)
@@ -33,7 +33,7 @@
namespace WebCore {
-BorderEdge::BorderEdge(LayoutUnit edgeWidth, Color edgeColor, EBorderStyle edgeStyle, bool edgeIsTransparent, bool edgeIsPresent, float devicePixelRatio)
+BorderEdge::BorderEdge(float edgeWidth, Color edgeColor, EBorderStyle edgeStyle, bool edgeIsTransparent, bool edgeIsPresent, float devicePixelRatio)
: m_width(edgeWidth)
, m_color(edgeColor)
, m_style(edgeStyle)
@@ -43,7 +43,7 @@
{
if (edgeStyle == DOUBLE && edgeWidth < borderWidthInDevicePixel(3))
m_style = SOLID;
- m_flooredToDevicePixelWidth = floorToDevicePixel(edgeWidth, devicePixelRatio);
+ m_flooredToDevicePixelWidth = floorf(edgeWidth * devicePixelRatio) / devicePixelRatio;
}
void BorderEdge::getBorderEdgeInfo(BorderEdge edges[], const RenderStyle& style, float deviceScaleFactor, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
Modified: trunk/Source/WebCore/rendering/BorderEdge.h (201906 => 201907)
--- trunk/Source/WebCore/rendering/BorderEdge.h 2016-06-10 05:24:46 UTC (rev 201906)
+++ trunk/Source/WebCore/rendering/BorderEdge.h 2016-06-10 05:27:11 UTC (rev 201907)
@@ -46,7 +46,7 @@
};
BorderEdge() = default;
- BorderEdge(LayoutUnit edgeWidth, Color edgeColor, EBorderStyle edgeStyle, bool edgeIsTransparent, bool edgeIsPresent, float devicePixelRatio);
+ BorderEdge(float edgeWidth, Color edgeColor, EBorderStyle edgeStyle, bool edgeIsTransparent, bool edgeIsPresent, float devicePixelRatio);
static void getBorderEdgeInfo(BorderEdge edges[], const RenderStyle&, float deviceScaleFactor, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);