text-decoration: line-through is mispositioned when text has overline/underline too.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Dec 2015 19:57:25 +0000 (19:57 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Dec 2015 19:57:25 +0000 (19:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152619

Reviewed by Simon Fraser.

Line-through painting was mistakenly calling drawLineForText with overline/underline positioning.

Source/WebCore:

Test: fast/css3-text/css3-text-decoration/text-decoration-line-through-mispositioned.html

* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paintDecoration): Deleted.
* rendering/TextDecorationPainter.cpp:
(WebCore::TextDecorationPainter::paintTextDecoration):

LayoutTests:

* fast/css3-text/css3-text-decoration/text-decoration-line-through-mispositioned-expected.html: Added.
* fast/css3-text/css3-text-decoration/text-decoration-line-through-mispositioned.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-line-through-mispositioned-expected.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-line-through-mispositioned.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/TextDecorationPainter.cpp

index dad3d34..e2c3b39 100644 (file)
@@ -1,5 +1,17 @@
 2015-12-31  Zalan Bujtas  <zalan@apple.com>
 
+        text-decoration: line-through is mispositioned when text has overline/underline too.
+        https://bugs.webkit.org/show_bug.cgi?id=152619
+
+        Reviewed by Simon Fraser.
+
+        Line-through painting was mistakenly calling drawLineForText with overline/underline positioning.
+
+        * fast/css3-text/css3-text-decoration/text-decoration-line-through-mispositioned-expected.html: Added.
+        * fast/css3-text/css3-text-decoration/text-decoration-line-through-mispositioned.html: Added.
+
+2015-12-31  Zalan Bujtas  <zalan@apple.com>
+
         Simple line layout: Text with stroke width is not positioned correctly.
         https://bugs.webkit.org/show_bug.cgi?id=152614
 
diff --git a/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-line-through-mispositioned-expected.html b/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-line-through-mispositioned-expected.html
new file mode 100644 (file)
index 0000000..5d4c785
--- /dev/null
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that line-through is positioned properly.</title>
+<style>
+  div {
+    border-top: 3px solid green;
+    position: absolute;
+    left: 20px;
+    top: 33px;
+    width: 120px;
+    height: 1px;
+  }
+</style>
+</head>
+<body>
+<div></div>
+</body>
+</html>
diff --git a/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-line-through-mispositioned.html b/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-line-through-mispositioned.html
new file mode 100644 (file)
index 0000000..0963c93
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that line-through is positioned properly.</title>
+<style>
+  body {
+       font-family: Ahem; 
+       font-size: 48px;
+       color: white;
+  } 
+  #blue-underline {
+    text-decoration: underline;
+    -webkit-text-decoration-color: white;
+  }
+  #green-line-through {
+    text-decoration: line-through;
+    -webkit-text-decoration-color: green;
+  }
+  
+  div {
+       position: relative;
+       top: 0px;
+       left: 0px;
+  }
+  
+</style>
+</head>
+<body>
+<div id="blue-underline">
+  <div id="green-line-through">foo</div>
+</div>
+<div style="position: absolute; left: 0px; top: 20px; width: 20px; height: 20px; background-color: white"></div>
+<div style="position: absolute; left: 140px; top: 20px; width: 20px; height: 20px; background-color: white"></div>
+</body>
+</html>
index e0e7863..1ea6207 100644 (file)
@@ -1,3 +1,19 @@
+2015-12-31  Zalan Bujtas  <zalan@apple.com>
+
+        text-decoration: line-through is mispositioned when text has overline/underline too.
+        https://bugs.webkit.org/show_bug.cgi?id=152619
+
+        Reviewed by Simon Fraser.
+
+        Line-through painting was mistakenly calling drawLineForText with overline/underline positioning.
+
+        Test: fast/css3-text/css3-text-decoration/text-decoration-line-through-mispositioned.html
+
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::paintDecoration): Deleted.
+        * rendering/TextDecorationPainter.cpp:
+        (WebCore::TextDecorationPainter::paintTextDecoration):
+
 2015-12-31  Simon Fraser  <simon.fraser@apple.com>
 
         Clarify that scrollPositionChangedViaPlatformWidget takes offsets
index 91bb9d1..d0c26c5 100644 (file)
@@ -702,11 +702,6 @@ void InlineTextBox::paintCompositionBackground(GraphicsContext& context, const F
 void InlineTextBox::paintDecoration(GraphicsContext& context, const FontCascade& font, const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& boxOrigin,
     TextDecoration decoration, const ShadowData* shadow)
 {
-#if !ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
-    UNUSED_PARAM(font);
-    UNUSED_PARAM(textRun);
-    UNUSED_PARAM(textOrigin);
-#endif
     if (m_truncation == cFullTruncation)
         return;
 
index 4b1d65e..fc92396 100644 (file)
@@ -255,19 +255,23 @@ TextDecorationPainter::TextDecorationPainter(GraphicsContext& context, TextDecor
 
 void TextDecorationPainter::paintTextDecoration(const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& boxOrigin)
 {
+#if !ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
+    UNUSED_PARAM(textRun);
+    UNUSED_PARAM(textOrigin);
+#endif
     ASSERT(m_font);
     float textDecorationThickness = textDecorationStrokeThickness(m_lineStyle.fontSize());
     m_context.setStrokeThickness(textDecorationThickness);
     FloatPoint localOrigin = boxOrigin;
 
-    auto paintDecoration = [&](TextDecorationStyle style, Color color, StrokeStyle strokeStyle,
+    auto paintDecoration = [&](TextDecoration decoration, TextDecorationStyle style, Color color, StrokeStyle strokeStyle,
         const FloatPoint& start, const FloatPoint& end, int offset) {
         m_context.setStrokeColor(color);
         m_context.setStrokeStyle(strokeStyle);
 
         if (style == TextDecorationStyleWavy) {
             strokeWavyTextDecoration(m_context, start, end, textDecorationThickness);
-        } else if (m_decoration & TextDecorationUnderline || m_decoration & TextDecorationOverline) {
+        } else if (decoration == TextDecorationUnderline || decoration == TextDecorationOverline) {
 #if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
             if ((m_lineStyle.textDecorationSkip() == TextDecorationSkipInk || m_lineStyle.textDecorationSkip() == TextDecorationSkipAuto) && m_isHorizontal) {
                 if (!m_context.paintingDisabled())
@@ -278,7 +282,7 @@ void TextDecorationPainter::paintTextDecoration(const TextRun& textRun, const Fl
                 m_context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + offset), m_width, m_isPrinting, style == TextDecorationStyleDouble);
             
         } else {
-            ASSERT(m_decoration & TextDecorationLineThrough);
+            ASSERT(decoration == TextDecorationLineThrough);
             m_context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + 2 * m_baseline / 3), m_width, m_isPrinting, style == TextDecorationStyleDouble);
         }
     };
@@ -327,17 +331,17 @@ void TextDecorationPainter::paintTextDecoration(const TextRun& textRun, const Fl
             const int offset = computeUnderlineOffset(m_lineStyle.textUnderlinePosition(), m_lineStyle.fontMetrics(), m_inlineTextBox, textDecorationThickness);
             FloatPoint start(localOrigin.x(), localOrigin.y() + offset + m_wavyOffset);
             FloatPoint end(localOrigin.x() + m_width, localOrigin.y() + offset + m_wavyOffset);
-            paintDecoration(m_underlineStyle, m_underlineColor, textDecorationStyleToStrokeStyle(m_underlineStyle), start, end, offset);
+            paintDecoration(TextDecorationUnderline, m_underlineStyle, m_underlineColor, textDecorationStyleToStrokeStyle(m_underlineStyle), start, end, offset);
         }
         if (m_decoration & TextDecorationOverline) {
             FloatPoint start(localOrigin.x(), localOrigin.y() - m_wavyOffset);
             FloatPoint end(localOrigin.x() + m_width, localOrigin.y() - m_wavyOffset);
-            paintDecoration(m_overlineStyle, m_overlineColor, textDecorationStyleToStrokeStyle(m_overlineStyle), start, end, 0);
+            paintDecoration(TextDecorationOverline, m_overlineStyle, m_overlineColor, textDecorationStyleToStrokeStyle(m_overlineStyle), start, end, 0);
         }
         if (m_decoration & TextDecorationLineThrough) {
             FloatPoint start(localOrigin.x(), localOrigin.y() + 2 * m_baseline / 3);
             FloatPoint end(localOrigin.x() + m_width, localOrigin.y() + 2 * m_baseline / 3);
-            paintDecoration(m_linethroughStyle, m_linethroughColor, textDecorationStyleToStrokeStyle(m_linethroughStyle), start, end, 0);
+            paintDecoration(TextDecorationLineThrough, m_linethroughStyle, m_linethroughColor, textDecorationStyleToStrokeStyle(m_linethroughStyle), start, end, 0);
         }
     } while (shadow);