Title: [237955] trunk
Revision
237955
Author
[email protected]
Date
2018-11-07 17:08:33 -0800 (Wed, 07 Nov 2018)

Log Message

Positioned text underline can look like a strike-through
https://bugs.webkit.org/show_bug.cgi?id=191341

Reviewed by Simon Fraser.

Source/WebCore:

We should just clamp the value so it can't go above the baseline.

We shouldn't do this at parse time because it's totally reasonable for text-underline-position: under to want
a negative text-underline-offset. Instead, we just do it at used value time.

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

* style/InlineTextBoxStyle.cpp:
(WebCore::computeUnderlineOffset):

LayoutTests:

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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (237954 => 237955)


--- trunk/LayoutTests/ChangeLog	2018-11-08 00:46:00 UTC (rev 237954)
+++ trunk/LayoutTests/ChangeLog	2018-11-08 01:08:33 UTC (rev 237955)
@@ -1,5 +1,15 @@
 2018-11-07  Myles C. Maxfield  <[email protected]>
 
+        Positioned text underline can look like a strike-through
+        https://bugs.webkit.org/show_bug.cgi?id=191341
+
+        Reviewed by Simon Fraser.
+
+        * fast/css3-text/css3-text-decoration/text-underline-negative-expected.html: Added.
+        * fast/css3-text/css3-text-decoration/text-underline-negative.html: Added.
+
+2018-11-07  Myles C. Maxfield  <[email protected]>
+
         Dotted underlines that skip descenders are invisible
         https://bugs.webkit.org/show_bug.cgi?id=191403
 

Added: trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-underline-negative-expected.html (0 => 237955)


--- trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-underline-negative-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-underline-negative-expected.html	2018-11-08 01:08:33 UTC (rev 237955)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure you can't place an underline to make it look like a line-through. The test passes if all the underlines are in the correct place.
+<div style="font: 100px 'Ahem'; text-decoration: underline; -webkit-text-decoration-color: green; text-underline-offset: 0px; -webkit-text-decoration-skip: none;">&#xc9;<span style="text-underline-offset: 13px;">&#xc9;<span style="text-underline-offset: 23px;">&#xc9;</span></span></div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-underline-negative.html (0 => 237955)


--- trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-underline-negative.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-underline-negative.html	2018-11-08 01:08:33 UTC (rev 237955)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure you can't place an underline to make it look like a line-through. The test passes if all the underlines are in the correct place.
+<div style="font: 100px 'Ahem'; text-decoration: underline; -webkit-text-decoration-color: green; text-underline-offset: -10px; -webkit-text-decoration-skip: none;">&#xc9;<span style="text-underline-position: under;">&#xc9;<span style="text-underline-offset: auto;">&#xc9;</span></span></div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (237954 => 237955)


--- trunk/Source/WebCore/ChangeLog	2018-11-08 00:46:00 UTC (rev 237954)
+++ trunk/Source/WebCore/ChangeLog	2018-11-08 01:08:33 UTC (rev 237955)
@@ -1,3 +1,20 @@
+2018-11-07  Myles C. Maxfield  <[email protected]>
+
+        Positioned text underline can look like a strike-through
+        https://bugs.webkit.org/show_bug.cgi?id=191341
+
+        Reviewed by Simon Fraser.
+
+        We should just clamp the value so it can't go above the baseline.
+
+        We shouldn't do this at parse time because it's totally reasonable for text-underline-position: under to want
+        a negative text-underline-offset. Instead, we just do it at used value time.
+
+        Test: fast/css3-text/css3-text-decoration/text-underline-negative.html
+
+        * style/InlineTextBoxStyle.cpp:
+        (WebCore::computeUnderlineOffset):
+
 2018-11-07  Chris Dumez  <[email protected]>
 
         Unreviewed, fix iOS build with recent SDKs.

Modified: trunk/Source/WebCore/style/InlineTextBoxStyle.cpp (237954 => 237955)


--- trunk/Source/WebCore/style/InlineTextBoxStyle.cpp	2018-11-08 00:46:00 UTC (rev 237954)
+++ trunk/Source/WebCore/style/InlineTextBoxStyle.cpp	2018-11-08 01:08:33 UTC (rev 237955)
@@ -32,10 +32,10 @@
 
 namespace WebCore {
     
-int computeUnderlineOffset(TextUnderlinePosition underlinePosition, TextUnderlineOffset underlineOffset, const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, int textDecorationThickness)
+int computeUnderlineOffset(TextUnderlinePosition underlinePosition, TextUnderlineOffset underlineOffset, const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, int defaultGap)
 {
     // This represents the gap between the baseline and the closest edge of the underline.
-    int gap = std::max<int>(1, ceilf(textDecorationThickness / 2.0));
+    int gap = std::max<int>(1, ceilf(defaultGap / 2.0));
     
     // FIXME: The code for visual overflow detection passes in a null inline text box. This means it is now
     // broken for the case where auto needs to behave like "under".
@@ -59,9 +59,9 @@
     case TextUnderlinePosition::Auto:
         if (underlineOffset.isAuto())
             return fontMetrics.ascent() + gap;
-        return fontMetrics.ascent() + underlineOffset.lengthValue();
+        return fontMetrics.ascent() + std::max(0.0f, underlineOffset.lengthValue());
     case TextUnderlinePosition::FromFont:
-        return fontMetrics.ascent() + fontMetrics.underlinePosition() + underlineOffset.lengthOr(0);
+        return fontMetrics.ascent() + std::max(0.0f, fontMetrics.underlinePosition() + underlineOffset.lengthOr(0));
     case TextUnderlinePosition::Under: {
         ASSERT(inlineTextBox);
         // Position underline relative to the bottom edge of the lowest element's content box.
@@ -78,7 +78,9 @@
             rootBox.maxLogicalBottomForTextDecorationLine(offset, decorationRenderer, TextDecoration::Underline);
             offset -= inlineTextBox->logicalBottom();
         }
-        return inlineTextBox->logicalHeight() + gap + std::max<float>(offset, 0) + underlineOffset.lengthOr(0);
+        auto desiredOffset = inlineTextBox->logicalHeight() + gap + std::max<float>(offset, 0) + underlineOffset.lengthOr(0);
+        desiredOffset = std::max<float>(desiredOffset, fontMetrics.ascent());
+        return desiredOffset;
     }
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to