text-decoration-skip: ink does not work with line wraps
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jan 2014 01:29:56 +0000 (01:29 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jan 2014 01:29:56 +0000 (01:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126729

Reviewed by Simon Fraser.

Source/WebCore:

InlineTextBox's m_start and m_length fields are offsets into the renderer's string,
not the generated TextRun. Because of this distinction, when multiple InlineTextBoxes
were constructed for the same element, all the subsequent elements would use incorrect
indices and therefore not have skipping decorations.

Test: fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink-multiline.html

* platform/graphics/Font.h:
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::dashesForIntersectionsWithRect):
* rendering/InlineTextBox.cpp:
(WebCore::drawSkipInkUnderline):
(WebCore::InlineTextBox::paintDecoration):
* rendering/TextPainter.cpp:
(WebCore::TextPainter::dashesForIntersectionsWithRect):
* rendering/TextPainter.h:

LayoutTests:

This test compares rending of a single element that wraps lines with one element per line.
Both elements have text-decoration-skip:ink turned on.

* fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink-multiline-expected.html: Added.
* fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink-multiline.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink-multiline-expected.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink-multiline.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Font.h
Source/WebCore/platform/graphics/mac/FontMac.mm
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/TextPainter.cpp
Source/WebCore/rendering/TextPainter.h

index dbbc1b380600ba94383b92ffdaf0d601638a512d..1930f533d572dee15b0e4d61e86009422b7b1a18 100644 (file)
@@ -1,3 +1,16 @@
+2014-01-09  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        text-decoration-skip: ink does not work with line wraps
+        https://bugs.webkit.org/show_bug.cgi?id=126729
+
+        Reviewed by Simon Fraser.
+
+        This test compares rending of a single element that wraps lines with one element per line.
+        Both elements have text-decoration-skip:ink turned on.
+
+        * fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink-multiline-expected.html: Added.
+        * fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink-multiline.html: Added.
+
 2014-01-09  Zoltan Horvath  <zoltan@webkit.org>
 
         [CSS Shapes] First line gets incorrectly adjusted in shape-inside due to rounding
diff --git a/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink-multiline-expected.html b/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink-multiline-expected.html
new file mode 100644 (file)
index 0000000..c91108a
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that text-decoration-skip: ink is applied on elements that wrap lines
+<div style="text-decoration: underline; -webkit-text-decoration-skip: ink; width: 300px;">thisisalongstringofcharactersthatshouldlinewrap</div>
+<div style="text-decoration: underline; -webkit-text-decoration-skip: ink; width: 300px;">thisisalongstringofcharactersthatshouldlinewrap</div>
+<div style="text-decoration: underline; -webkit-text-decoration-skip: ink; width: 300px;">thisisalongstringofcharactersthatshouldlinewrap</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink-multiline.html b/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink-multiline.html
new file mode 100644 (file)
index 0000000..a4beec8
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that text-decoration-skip: ink is applied on elements that wrap lines
+<div style="text-decoration: underline; -webkit-text-decoration-skip: ink; width: 300px;">thisisalongstringofcharactersthatshouldlinewrap thisisalongstringofcharactersthatshouldlinewrap thisisalongstringofcharactersthatshouldlinewrap</div>
+</body>
+</html>
index c68a627005101379ee32bb644b040f2dd7fe56da..475d56324a8b4cbf2f79c16765d1b2c8758bf10f 100644 (file)
@@ -1,3 +1,27 @@
+2014-01-09  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        text-decoration-skip: ink does not work with line wraps
+        https://bugs.webkit.org/show_bug.cgi?id=126729
+
+        Reviewed by Simon Fraser.
+
+        InlineTextBox's m_start and m_length fields are offsets into the renderer's string,
+        not the generated TextRun. Because of this distinction, when multiple InlineTextBoxes
+        were constructed for the same element, all the subsequent elements would use incorrect
+        indices and therefore not have skipping decorations.
+
+        Test: fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-ink-multiline.html
+
+        * platform/graphics/Font.h:
+        * platform/graphics/mac/FontMac.mm:
+        (WebCore::Font::dashesForIntersectionsWithRect):
+        * rendering/InlineTextBox.cpp:
+        (WebCore::drawSkipInkUnderline):
+        (WebCore::InlineTextBox::paintDecoration):
+        * rendering/TextPainter.cpp:
+        (WebCore::TextPainter::dashesForIntersectionsWithRect):
+        * rendering/TextPainter.h:
+
 2014-01-09  Benjamin Poulain  <bpoulain@apple.com>
 
         Remove remaining blackberry files I could find in WebCore
index e5318dc0e81f72112ce59722455e75a0c5a3a302..35151f127106bf0ad9206952b91f0cea9892dd91 100644 (file)
@@ -106,7 +106,7 @@ public:
     float drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const;
     void drawEmphasisMarks(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1) const;
 
-    DashArray dashesForIntersectionsWithRect(const TextRun&, const FloatPoint& textOrigin, int from, int to, const FloatRect& lineExtents) const;
+    DashArray dashesForIntersectionsWithRect(const TextRun&, const FloatPoint& textOrigin, const FloatRect& lineExtents) const;
 
     float width(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
     float width(const TextRun&, int& charsConsumed, String& glyphName) const;
index af6287f662dfa153f15482601b74ea446c84b258..eae3b074c384a97bf304f4265fc7944bfe93a490 100644 (file)
@@ -436,14 +436,14 @@ static void findPathIntersections(void* stateAsVoidPointer, const CGPathElement*
     state.currentPoint = point;
 }
 
-DashArray Font::dashesForIntersectionsWithRect(const TextRun& run, const FloatPoint& textOrigin, int textRunStartIndex, int textRunEndIndex, const FloatRect& lineExtents) const
+DashArray Font::dashesForIntersectionsWithRect(const TextRun& run, const FloatPoint& textOrigin, const FloatRect& lineExtents) const
 {
     float deltaX;
     GlyphBuffer glyphBuffer;
     if (codePath(run) != Complex)
-        deltaX = getGlyphsAndAdvancesForSimpleText(run, textRunStartIndex, textRunEndIndex, glyphBuffer);
+        deltaX = getGlyphsAndAdvancesForSimpleText(run, 0, run.length(), glyphBuffer);
     else
-        deltaX = getGlyphsAndAdvancesForComplexText(run, textRunStartIndex, textRunEndIndex, glyphBuffer);
+        deltaX = getGlyphsAndAdvancesForComplexText(run, 0, run.length(), glyphBuffer);
     CGAffineTransform translation = CGAffineTransformMakeTranslation(textOrigin.x() + deltaX, textOrigin.y());
     translation = CGAffineTransformScale(translation, 1, -1);
     DashArray result;
index 857cace8a4521b700dcfeabf59a68d0e75c97734..b8d2df9ec7ce3a1dd6bfa45c58fcda2fc822bc64 100644 (file)
@@ -118,12 +118,12 @@ static DashArray translateIntersectionPointsToSkipInkBoundaries(const DashArray&
     return result;
 }
 
-static void drawSkipInkUnderline(TextPainter& textPainter, GraphicsContext& context, FloatPoint localOrigin, float underlineOffset, float width, bool isPrinting, int m_start, int m_len)
+static void drawSkipInkUnderline(TextPainter& textPainter, GraphicsContext& context, FloatPoint localOrigin, float underlineOffset, float width, bool isPrinting)
 {
     FloatPoint adjustedLocalOrigin = localOrigin;
     adjustedLocalOrigin.move(0, underlineOffset);
     FloatRect underlineBoundingBox = context.computeLineBoundsForText(adjustedLocalOrigin, width, isPrinting);
-    DashArray intersections = textPainter.dashesForIntersectionsWithRect(underlineBoundingBox, m_start, m_start + m_len);
+    DashArray intersections = textPainter.dashesForIntersectionsWithRect(underlineBoundingBox);
     DashArray a = translateIntersectionPointsToSkipInkBoundaries(intersections, underlineBoundingBox.height(), width);
 
     ASSERT(!(a.size() % 2));
@@ -1185,10 +1185,10 @@ void InlineTextBox::paintDecoration(GraphicsContext& context, const FloatPoint&
 #if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
                 if (lineStyle.textDecorationSkip() == TextDecorationSkipInk) {
                     if (!context.paintingDisabled()) {
-                        drawSkipInkUnderline(textPainter, context, localOrigin, underlineOffset, width, isPrinting, m_start, m_len);
+                        drawSkipInkUnderline(textPainter, context, localOrigin, underlineOffset, width, isPrinting);
 
                         if (decorationStyle == TextDecorationStyleDouble)
-                            drawSkipInkUnderline(textPainter, context, localOrigin, underlineOffset + doubleOffset, width, isPrinting, m_start, m_len);
+                            drawSkipInkUnderline(textPainter, context, localOrigin, underlineOffset + doubleOffset, width, isPrinting);
                     }
                 } else {
 #endif // CSS3_TEXT_DECORATION_SKIP_INK
@@ -1219,10 +1219,10 @@ void InlineTextBox::paintDecoration(GraphicsContext& context, const FloatPoint&
 #if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
                 if (lineStyle.textDecorationSkip() == TextDecorationSkipInk) {
                     if (!context.paintingDisabled()) {
-                        drawSkipInkUnderline(textPainter, context, localOrigin, 0, width, isPrinting, m_start, m_len);
+                        drawSkipInkUnderline(textPainter, context, localOrigin, 0, width, isPrinting);
 
                         if (decorationStyle == TextDecorationStyleDouble)
-                            drawSkipInkUnderline(textPainter, context, localOrigin, -doubleOffset, width, isPrinting, m_start, m_len);
+                            drawSkipInkUnderline(textPainter, context, localOrigin, -doubleOffset, width, isPrinting);
                     }
                 } else {
 #endif // CSS3_TEXT_DECORATION_SKIP_INK
index cfd9753f21ad6a9878a478a0fbbe9f1ee36f7138..d5bbdb92db49103d8b72bc5f5fcfe02b5f406dc5 100644 (file)
@@ -177,9 +177,9 @@ void TextPainter::paintTextInContext(GraphicsContext& context, float amountToInc
 }
 
 #if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
-DashArray TextPainter::dashesForIntersectionsWithRect(const FloatRect& lineExtents, int textRunStartIndex, int textRunEndIndex)
+DashArray TextPainter::dashesForIntersectionsWithRect(const FloatRect& lineExtents)
 {
-    return m_font.dashesForIntersectionsWithRect(m_textRun, m_textOrigin, textRunStartIndex, textRunEndIndex, lineExtents);
+    return m_font.dashesForIntersectionsWithRect(m_textRun, m_textOrigin, lineExtents);
 }
 #endif
 
index af659cd09ff5300ee7dac91e78066c67abc9e073..cb2408c53e0fe45271bc478f42c2e286f53b76ac 100644 (file)
@@ -68,7 +68,7 @@ public:
     void paintText();
     void paintTextInContext(GraphicsContext&, float amountToIncreaseStrokeWidthBy);
 
-    DashArray dashesForIntersectionsWithRect(const FloatRect& lineExtents, int textRunStartIndex, int textRunEndIndex);
+    DashArray dashesForIntersectionsWithRect(const FloatRect& lineExtents);
 
 private:
     bool m_paintSelectedTextOnly;