<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160951] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160951">160951</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2013-12-20 17:55:10 -0800 (Fri, 20 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Faster implementation of text-decoration-skip: ink
https://bugs.webkit.org/show_bug.cgi?id=125718

Reviewed by Simon Fraser.

Source/WebCore:

This new implementation of text-decoration-skip: ink extracts
each glyph into a path, then decomposes each path into a series
of contours. It then intersects each contour with the top and
bottom of the underline (by approximating the contour with a line).
It then draws underlines in between these intersection regions.

Tests for text-decoration-skip: ink already exist in
fast/css3-text/css3-text-decoration/text-decoration-skip

* platform/graphics/Font.h: Signature of new function
* platform/graphics/mac/FontMac.mm:
(WebCore::GlyphIterationState::GlyphIterationState): Persistent
between calls to findPathIntersections
(WebCore::findIntersectionPoint): Calculates an intersection point
between two lines
(WebCore::findPathIntersections): Called by CGPathApply to find
intersections of each contour
(WebCore::Font::intersectionPoints): Function to get the places
where an underline would intersect a TextRun.
* rendering/InlineTextBox.cpp:
(WebCore::compareTuples): Used for sorting intersection ranges
(WebCore::translateIntersectionPointsToSkipInkBoundaries): Converts
a sequence of intersection points to the locations where
text-decoration-skip: ink should draw underlines
(WebCore::drawSkipInkUnderline): Draws a sequence of short underlines
(WebCore::InlineTextBox::paintDecoration):
* rendering/TextPainter.cpp:
(WebCore::TextPainter::intersectionPoints): Calls Font::intersectionPoints
* rendering/TextPainter.h:

Source/WTF:

This creates a new preprocessor define, CSS3_TEXT_DECORATION_SKIP_INK,
which enables the use of the text-decoration-skip: ink CSS value.
Creating this new value simplifies the logic about when to enable the
codepath for this CSS value.

* wtf/Platform.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfPlatformh">trunk/Source/WTF/wtf/Platform.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFonth">trunk/Source/WebCore/platform/graphics/Font.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacFontMacmm">trunk/Source/WebCore/platform/graphics/mac/FontMac.mm</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineTextBoxcpp">trunk/Source/WebCore/rendering/InlineTextBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingTextPaintercpp">trunk/Source/WebCore/rendering/TextPainter.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingTextPainterh">trunk/Source/WebCore/rendering/TextPainter.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (160950 => 160951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2013-12-21 01:27:45 UTC (rev 160950)
+++ trunk/Source/WTF/ChangeLog        2013-12-21 01:55:10 UTC (rev 160951)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2013-12-20  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        Faster implementation of text-decoration-skip: ink
+        https://bugs.webkit.org/show_bug.cgi?id=125718
+
+        Reviewed by Simon Fraser.
+
+        This creates a new preprocessor define, CSS3_TEXT_DECORATION_SKIP_INK,
+        which enables the use of the text-decoration-skip: ink CSS value.
+        Creating this new value simplifies the logic about when to enable the
+        codepath for this CSS value.
+
+        * wtf/Platform.h:
+
</ins><span class="cx"> 2013-12-20  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Change &quot;threaded scrolling&quot; terminology to &quot;asynchronous scrolling&quot;
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Platform.h (160950 => 160951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Platform.h        2013-12-21 01:27:45 UTC (rev 160950)
+++ trunk/Source/WTF/wtf/Platform.h        2013-12-21 01:55:10 UTC (rev 160951)
</span><span class="lines">@@ -1067,4 +1067,8 @@
</span><span class="cx"> #define ENABLE_OPENTYPE_VERTICAL 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(CSS3_TEXT_DECORATION) &amp;&amp; PLATFORM(MAC)
+#define ENABLE_CSS3_TEXT_DECORATION_SKIP_INK 1
+#endif
+
</ins><span class="cx"> #endif /* WTF_Platform_h */
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (160950 => 160951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-12-21 01:27:45 UTC (rev 160950)
+++ trunk/Source/WebCore/ChangeLog        2013-12-21 01:55:10 UTC (rev 160951)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2013-12-20  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        Faster implementation of text-decoration-skip: ink
+        https://bugs.webkit.org/show_bug.cgi?id=125718
+
+        Reviewed by Simon Fraser.
+
+        This new implementation of text-decoration-skip: ink extracts
+        each glyph into a path, then decomposes each path into a series
+        of contours. It then intersects each contour with the top and
+        bottom of the underline (by approximating the contour with a line).
+        It then draws underlines in between these intersection regions.
+
+        Tests for text-decoration-skip: ink already exist in
+        fast/css3-text/css3-text-decoration/text-decoration-skip
+
+        * platform/graphics/Font.h: Signature of new function
+        * platform/graphics/mac/FontMac.mm:
+        (WebCore::GlyphIterationState::GlyphIterationState): Persistent
+        between calls to findPathIntersections
+        (WebCore::findIntersectionPoint): Calculates an intersection point
+        between two lines
+        (WebCore::findPathIntersections): Called by CGPathApply to find
+        intersections of each contour
+        (WebCore::Font::intersectionPoints): Function to get the places
+        where an underline would intersect a TextRun.
+        * rendering/InlineTextBox.cpp:
+        (WebCore::compareTuples): Used for sorting intersection ranges
+        (WebCore::translateIntersectionPointsToSkipInkBoundaries): Converts
+        a sequence of intersection points to the locations where
+        text-decoration-skip: ink should draw underlines
+        (WebCore::drawSkipInkUnderline): Draws a sequence of short underlines
+        (WebCore::InlineTextBox::paintDecoration):
+        * rendering/TextPainter.cpp:
+        (WebCore::TextPainter::intersectionPoints): Calls Font::intersectionPoints
+        * rendering/TextPainter.h:
+
</ins><span class="cx"> 2013-12-20  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Give the CommandLineAPIModule its own Host object, making InjectedScriptHost viable for a JS Context
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFonth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Font.h (160950 => 160951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Font.h        2013-12-21 01:27:45 UTC (rev 160950)
+++ trunk/Source/WebCore/platform/graphics/Font.h        2013-12-21 01:55:10 UTC (rev 160951)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> #ifndef Font_h
</span><span class="cx"> #define Font_h
</span><span class="cx"> 
</span><ins>+#include &quot;DashArray.h&quot;
</ins><span class="cx"> #include &quot;FontDescription.h&quot;
</span><span class="cx"> #include &quot;FontGlyphs.h&quot;
</span><span class="cx"> #include &quot;SimpleFontData.h&quot;
</span><span class="lines">@@ -100,6 +101,8 @@
</span><span class="cx">     void drawText(GraphicsContext*, const TextRun&amp;, const FloatPoint&amp;, int from = 0, int to = -1, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const;
</span><span class="cx">     void drawEmphasisMarks(GraphicsContext*, const TextRun&amp;, const AtomicString&amp; mark, const FloatPoint&amp;, int from = 0, int to = -1) const;
</span><span class="cx"> 
</span><ins>+    DashArray dashesForIntersectionsWithRect(const TextRun&amp;, const FloatPoint&amp; textOrigin, int from, int to, const FloatRect&amp; lineExtents) const;
+
</ins><span class="cx">     float width(const TextRun&amp;, HashSet&lt;const SimpleFontData*&gt;* fallbackFonts = 0, GlyphOverflow* = 0) const;
</span><span class="cx">     float width(const TextRun&amp;, int&amp; charsConsumed, String&amp; glyphName) const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacFontMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/FontMac.mm (160950 => 160951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/FontMac.mm        2013-12-21 01:27:45 UTC (rev 160950)
+++ trunk/Source/WebCore/platform/graphics/mac/FontMac.mm        2013-12-21 01:55:10 UTC (rev 160951)
</span><span class="lines">@@ -23,6 +23,7 @@
</span><span class="cx"> #import &quot;config.h&quot;
</span><span class="cx"> #import &quot;Font.h&quot;
</span><span class="cx"> 
</span><ins>+#import &quot;DashArray.h&quot;
</ins><span class="cx"> #import &quot;GlyphBuffer.h&quot;
</span><span class="cx"> #import &quot;GraphicsContext.h&quot;
</span><span class="cx"> #import &quot;Logging.h&quot;
</span><span class="lines">@@ -323,4 +324,103 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
+struct GlyphIterationState {
+    GlyphIterationState(CGPoint startingPoint, CGPoint currentPoint, CGFloat y1, CGFloat y2, CGFloat minX, CGFloat maxX)
+        : startingPoint(startingPoint)
+        , currentPoint(currentPoint)
+        , y1(y1)
+        , y2(y2)
+        , minX(minX)
+        , maxX(maxX)
+    {
+    }
+    CGPoint startingPoint;
+    CGPoint currentPoint;
+    CGFloat y1;
+    CGFloat y2;
+    CGFloat minX;
+    CGFloat maxX;
+};
+
+static bool findIntersectionPoint(float y, CGPoint p1, CGPoint p2, CGFloat&amp; x)
+{
+    x = p1.x + (y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y);
+    return (p1.y &lt; y &amp;&amp; p2.y &gt; y) || (p1.y &gt; y &amp;&amp; p2.y &lt; y);
</ins><span class="cx"> }
</span><ins>+
+// This function is called by CGPathApply and is therefore invoked for each
+// contour in a glyph. This function models each contours as a straight line
+// and calculates the intersections between each pseudo-contour and
+// two horizontal lines (the upper and lower bounds of an underline) found in
+// GlyphIterationState::y1 and GlyphIterationState::y2. It keeps track of the
+// leftmost and rightmost intersection in GlyphIterationState::minX and
+// GlyphIterationState::maxX.
+static void findPathIntersections(void* stateAsVoidPointer, const CGPathElement* e)
+{
+    auto&amp; state = *static_cast&lt;GlyphIterationState*&gt;(stateAsVoidPointer);
+    bool doIntersection = false;
+    CGPoint point = CGPointZero;
+    switch (e-&gt;type) {
+    case kCGPathElementMoveToPoint:
+        state.startingPoint = e-&gt;points[0];
+        state.currentPoint = e-&gt;points[0];
+        break;
+    case kCGPathElementAddLineToPoint:
+        doIntersection = true;
+        point = e-&gt;points[0];
+        break;
+    case kCGPathElementAddQuadCurveToPoint:
+        doIntersection = true;
+        point = e-&gt;points[1];
+        break;
+    case kCGPathElementAddCurveToPoint:
+        doIntersection = true;
+        point = e-&gt;points[2];
+        break;
+    case kCGPathElementCloseSubpath:
+        doIntersection = true;
+        point = state.startingPoint;
+        break;
+    }
+    if (!doIntersection)
+        return;
+    CGFloat x;
+    if (findIntersectionPoint(state.y1, state.currentPoint, point, x)) {
+        state.minX = std::min(state.minX, x);
+        state.maxX = std::max(state.maxX, x);
+    }
+    if (findIntersectionPoint(state.y2, state.currentPoint, point, x)) {
+        state.minX = std::min(state.minX, x);
+        state.maxX = std::max(state.maxX, x);
+    }
+    state.currentPoint = point;
+}
+
+DashArray Font::dashesForIntersectionsWithRect(const TextRun&amp; run, const FloatPoint&amp; textOrigin, int textRunStartIndex, int textRunEndIndex, const FloatRect&amp; lineExtents) const
+{
+    float deltaX;
+    GlyphBuffer glyphBuffer;
+    if (codePath(run) != Complex)
+        deltaX = getGlyphsAndAdvancesForSimpleText(run, textRunStartIndex, textRunEndIndex, glyphBuffer);
+    else
+        deltaX = getGlyphsAndAdvancesForComplexText(run, textRunStartIndex, textRunEndIndex, glyphBuffer);
+    CGAffineTransform translation = CGAffineTransformMakeTranslation(textOrigin.x() + deltaX, textOrigin.y());
+    translation = CGAffineTransformScale(translation, 1, -1);
+    DashArray result;
+    for (int i = 0; i &lt; glyphBuffer.size(); ++i) {
+        GlyphIterationState info = GlyphIterationState(CGPointMake(0, 0), CGPointMake(0, 0), lineExtents.y(), lineExtents.y() + lineExtents.height(), lineExtents.x() + lineExtents.width(), lineExtents.x());
+        RetainPtr&lt;CGPathRef&gt; path = adoptCF(CTFontCreatePathForGlyph(glyphBuffer.fontDataAt(i)-&gt;platformData().ctFont(), glyphBuffer.glyphAt(i), &amp;translation));
+        CGPathApply(path.get(), &amp;info, &amp;findPathIntersections);
+        if (info.minX &lt; info.maxX) {
+            result.append(info.minX - lineExtents.x());
+            result.append(info.maxX - lineExtents.x());
+        }
+        GlyphBufferAdvance advance = glyphBuffer.advanceAt(i);
+        translation = CGAffineTransformTranslate(translation, advance.width(), advance.height());
+    }
+    return result;
+}
+#endif
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (160950 => 160951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineTextBox.cpp        2013-12-21 01:27:45 UTC (rev 160950)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp        2013-12-21 01:55:10 UTC (rev 160951)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Chrome.h&quot;
</span><span class="cx"> #include &quot;ChromeClient.h&quot;
</span><ins>+#include &quot;DashArray.h&quot;
</ins><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;DocumentMarkerController.h&quot;
</span><span class="cx"> #include &quot;Editor.h&quot;
</span><span class="lines">@@ -65,6 +66,75 @@
</span><span class="cx"> typedef WTF::HashMap&lt;const InlineTextBox*, LayoutRect&gt; InlineTextBoxOverflowMap;
</span><span class="cx"> static InlineTextBoxOverflowMap* gTextBoxesWithOverflow;
</span><span class="cx"> 
</span><ins>+#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
+static bool compareTuples(std::pair&lt;float, float&gt; l, std::pair&lt;float, float&gt; r)
+{
+    return l.first &lt; r.first;
+}
+
+static DashArray translateIntersectionPointsToSkipInkBoundaries(const DashArray&amp; intersections, float dilationAmount, float totalWidth)
+{
+    ASSERT(!(intersections.size() % 2));
+    
+    // Step 1: Make pairs so we can sort based on range starting-point. We dilate the ranges in this step as well.
+    Vector&lt;std::pair&lt;float, float&gt;&gt; tuples;
+    for (auto i = intersections.begin(); i != intersections.end(); i++, i++)
+        tuples.append(std::make_pair(*i - dilationAmount, *(i + 1) + dilationAmount));
+    std::sort(tuples.begin(), tuples.end(), &amp;compareTuples);
+
+    // Step 2: Deal with intersecting ranges.
+    Vector&lt;std::pair&lt;float, float&gt;&gt; intermediateTuples;
+    if (tuples.size() &gt;= 2) {
+        intermediateTuples.append(*tuples.begin());
+        auto lastIntermediate = intermediateTuples.begin();
+        for (auto i = tuples.begin() + 1; i != tuples.end(); i++) {
+            float&amp; firstEnd = lastIntermediate-&gt;second;
+            float secondStart = i-&gt;first;
+            float secondEnd = i-&gt;second;
+            if (secondStart &lt;= firstEnd &amp;&amp; secondEnd &lt;= firstEnd) {
+                // Ignore this range completely
+            } else if (secondStart &lt;= firstEnd)
+                firstEnd = secondEnd;
+            else {
+                intermediateTuples.append(*i);
+                ++lastIntermediate;
+            }
+        }
+    } else
+        intermediateTuples = tuples;
+
+    // Step 3: Output the space between the ranges, but only if the space warrants an underline.
+    float previous = 0;
+    DashArray result;
+    for (auto i = intermediateTuples.begin(); i != intermediateTuples.end(); i++) {
+        if (i-&gt;first - previous &gt; dilationAmount) {
+            result.append(previous);
+            result.append(i-&gt;first);
+        }
+        previous = i-&gt;second;
+    }
+    if (totalWidth - previous &gt; dilationAmount) {
+        result.append(previous);
+        result.append(totalWidth);
+    }
+    
+    return result;
+}
+
+static void drawSkipInkUnderline(TextPainter&amp; textPainter, GraphicsContext&amp; context, FloatPoint localOrigin, float underlineOffset, float width, bool isPrinting, int m_start, int m_len)
+{
+    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 a = translateIntersectionPointsToSkipInkBoundaries(intersections, underlineBoundingBox.height(), width);
+
+    ASSERT(!(a.size() % 2));
+    for (auto i = a.begin(); i != a.end(); i++, i++)
+        context.drawLineForText(FloatPoint(localOrigin.x() + *i, localOrigin.y() + underlineOffset), *(i+1) - *i, isPrinting);
+}
+#endif
+
</ins><span class="cx"> InlineTextBox::~InlineTextBox()
</span><span class="cx"> {
</span><span class="cx">     if (!knownToHaveNoOverflow() &amp;&amp; gTextBoxesWithOverflow)
</span><span class="lines">@@ -1072,7 +1142,7 @@
</span><span class="cx">         // Offset between lines - always non-zero, so lines never cross each other.
</span><span class="cx">         float doubleOffset = textDecorationThickness + 1;
</span><span class="cx">         
</span><del>-        bool clipDecorationToMask = lineStyle.textDecorationSkip() == TextDecorationSkipInk;
</del><ins>+        bool clipDecorationToMask = false;
</ins><span class="cx">         
</span><span class="cx">         GraphicsContextStateSaver stateSaver(context, false);
</span><span class="cx">         
</span><span class="lines">@@ -1115,10 +1185,23 @@
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><span class="cx">             default:
</span><del>-                context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + underlineOffset), width, isPrinting);
</del><ins>+#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);
</ins><span class="cx"> 
</span><del>-                if (decorationStyle == TextDecorationStyleDouble)
-                    context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + underlineOffset + doubleOffset), width, isPrinting);
</del><ins>+                        if (decorationStyle == TextDecorationStyleDouble)
+                            drawSkipInkUnderline(textPainter, context, localOrigin, underlineOffset + doubleOffset, width, isPrinting, m_start, m_len);
+                    }
+                } else {
+#endif // CSS3_TEXT_DECORATION_SKIP_INK
+                    context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + underlineOffset), width, isPrinting);
+
+                    if (decorationStyle == TextDecorationStyleDouble)
+                        context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + underlineOffset + doubleOffset), width, isPrinting);
+#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
+                }
+#endif
</ins><span class="cx">             }
</span><span class="cx"> #else
</span><span class="cx">             // Leave one pixel of white between the baseline and the underline.
</span><span class="lines">@@ -1136,11 +1219,24 @@
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><span class="cx">             default:
</span><ins>+#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);
+
+                        if (decorationStyle == TextDecorationStyleDouble)
+                            drawSkipInkUnderline(textPainter, context, localOrigin, -doubleOffset, width, isPrinting, m_start, m_len);
+                    }
+                } else {
+#endif // CSS3_TEXT_DECORATION_SKIP_INK
</ins><span class="cx"> #endif // CSS3_TEXT_DECORATION
</span><del>-                context.drawLineForText(localOrigin, width, isPrinting);
</del><ins>+                    context.drawLineForText(localOrigin, width, isPrinting);
</ins><span class="cx"> #if ENABLE(CSS3_TEXT_DECORATION)
</span><del>-                if (decorationStyle == TextDecorationStyleDouble)
-                    context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() - doubleOffset), width, isPrinting);
</del><ins>+                    if (decorationStyle == TextDecorationStyleDouble)
+                        context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() - doubleOffset), width, isPrinting);
+#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
+                }
+#endif
</ins><span class="cx">             }
</span><span class="cx"> #endif // CSS3_TEXT_DECORATION
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingTextPaintercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/TextPainter.cpp (160950 => 160951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/TextPainter.cpp        2013-12-21 01:27:45 UTC (rev 160950)
+++ trunk/Source/WebCore/rendering/TextPainter.cpp        2013-12-21 01:55:10 UTC (rev 160951)
</span><span class="lines">@@ -176,4 +176,11 @@
</span><span class="cx">     m_savedDrawingStateForMask = savedDrawingStateForMask;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
+DashArray TextPainter::dashesForIntersectionsWithRect(const FloatRect&amp; lineExtents, int textRunStartIndex, int textRunEndIndex)
+{
+    return m_font.dashesForIntersectionsWithRect(m_textRun, m_textOrigin, textRunStartIndex, textRunEndIndex, lineExtents);
+}
+#endif
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingTextPainterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/TextPainter.h (160950 => 160951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/TextPainter.h        2013-12-21 01:27:45 UTC (rev 160950)
+++ trunk/Source/WebCore/rendering/TextPainter.h        2013-12-21 01:55:10 UTC (rev 160951)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> #define TextPainter_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;AffineTransform.h&quot;
</span><ins>+#include &quot;DashArray.h&quot;
</ins><span class="cx"> #include &quot;RenderText.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -67,6 +68,8 @@
</span><span class="cx">     void paintText();
</span><span class="cx">     void paintTextInContext(GraphicsContext&amp;, float amountToIncreaseStrokeWidthBy);
</span><span class="cx"> 
</span><ins>+    DashArray dashesForIntersectionsWithRect(const FloatRect&amp; lineExtents, int textRunStartIndex, int textRunEndIndex);
+
</ins><span class="cx"> private:
</span><span class="cx">     bool m_paintSelectedTextOnly;
</span><span class="cx">     bool m_paintSelectedTextSeparately;
</span></span></pre>
</div>
</div>

</body>
</html>