Dotted underlines that skip descenders are invisible
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Nov 2018 00:10:20 +0000 (00:10 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Nov 2018 00:10:20 +0000 (00:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191403

Reviewed by Simon Fraser.

Source/WebCore:

Turns out our underline bounding boxes had negative width. When drawing the full
underline that was fine because it was handled by the 2D graphics engine, but when
we try to split up the box into dots, our "for" loop was taking 0 iterations (because
the end was before the start).

Test: fast/css3-text/css3-text-decoration/text-underline-style.html

* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::drawLineForText):
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::drawLineForText):
* platform/graphics/win/GraphicsContextDirect2D.cpp:
(WebCore::GraphicsContext::drawLineForText):

LayoutTests:

* fast/css3-text/css3-text-decoration/text-underline-style-expected.html: Added.
* fast/css3-text/css3-text-decoration/text-underline-style.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css3-text/css3-text-decoration/text-underline-style-expected.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-text-decoration/text-underline-style.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp

index 4939f6f..51a9966 100644 (file)
@@ -1,3 +1,13 @@
+2018-11-07  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Dotted underlines that skip descenders are invisible
+        https://bugs.webkit.org/show_bug.cgi?id=191403
+
+        Reviewed by Simon Fraser.
+
+        * fast/css3-text/css3-text-decoration/text-underline-style-expected.html: Added.
+        * fast/css3-text/css3-text-decoration/text-underline-style.html: Added.
+
 2018-11-07  Andy Estes  <aestes@apple.com>
 
         Crash in WebCore::PaymentRequest::canMakePayment when Apple Pay payment method data is missing
diff --git a/LayoutTests/fast/css3-text/css3-text-decoration/text-underline-style-expected.html b/LayoutTests/fast/css3-text/css3-text-decoration/text-underline-style-expected.html
new file mode 100644 (file)
index 0000000..1590e6d
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that dotted underlines have the correct dot diameters when underlines have thickness.
+<div style="position: relative;">
+<div style="font: 100px 'Ahem';">&#xc9;&#xc9;&#xc9;&#xc9;</div>
+<div style="position: absolute; left: 0px; top: 80px; width: 50px; height: 50px; background: green;"></div>
+<div style="position: absolute; left: 100px; top: 80px; width: 50px; height: 50px; background: green;"></div>
+<div style="position: absolute; left: 200px; top: 80px; width: 50px; height: 50px; background: green;"></div>
+<div style="position: absolute; left: 300px; top: 80px; width: 50px; height: 50px; background: green;"></div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/css3-text/css3-text-decoration/text-underline-style.html b/LayoutTests/fast/css3-text/css3-text-decoration/text-underline-style.html
new file mode 100644 (file)
index 0000000..811d4cf
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that dotted underlines have the correct dot diameters when underlines have thickness.
+<div style="font: 100px 'Ahem'; text-decoration: underline; -webkit-text-decoration-skip: none; text-underline-offset: 0px; -webkit-text-decoration-color: green; text-decoration-thickness: 50px; -webkit-text-decoration-style: dotted;">&#xc9;&#xc9;&#xc9;&#xc9;</div>
+</body>
+</html>
index 74e74ac..b759b50 100644 (file)
@@ -1,3 +1,24 @@
+2018-11-07  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Dotted underlines that skip descenders are invisible
+        https://bugs.webkit.org/show_bug.cgi?id=191403
+
+        Reviewed by Simon Fraser.
+
+        Turns out our underline bounding boxes had negative width. When drawing the full
+        underline that was fine because it was handled by the 2D graphics engine, but when
+        we try to split up the box into dots, our "for" loop was taking 0 iterations (because
+        the end was before the start).
+
+        Test: fast/css3-text/css3-text-decoration/text-underline-style.html
+
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::drawLineForText):
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::drawLineForText):
+        * platform/graphics/win/GraphicsContextDirect2D.cpp:
+        (WebCore::GraphicsContext::drawLineForText):
+
 2018-11-07  Andy Estes  <aestes@apple.com>
 
         Crash in WebCore::PaymentRequest::canMakePayment when Apple Pay payment method data is missing
index 6d42e33..23f653e 100644 (file)
@@ -318,7 +318,7 @@ void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, float width,
 
 void GraphicsContext::drawLineForText(const FloatRect& rect, bool printing, bool doubleUnderlines, StrokeStyle)
 {
-    drawLinesForText(rect.location(), rect.height(), DashArray { rect.width(), 0 }, printing, doubleUnderlines);
+    drawLinesForText(rect.location(), rect.height(), DashArray { 0, rect.width() }, printing, doubleUnderlines);
 }
 
 void GraphicsContext::drawLinesForText(const FloatPoint& point, float thickness, const DashArray& widths, bool printing, bool doubleUnderlines, StrokeStyle)
index 3749021..2253272 100644 (file)
@@ -1573,8 +1573,8 @@ FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMo
 void GraphicsContext::drawLineForText(const FloatRect& rect, bool printing, bool doubleLines, StrokeStyle strokeStyle)
 {
     DashArray widths;
-    widths.append(rect.width());
     widths.append(0);
+    widths.append(rect.width());
     drawLinesForText(rect.location(), rect.height(), widths, printing, doubleLines, strokeStyle);
 }
 
index ba150c6..97a5820 100644 (file)
@@ -1690,8 +1690,8 @@ FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMo
 void GraphicsContext::drawLineForText(const FloatPoint& point, float width, bool printing, bool doubleLines, StrokeStyle strokeStyle)
 {
     DashArray widths;
-    widths.append(width);
     widths.append(0);
+    widths.append(width);
     drawLinesForText(point, widths, printing, doubleLines, strokeStyle);
 }