<!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>[237845] trunk</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/237845">237845</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2018-11-05 20:35:50 -0800 (Mon, 05 Nov 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cache glyph paths and share underline skipping code between all the ports
https://bugs.webkit.org/show_bug.cgi?id=191239

Reviewed by Alex Christensen.

PerformanceTests:

Measures the performance of drawing a whole lot of underlines

* Layout/underline.html: Added.

Source/WebCore:

I was hoping that caching the glyph paths was going to be a performance progression,
but it turns out that the additional overhead of WebCore::Path compensated for it.
In total, the performance is the same (my testing says that this patch is a 1%
progression, but that's within the noise).

Because the ink skipping logic is now shared among all ports, Windows now gets it for
free.

Test: PerformanceTests/Layout/underline.html

* platform/graphics/Font.cpp:
(WebCore::Font::pathForGlyph const):
* platform/graphics/Font.h:
* platform/graphics/FontCascade.cpp:
(WebCore::computeUnderlineType):
(WebCore::GlyphIterationState::GlyphIterationState):
(WebCore::findIntersectionPoint):
(WebCore::updateX):
(WebCore::findPathIntersections):
(WebCore::GlyphToPathTranslator::GlyphToPathTranslator):
(WebCore::GlyphToPathTranslator::containsMorePaths):
(WebCore::GlyphToPathTranslator::path):
(WebCore::GlyphToPathTranslator::extents):
(WebCore::GlyphToPathTranslator::underlineType):
(WebCore::GlyphToPathTranslator::advance):
(WebCore::FontCascade::dashesForIntersectionsWithRect const):
* platform/graphics/FontCascade.h:
* platform/graphics/GlyphMetricsMap.h:
(WebCore::GlyphMetricsMap::existingMetricsForGlyph):
(WebCore::GlyphMetricsMap::GlyphMetricsPage::existingMetricsForGlyph const):
(WebCore::GlyphMetricsMap<std::optional<Path>>::unknownMetrics):
* platform/graphics/TextRun.h:
* platform/graphics/cairo/FontCairo.cpp:
(WebCore::Font::platformPathForGlyph const):
(WebCore::GlyphIterationState::GlyphIterationState): Deleted.
(WebCore::findIntersectionPoint): Deleted.
(WebCore::updateX): Deleted.
(WebCore::findPathIntersections): Deleted.
(): Deleted.
(WebCore::CairoGlyphToPathTranslator::path): Deleted.
(WebCore::CairoGlyphToPathTranslator::extents): Deleted.
(WebCore::CairoGlyphToPathTranslator::underlineType): Deleted.
(WebCore::CairoGlyphToPathTranslator::advance): Deleted.
(WebCore::FontCascade::dashesForIntersectionsWithRect const): Deleted.
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::GlyphIterationState::GlyphIterationState): Deleted.
(WebCore::findIntersectionPoint): Deleted.
(WebCore::updateX): Deleted.
(WebCore::findPathIntersections): Deleted.
(): Deleted.
(WebCore::MacGlyphToPathTranslator::path): Deleted.
(WebCore::MacGlyphToPathTranslator::extents): Deleted.
(WebCore::MacGlyphToPathTranslator::underlineType): Deleted.
(WebCore::MacGlyphToPathTranslator::advance): Deleted.
(WebCore::FontCascade::dashesForIntersectionsWithRect const): Deleted.
* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::Font::platformPathForGlyph const):
* rendering/TextDecorationPainter.cpp:
(WebCore::drawSkipInkUnderline):
(WebCore::TextDecorationPainter::paintTextDecoration):

Source/WTF:

Remove CSS3_TEXT_DECORATION_SKIP_INK. It's now interoperable and part of the Web Platform.

* wtf/Platform.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkPerformanceTestsChangeLog">trunk/PerformanceTests/ChangeLog</a></li>
<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="#trunkSourceWebCorePALpalspiwinCoreTextSPIWinh">trunk/Source/WebCore/PAL/pal/spi/win/CoreTextSPIWin.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontcpp">trunk/Source/WebCore/platform/graphics/Font.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFonth">trunk/Source/WebCore/platform/graphics/Font.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCascadecpp">trunk/Source/WebCore/platform/graphics/FontCascade.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCascadeh">trunk/Source/WebCore/platform/graphics/FontCascade.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGlyphMetricsMaph">trunk/Source/WebCore/platform/graphics/GlyphMetricsMap.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsTextRunh">trunk/Source/WebCore/platform/graphics/TextRun.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoFontCairocpp">trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaFontCascadeCocoamm">trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaFontCocoamm">trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinSimpleFontDataCGWincpp">trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinSimpleFontDataDirect2Dcpp">trunk/Source/WebCore/platform/graphics/win/SimpleFontDataDirect2D.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingTextDecorationPaintercpp">trunk/Source/WebCore/rendering/TextDecorationPainter.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkPerformanceTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/ChangeLog (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/ChangeLog 2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/PerformanceTests/ChangeLog    2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2018-11-05  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Cache glyph paths and share underline skipping code between all the ports
+        https://bugs.webkit.org/show_bug.cgi?id=191239
+
+        Reviewed by Alex Christensen.
+
+        Measures the performance of drawing a whole lot of underlines
+
+        * Layout/underline.html: Added.
+
</ins><span class="cx"> 2018-10-25  Saam Barati  <sbarati@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Check in corresponding C code in JetStream 2
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WTF/ChangeLog  2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2018-11-05  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Cache glyph paths and share underline skipping code between all the ports
+        https://bugs.webkit.org/show_bug.cgi?id=191239
+
+        Reviewed by Alex Christensen.
+
+        Remove CSS3_TEXT_DECORATION_SKIP_INK. It's now interoperable and part of the Web Platform.
+
+        * wtf/Platform.h:
+
</ins><span class="cx"> 2018-11-05  Dominik Infuehr  <dinfuehr@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         Enable LLInt on ARMv7/Linux
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Platform.h (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Platform.h  2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WTF/wtf/Platform.h     2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -1263,13 +1263,8 @@
</span><span class="cx"> #if PLATFORM(GTK) || PLATFORM(WPE)
</span><span class="cx"> #undef ENABLE_OPENTYPE_VERTICAL
</span><span class="cx"> #define ENABLE_OPENTYPE_VERTICAL 1
</span><del>-#define ENABLE_CSS3_TEXT_DECORATION_SKIP_INK 1
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(COCOA)
-#define ENABLE_CSS3_TEXT_DECORATION_SKIP_INK 1
-#endif
-
</del><span class="cx"> #if COMPILER(MSVC)
</span><span class="cx"> #undef __STDC_FORMAT_MACROS
</span><span class="cx"> #define __STDC_FORMAT_MACROS
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/ChangeLog      2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -1,5 +1,73 @@
</span><span class="cx"> 2018-11-05  Myles C. Maxfield  <mmaxfield@apple.com>
</span><span class="cx"> 
</span><ins>+        Cache glyph paths and share underline skipping code between all the ports
+        https://bugs.webkit.org/show_bug.cgi?id=191239
+
+        Reviewed by Alex Christensen.
+
+        I was hoping that caching the glyph paths was going to be a performance progression,
+        but it turns out that the additional overhead of WebCore::Path compensated for it.
+        In total, the performance is the same (my testing says that this patch is a 1%
+        progression, but that's within the noise).
+
+        Because the ink skipping logic is now shared among all ports, Windows now gets it for
+        free.
+
+        Test: PerformanceTests/Layout/underline.html
+
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::pathForGlyph const):
+        * platform/graphics/Font.h:
+        * platform/graphics/FontCascade.cpp:
+        (WebCore::computeUnderlineType):
+        (WebCore::GlyphIterationState::GlyphIterationState):
+        (WebCore::findIntersectionPoint):
+        (WebCore::updateX):
+        (WebCore::findPathIntersections):
+        (WebCore::GlyphToPathTranslator::GlyphToPathTranslator):
+        (WebCore::GlyphToPathTranslator::containsMorePaths):
+        (WebCore::GlyphToPathTranslator::path):
+        (WebCore::GlyphToPathTranslator::extents):
+        (WebCore::GlyphToPathTranslator::underlineType):
+        (WebCore::GlyphToPathTranslator::advance):
+        (WebCore::FontCascade::dashesForIntersectionsWithRect const):
+        * platform/graphics/FontCascade.h:
+        * platform/graphics/GlyphMetricsMap.h:
+        (WebCore::GlyphMetricsMap::existingMetricsForGlyph):
+        (WebCore::GlyphMetricsMap::GlyphMetricsPage::existingMetricsForGlyph const):
+        (WebCore::GlyphMetricsMap<std::optional<Path>>::unknownMetrics):
+        * platform/graphics/TextRun.h:
+        * platform/graphics/cairo/FontCairo.cpp:
+        (WebCore::Font::platformPathForGlyph const):
+        (WebCore::GlyphIterationState::GlyphIterationState): Deleted.
+        (WebCore::findIntersectionPoint): Deleted.
+        (WebCore::updateX): Deleted.
+        (WebCore::findPathIntersections): Deleted.
+        (): Deleted.
+        (WebCore::CairoGlyphToPathTranslator::path): Deleted.
+        (WebCore::CairoGlyphToPathTranslator::extents): Deleted.
+        (WebCore::CairoGlyphToPathTranslator::underlineType): Deleted.
+        (WebCore::CairoGlyphToPathTranslator::advance): Deleted.
+        (WebCore::FontCascade::dashesForIntersectionsWithRect const): Deleted.
+        * platform/graphics/cocoa/FontCascadeCocoa.mm:
+        (WebCore::GlyphIterationState::GlyphIterationState): Deleted.
+        (WebCore::findIntersectionPoint): Deleted.
+        (WebCore::updateX): Deleted.
+        (WebCore::findPathIntersections): Deleted.
+        (): Deleted.
+        (WebCore::MacGlyphToPathTranslator::path): Deleted.
+        (WebCore::MacGlyphToPathTranslator::extents): Deleted.
+        (WebCore::MacGlyphToPathTranslator::underlineType): Deleted.
+        (WebCore::MacGlyphToPathTranslator::advance): Deleted.
+        (WebCore::FontCascade::dashesForIntersectionsWithRect const): Deleted.
+        * platform/graphics/cocoa/FontCocoa.mm:
+        (WebCore::Font::platformPathForGlyph const):
+        * rendering/TextDecorationPainter.cpp:
+        (WebCore::drawSkipInkUnderline):
+        (WebCore::TextDecorationPainter::paintTextDecoration):
+
+2018-11-05  Myles C. Maxfield  <mmaxfield@apple.com>
+
</ins><span class="cx">         Clean up text decoration drawing code
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=191245
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorePALpalspiwinCoreTextSPIWinh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PAL/pal/spi/win/CoreTextSPIWin.h (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PAL/pal/spi/win/CoreTextSPIWin.h    2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/PAL/pal/spi/win/CoreTextSPIWin.h       2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> void CTLineDraw(CTLineRef, CGContextRef);
</span><span class="cx"> CFDataRef CTFontCopyTable(CTFontRef, CTFontTableTag, CTFontTableOptions);
</span><span class="cx"> CFArrayRef CTFontCopyAvailableTables(CTFontRef, CTFontTableOptions);
</span><ins>+CGPathRef CTFontCreatePathForGlyph(CTFontRef, CGGlyph, const CGAffineTransform*);
</ins><span class="cx"> 
</span><span class="cx"> WTF_EXTERN_C_END
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Font.cpp  2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp     2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -663,4 +663,15 @@
</span><span class="cx">     }
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><ins>+
+// Don't store the result of this! The hash map is free to rehash at any point, leaving this reference dangling.
+const Path& Font::pathForGlyph(Glyph glyph) const
+{
+    if (const auto& path = m_glyphPathMap.existingMetricsForGlyph(glyph))
+        return *path;
+    auto path = platformPathForGlyph(glyph);
+    m_glyphPathMap.setMetricsForGlyph(glyph, path);
+    return *m_glyphPathMap.existingMetricsForGlyph(glyph);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFonth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Font.h (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Font.h    2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/platform/graphics/Font.h       2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -146,8 +146,10 @@
</span><span class="cx"> 
</span><span class="cx">     FloatRect boundsForGlyph(Glyph) const;
</span><span class="cx">     float widthForGlyph(Glyph) const;
</span><ins>+    const Path& pathForGlyph(Glyph) const; // Don't store the result of this! The hash map is free to rehash at any point, leaving this reference dangling.
</ins><span class="cx">     FloatRect platformBoundsForGlyph(Glyph) const;
</span><span class="cx">     float platformWidthForGlyph(Glyph) const;
</span><ins>+    Path platformPathForGlyph(Glyph) const;
</ins><span class="cx"> 
</span><span class="cx">     float spaceWidth() const { return m_spaceWidth; }
</span><span class="cx">     float adjustedSpaceWidth() const { return m_adjustedSpaceWidth; }
</span><span class="lines">@@ -253,6 +255,7 @@
</span><span class="cx">     mutable HashMap<unsigned, RefPtr<GlyphPage>> m_glyphPages;
</span><span class="cx">     mutable std::unique_ptr<GlyphMetricsMap<FloatRect>> m_glyphToBoundsMap;
</span><span class="cx">     mutable GlyphMetricsMap<float> m_glyphToWidthMap;
</span><ins>+    mutable GlyphMetricsMap<std::optional<Path>> m_glyphPathMap;
</ins><span class="cx">     mutable BitVector m_codePointSupport;
</span><span class="cx"> 
</span><span class="cx">     mutable RefPtr<OpenTypeMathData> m_mathData;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCascadecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp   2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp      2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -1237,11 +1237,18 @@
</span><span class="cx"> {
</span><span class="cx">     return m_fonts && m_fonts->isLoadingCustomFonts();
</span><span class="cx"> }
</span><ins>+
+enum class GlyphUnderlineType : uint8_t {
+    SkipDescenders,
+    SkipGlyph,
+    DrawOverGlyph
+};
</ins><span class="cx">     
</span><del>-GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun& textRun, const GlyphBuffer& glyphBuffer, unsigned index)
</del><ins>+static GlyphUnderlineType computeUnderlineType(const TextRun& textRun, const GlyphBuffer& glyphBuffer, unsigned index)
</ins><span class="cx"> {
</span><span class="cx">     // In general, we want to skip descenders. However, skipping descenders on CJK characters leads to undesirable renderings,
</span><span class="cx">     // so we want to draw through CJK characters (on a character-by-character basis).
</span><ins>+    // FIXME: The CSS spec says this should instead be done by the user-agent stylesheet using the lang= attribute.
</ins><span class="cx">     UChar32 baseCharacter;
</span><span class="cx">     unsigned offsetInString = glyphBuffer.offsetInString(index);
</span><span class="cx"> 
</span><span class="lines">@@ -1248,7 +1255,7 @@
</span><span class="cx">     if (offsetInString == GlyphBuffer::noOffset || offsetInString >= textRun.length()) {
</span><span class="cx">         // We have no idea which character spawned this glyph. Bail.
</span><span class="cx">         ASSERT_WITH_SECURITY_IMPLICATION(offsetInString < textRun.length());
</span><del>-        return GlyphToPathTranslator::GlyphUnderlineType::DrawOverGlyph;
</del><ins>+        return GlyphUnderlineType::DrawOverGlyph;
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     if (textRun.is8Bit())
</span><span class="lines">@@ -1285,9 +1292,9 @@
</span><span class="cx">     case UBLOCK_HANGUL_SYLLABLES:
</span><span class="cx">     case UBLOCK_HANGUL_JAMO_EXTENDED_A:
</span><span class="cx">     case UBLOCK_HANGUL_JAMO_EXTENDED_B:
</span><del>-        return GlyphToPathTranslator::GlyphUnderlineType::DrawOverGlyph;
</del><ins>+        return GlyphUnderlineType::DrawOverGlyph;
</ins><span class="cx">     default:
</span><del>-        return GlyphToPathTranslator::GlyphUnderlineType::SkipDescenders;
</del><ins>+        return GlyphUnderlineType::SkipDescenders;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1658,4 +1665,178 @@
</span><span class="cx">     drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+struct GlyphIterationState {
+    FloatPoint startingPoint;
+    FloatPoint currentPoint;
+    float y1;
+    float y2;
+    float minX;
+    float maxX;
+};
+
+static std::optional<float> findIntersectionPoint(float y, FloatPoint p1, FloatPoint p2)
+{
+    if ((p1.y() < y && p2.y() > y) || (p1.y() > y && p2.y() < y))
+        return p1.x() + (y - p1.y()) * (p2.x() - p1.x()) / (p2.y() - p1.y());
+    return std::nullopt;
</ins><span class="cx"> }
</span><ins>+
+static void updateX(GlyphIterationState& state, float x)
+{
+    state.minX = std::min(state.minX, x);
+    state.maxX = std::max(state.maxX, x);
+}
+
+// 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(GlyphIterationState& state, const PathElement& element)
+{
+    bool doIntersection = false;
+    FloatPoint point = FloatPoint();
+    switch (element.type) {
+    case PathElementMoveToPoint:
+        state.startingPoint = element.points[0];
+        state.currentPoint = element.points[0];
+        break;
+    case PathElementAddLineToPoint:
+        doIntersection = true;
+        point = element.points[0];
+        break;
+    case PathElementAddQuadCurveToPoint:
+        doIntersection = true;
+        point = element.points[1];
+        break;
+    case PathElementAddCurveToPoint:
+        doIntersection = true;
+        point = element.points[2];
+        break;
+    case PathElementCloseSubpath:
+        doIntersection = true;
+        point = state.startingPoint;
+        break;
+    }
+    if (!doIntersection)
+        return;
+    if (auto intersectionPoint = findIntersectionPoint(state.y1, state.currentPoint, point))
+        updateX(state, *intersectionPoint);
+    if (auto intersectionPoint = findIntersectionPoint(state.y2, state.currentPoint, point))
+        updateX(state, *intersectionPoint);
+    if ((state.currentPoint.y() >= state.y1 && state.currentPoint.y() <= state.y2)
+        || (state.currentPoint.y() <= state.y1 && state.currentPoint.y() >= state.y2))
+        updateX(state, state.currentPoint.x());
+    state.currentPoint = point;
+}
+
+class GlyphToPathTranslator {
+public:
+    GlyphToPathTranslator(const TextRun& textRun, const GlyphBuffer& glyphBuffer, const FloatPoint& textOrigin)
+        : m_index(0)
+        , m_textRun(textRun)
+        , m_glyphBuffer(glyphBuffer)
+        , m_fontData(glyphBuffer.fontAt(m_index))
+        , m_translation(AffineTransform::translation(textOrigin.x(), textOrigin.y()).scale(1, -1))
+    {
+    }
+
+    bool containsMorePaths() { return m_index != m_glyphBuffer.size(); }
+    Path path();
+    std::pair<float, float> extents();
+    GlyphUnderlineType underlineType();
+    void advance();
+
+private:
+    unsigned m_index;
+    const TextRun& m_textRun;
+    const GlyphBuffer& m_glyphBuffer;
+    const Font* m_fontData;
+    AffineTransform m_translation;
+};
+
+Path GlyphToPathTranslator::path()
+{
+    Path path = m_fontData->pathForGlyph(m_glyphBuffer.glyphAt(m_index));
+    path.transform(m_translation);
+    return path;
+}
+
+std::pair<float, float> GlyphToPathTranslator::extents()
+{
+    auto beginning = m_translation.mapPoint(FloatPoint(0, 0));
+    auto advance = m_glyphBuffer.advanceAt(m_index);
+    auto end = m_translation.mapSize(FloatSize(advance.width(), advance.height()));
+    return std::make_pair(beginning.x(), beginning.x() + end.width());
+}
+
+auto GlyphToPathTranslator::underlineType() -> GlyphUnderlineType
+{
+    return computeUnderlineType(m_textRun, m_glyphBuffer, m_index);
+}
+
+void GlyphToPathTranslator::advance()
+{
+    GlyphBufferAdvance advance = m_glyphBuffer.advanceAt(m_index);
+    m_translation.translate(FloatSize(advance.width(), advance.height()));
+    ++m_index;
+    if (m_index < m_glyphBuffer.size())
+        m_fontData = m_glyphBuffer.fontAt(m_index);
+}
+
+DashArray FontCascade::dashesForIntersectionsWithRect(const TextRun& run, const FloatPoint& textOrigin, const FloatRect& lineExtents) const
+{
+    if (isLoadingCustomFonts())
+        return DashArray();
+
+    GlyphBuffer glyphBuffer;
+    glyphBuffer.saveOffsetsInString();
+    float deltaX;
+    if (codePath(run) != FontCascade::Complex)
+        deltaX = getGlyphsAndAdvancesForSimpleText(run, 0, run.length(), glyphBuffer);
+    else
+        deltaX = getGlyphsAndAdvancesForComplexText(run, 0, run.length(), glyphBuffer);
+
+    if (!glyphBuffer.size())
+        return DashArray();
+
+    FloatPoint origin = FloatPoint(textOrigin.x() + deltaX, textOrigin.y());
+    GlyphToPathTranslator translator(run, glyphBuffer, origin);
+    DashArray result;
+    for (unsigned index = 0; translator.containsMorePaths(); ++index, translator.advance()) {
+        GlyphIterationState info = { FloatPoint(0, 0), FloatPoint(0, 0), lineExtents.y(), lineExtents.y() + lineExtents.height(), lineExtents.x() + lineExtents.width(), lineExtents.x() };
+        const Font* localFont = glyphBuffer.fontAt(index);
+        if (!localFont) {
+            // The advances will get all messed up if we do anything other than bail here.
+            result.clear();
+            break;
+        }
+        switch (translator.underlineType()) {
+        case GlyphUnderlineType::SkipDescenders: {
+            Path path = translator.path();
+            path.apply([&](const PathElement& element) {
+                findPathIntersections(info, element);
+            });
+            if (info.minX < info.maxX) {
+                result.append(info.minX - lineExtents.x());
+                result.append(info.maxX - lineExtents.x());
+            }
+            break;
+        }
+        case GlyphUnderlineType::SkipGlyph: {
+            std::pair<float, float> extents = translator.extents();
+            result.append(extents.first - lineExtents.x());
+            result.append(extents.second - lineExtents.x());
+            break;
+        }
+        case GlyphUnderlineType::DrawOverGlyph:
+            // Nothing to do
+            break;
+        }
+    }
+    return result;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCascadeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCascade.h (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCascade.h     2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.h        2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -81,18 +81,6 @@
</span><span class="cx">     bool computeBounds { false };
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-class GlyphToPathTranslator {
-public:
-    enum class GlyphUnderlineType {SkipDescenders, SkipGlyph, DrawOverGlyph};
-    virtual bool containsMorePaths() = 0;
-    virtual Path path() = 0;
-    virtual std::pair<float, float> extents() = 0;
-    virtual GlyphUnderlineType underlineType() = 0;
-    virtual void advance() = 0;
-    virtual ~GlyphToPathTranslator() = default;
-};
-GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun&, const GlyphBuffer&, unsigned index);
-
</del><span class="cx"> class TextLayoutDeleter {
</span><span class="cx"> public:
</span><span class="cx">     void operator()(TextLayout*) const;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGlyphMetricsMaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GlyphMetricsMap.h (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GlyphMetricsMap.h 2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/platform/graphics/GlyphMetricsMap.h    2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #define GlyphMetricsMap_h
</span><span class="cx"> 
</span><span class="cx"> #include "Glyph.h"
</span><ins>+#include "Path.h"
</ins><span class="cx"> #include <array>
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="cx"> 
</span><span class="lines">@@ -45,6 +46,11 @@
</span><span class="cx">         return locatePage(glyph / GlyphMetricsPage::size).metricsForGlyph(glyph);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    const T& existingMetricsForGlyph(Glyph glyph)
+    {
+        return locatePage(glyph / GlyphMetricsPage::size).existingMetricsForGlyph(glyph);
+    }
+
</ins><span class="cx">     void setMetricsForGlyph(Glyph glyph, const T& metrics)
</span><span class="cx">     {
</span><span class="cx">         locatePage(glyph / GlyphMetricsPage::size).setMetricsForGlyph(glyph, metrics);
</span><span class="lines">@@ -68,6 +74,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         T metricsForGlyph(Glyph glyph) const { return m_metrics[glyph % size]; }
</span><ins>+        const T& existingMetricsForGlyph(Glyph glyph) const { return m_metrics[glyph % size]; }
</ins><span class="cx">         void setMetricsForGlyph(Glyph glyph, const T& metrics)
</span><span class="cx">         {
</span><span class="cx">             setMetricsForIndex(glyph % size, metrics);
</span><span class="lines">@@ -108,6 +115,11 @@
</span><span class="cx">     return FloatRect(0, 0, cGlyphSizeUnknown, cGlyphSizeUnknown);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template<> inline std::optional<Path> GlyphMetricsMap<std::optional<Path>>::unknownMetrics()
+{
+    return std::nullopt;
+}
+
</ins><span class="cx"> template<class T> typename GlyphMetricsMap<T>::GlyphMetricsPage& GlyphMetricsMap<T>::locatePageSlowCase(unsigned pageNumber)
</span><span class="cx"> {
</span><span class="cx">     if (!pageNumber) {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsTextRunh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/TextRun.h (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/TextRun.h 2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/platform/graphics/TextRun.h    2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -35,7 +35,6 @@
</span><span class="cx"> class FontCascade;
</span><span class="cx"> class GraphicsContext;
</span><span class="cx"> class GlyphBuffer;
</span><del>-class GlyphToPathTranslator;
</del><span class="cx"> class Font;
</span><span class="cx"> 
</span><span class="cx"> struct GlyphData;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoFontCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp       2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp  2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -78,198 +78,23 @@
</span><span class="cx">         state.textDrawingMode, state.strokeThickness, state.shadowOffset, state.shadowColor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
-struct GlyphIterationState {
-    GlyphIterationState(FloatPoint startingPoint, FloatPoint currentPoint, float centerOfLine, float minX, float maxX)
-        : startingPoint(startingPoint)
-        , currentPoint(currentPoint)
-        , centerOfLine(centerOfLine)
-        , minX(minX)
-        , maxX(maxX)
-    {
-    }
-    FloatPoint startingPoint;
-    FloatPoint currentPoint;
-    float centerOfLine;
-    float minX;
-    float maxX;
-};
-
-static bool findIntersectionPoint(float y, FloatPoint p1, FloatPoint p2, float& x)
</del><ins>+Path Font::platformPathForGlyph(Glyph glyph) const
</ins><span class="cx"> {
</span><del>-    x = p1.x() + (y - p1.y()) * (p2.x() - p1.x()) / (p2.y() - p1.y());
-    return (p1.y() < y && p2.y() > y) || (p1.y() > y && p2.y() < y);
-}
-
-static void updateX(GlyphIterationState& state, float x)
-{
-    state.minX = std::min(state.minX, x);
-    state.maxX = std::max(state.maxX, x);
-}
-
-// This function is called by Path::apply 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 the vertical center of the underline found in GlyphIterationState::centerOfLine.
-// It keeps track of the leftmost and rightmost intersection in  GlyphIterationState::minX and 
-// GlyphIterationState::maxX.
-static void findPathIntersections(GlyphIterationState& state, const PathElement& element)
-{
-    bool doIntersection = false;
-    FloatPoint point = FloatPoint();
-    switch (element.type) {
-    case PathElementMoveToPoint:
-        state.startingPoint = element.points[0];
-        state.currentPoint = element.points[0];
-        break;
-    case PathElementAddLineToPoint:
-        doIntersection = true;
-        point = element.points[0];
-        break;
-    case PathElementAddQuadCurveToPoint:
-        doIntersection = true;
-        point = element.points[1];
-        break;
-    case PathElementAddCurveToPoint:
-        doIntersection = true;
-        point = element.points[2];
-        break;
-    case PathElementCloseSubpath:
-        doIntersection = true;
-        point = state.startingPoint;
-        break;
-    }
-
-    if (!doIntersection)
-        return;
-
-    float x;
-    if (findIntersectionPoint(state.centerOfLine, state.currentPoint, point, x))
-        updateX(state, x);
-
-    state.currentPoint = point;
-}
-
-class CairoGlyphToPathTranslator final : public GlyphToPathTranslator {
-public:
-    CairoGlyphToPathTranslator(const TextRun& textRun, const GlyphBuffer& glyphBuffer, const FloatPoint& textOrigin)
-        : m_index(0)
-        , m_textRun(textRun)
-        , m_glyphBuffer(glyphBuffer)
-        , m_fontData(glyphBuffer.fontAt(m_index))
-        , m_translation(AffineTransform().translate(textOrigin.x(), textOrigin.y()))
-    {
-    }
-
-    bool containsMorePaths() final { return m_index != m_glyphBuffer.size(); }
-    Path path() final;
-    std::pair<float, float> extents() final;
-    GlyphUnderlineType underlineType() final;
-    void advance() final;
-
-private:
-    unsigned m_index;
-    const TextRun& m_textRun;
-    const GlyphBuffer& m_glyphBuffer;
-    const Font* m_fontData;
-    AffineTransform m_translation;
-};
-
-Path CairoGlyphToPathTranslator::path()
-{
</del><span class="cx">     Path path;
</span><span class="cx">     path.ensurePlatformPath();
</span><span class="cx"> 
</span><del>-    cairo_glyph_t cairoGlyph = { m_glyphBuffer.glyphAt(m_index), 0, 0 };
-    cairo_set_scaled_font(path.platformPath()->context(), m_fontData->platformData().scaledFont());
</del><ins>+    cairo_glyph_t cairoGlyph = { glyph, 0, 0 };
+    cairo_set_scaled_font(path.platformPath()->context(), platformData().scaledFont());
</ins><span class="cx">     cairo_glyph_path(path.platformPath()->context(), &cairoGlyph, 1);
</span><span class="cx"> 
</span><del>-    float syntheticBoldOffset = m_fontData->syntheticBoldOffset();
</del><ins>+    float syntheticBoldOffset = this->syntheticBoldOffset();
</ins><span class="cx">     if (syntheticBoldOffset) {
</span><span class="cx">         cairo_translate(path.platformPath()->context(), syntheticBoldOffset, 0);
</span><span class="cx">         cairo_glyph_path(path.platformPath()->context(), &cairoGlyph, 1);
</span><span class="cx">     }
</span><del>-
-    path.transform(m_translation);
</del><span class="cx">     return path;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::pair<float, float> CairoGlyphToPathTranslator::extents()
-{
-    FloatPoint beginning = m_translation.mapPoint(FloatPoint());
-    FloatSize end = m_translation.mapSize(m_glyphBuffer.advanceAt(m_index));
-    return std::make_pair(static_cast<float>(beginning.x()), static_cast<float>(beginning.x() + end.width()));
-}
-
-GlyphToPathTranslator::GlyphUnderlineType CairoGlyphToPathTranslator::underlineType()
-{
-    return computeUnderlineType(m_textRun, m_glyphBuffer, m_index);
-}
-
-void CairoGlyphToPathTranslator::advance()
-{
-    GlyphBufferAdvance advance = m_glyphBuffer.advanceAt(m_index);
-    m_translation = m_translation.translate(advance.width(), advance.height());
-    ++m_index;
-    if (m_index < m_glyphBuffer.size())
-        m_fontData = m_glyphBuffer.fontAt(m_index);
-}
-
-DashArray FontCascade::dashesForIntersectionsWithRect(const TextRun& run, const FloatPoint& textOrigin, const FloatRect& lineExtents) const
-{
-    if (isLoadingCustomFonts())
-        return DashArray();
-
-    GlyphBuffer glyphBuffer;
-    glyphBuffer.saveOffsetsInString();
-    float deltaX;
-    if (codePath(run) != FontCascade::Complex)
-        deltaX = getGlyphsAndAdvancesForSimpleText(run, 0, run.length(), glyphBuffer);
-    else
-        deltaX = getGlyphsAndAdvancesForComplexText(run, 0, run.length(), glyphBuffer);
-
-    if (!glyphBuffer.size())
-        return DashArray();
-
-    // FIXME: Handle SVG + non-SVG interleaved runs. https://bugs.webkit.org/show_bug.cgi?id=133778
-    FloatPoint origin = FloatPoint(textOrigin.x() + deltaX, textOrigin.y());
-    CairoGlyphToPathTranslator translator(run, glyphBuffer, origin);
-    DashArray result;
-    for (int index = 0; translator.containsMorePaths(); ++index, translator.advance()) {
-        float centerOfLine = lineExtents.y() + (lineExtents.height() / 2);
-        GlyphIterationState info = GlyphIterationState(FloatPoint(), FloatPoint(), centerOfLine, lineExtents.x() + lineExtents.width(), lineExtents.x());
-        const Font* localFontData = glyphBuffer.fontAt(index);
-        if (!localFontData) {
-            // The advances will get all messed up if we do anything other than bail here.
-            result.clear();
-            break;
-        }
-        switch (translator.underlineType()) {
-        case GlyphToPathTranslator::GlyphUnderlineType::SkipDescenders: {
-            Path path = translator.path();
-            path.apply([&info](const PathElement& pathElement) {
-                findPathIntersections(info, pathElement);
-            });
-            if (info.minX < info.maxX) {
-                result.append(info.minX - lineExtents.x());
-                result.append(info.maxX - lineExtents.x());
-            }
-            break;
-        }
-        case GlyphToPathTranslator::GlyphUnderlineType::SkipGlyph: {
-            std::pair<float, float> extents = translator.extents();
-            result.append(extents.first - lineExtents.x());
-            result.append(extents.second - lineExtents.x());
-            break;
-        }
-        case GlyphToPathTranslator::GlyphUnderlineType::DrawOverGlyph:
-            // Nothing to do
-            break;
-        }
-    }
-    return result;
-}
-#endif // ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // USE(CAIRO)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaFontCascadeCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm 2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm    2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -303,188 +303,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#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& x)
-{
-    x = p1.x + (y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y);
-    return (p1.y < y && p2.y > y) || (p1.y > y && p2.y < y);
-}
-
-static void updateX(GlyphIterationState& state, CGFloat x)
-{
-    state.minX = std::min(state.minX, x);
-    state.maxX = std::max(state.maxX, x);
-}
-
-// 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& state = *static_cast<GlyphIterationState*>(stateAsVoidPointer);
-    bool doIntersection = false;
-    CGPoint point = CGPointZero;
-    switch (e->type) {
-    case kCGPathElementMoveToPoint:
-        state.startingPoint = e->points[0];
-        state.currentPoint = e->points[0];
-        break;
-    case kCGPathElementAddLineToPoint:
-        doIntersection = true;
-        point = e->points[0];
-        break;
-    case kCGPathElementAddQuadCurveToPoint:
-        doIntersection = true;
-        point = e->points[1];
-        break;
-    case kCGPathElementAddCurveToPoint:
-        doIntersection = true;
-        point = e->points[2];
-        break;
-    case kCGPathElementCloseSubpath:
-        doIntersection = true;
-        point = state.startingPoint;
-        break;
-    }
-    if (!doIntersection)
-        return;
-    CGFloat x;
-    if (findIntersectionPoint(state.y1, state.currentPoint, point, x))
-        updateX(state, x);
-    if (findIntersectionPoint(state.y2, state.currentPoint, point, x))
-        updateX(state, x);
-    if ((state.currentPoint.y >= state.y1 && state.currentPoint.y <= state.y2)
-        || (state.currentPoint.y <= state.y1 && state.currentPoint.y >= state.y2))
-        updateX(state, state.currentPoint.x);
-    state.currentPoint = point;
-}
-
-class MacGlyphToPathTranslator final : public GlyphToPathTranslator {
-public:
-    MacGlyphToPathTranslator(const TextRun& textRun, const GlyphBuffer& glyphBuffer, const FloatPoint& textOrigin)
-        : m_index(0)
-        , m_textRun(textRun)
-        , m_glyphBuffer(glyphBuffer)
-        , m_fontData(glyphBuffer.fontAt(m_index))
-        , m_translation(CGAffineTransformScale(CGAffineTransformMakeTranslation(textOrigin.x(), textOrigin.y()), 1, -1))
-    {
-    }
-    bool containsMorePaths() final { return m_index != m_glyphBuffer.size(); }
-    Path path() final;
-    std::pair<float, float> extents() final;
-    GlyphUnderlineType underlineType() final;
-    void advance() final;
-
-private:
-    unsigned m_index;
-    const TextRun& m_textRun;
-    const GlyphBuffer& m_glyphBuffer;
-    const Font* m_fontData;
-    CGAffineTransform m_translation;
-};
-
-Path MacGlyphToPathTranslator::path()
-{
-    RetainPtr<CGPathRef> result = adoptCF(CTFontCreatePathForGlyph(m_fontData->platformData().ctFont(), m_glyphBuffer.glyphAt(m_index), &m_translation));
-    return adoptCF(CGPathCreateMutableCopy(result.get()));
-}
-
-std::pair<float, float> MacGlyphToPathTranslator::extents()
-{
-    CGPoint beginning = CGPointApplyAffineTransform(CGPointMake(0, 0), m_translation);
-    CGSize end = CGSizeApplyAffineTransform(m_glyphBuffer.advanceAt(m_index), m_translation);
-    return std::make_pair(static_cast<float>(beginning.x), static_cast<float>(beginning.x + end.width));
-}
-
-auto MacGlyphToPathTranslator::underlineType() -> GlyphUnderlineType
-{
-    return computeUnderlineType(m_textRun, m_glyphBuffer, m_index);
-}
-
-void MacGlyphToPathTranslator::advance()
-{
-    GlyphBufferAdvance advance = m_glyphBuffer.advanceAt(m_index);
-    m_translation = CGAffineTransformTranslate(m_translation, advance.width(), advance.height());
-    ++m_index;
-    if (m_index < m_glyphBuffer.size())
-        m_fontData = m_glyphBuffer.fontAt(m_index);
-}
-
-DashArray FontCascade::dashesForIntersectionsWithRect(const TextRun& run, const FloatPoint& textOrigin, const FloatRect& lineExtents) const
-{
-    if (isLoadingCustomFonts())
-        return DashArray();
-
-    GlyphBuffer glyphBuffer;
-    glyphBuffer.saveOffsetsInString();
-    float deltaX;
-    if (codePath(run) != FontCascade::Complex)
-        deltaX = getGlyphsAndAdvancesForSimpleText(run, 0, run.length(), glyphBuffer);
-    else
-        deltaX = getGlyphsAndAdvancesForComplexText(run, 0, run.length(), glyphBuffer);
-
-    if (!glyphBuffer.size())
-        return DashArray();
-    
-    // FIXME: Handle SVG + non-SVG interleaved runs. https://bugs.webkit.org/show_bug.cgi?id=133778
-    FloatPoint origin = FloatPoint(textOrigin.x() + deltaX, textOrigin.y());
-    MacGlyphToPathTranslator translator(run, glyphBuffer, origin);
-    DashArray result;
-    for (unsigned index = 0; translator.containsMorePaths(); ++index, translator.advance()) {
-        GlyphIterationState info = GlyphIterationState(CGPointMake(0, 0), CGPointMake(0, 0), lineExtents.y(), lineExtents.y() + lineExtents.height(), lineExtents.x() + lineExtents.width(), lineExtents.x());
-        const Font* localFont = glyphBuffer.fontAt(index);
-        if (!localFont) {
-            // The advances will get all messed up if we do anything other than bail here.
-            result.clear();
-            break;
-        }
-        switch (translator.underlineType()) {
-        case GlyphToPathTranslator::GlyphUnderlineType::SkipDescenders: {
-            Path path = translator.path();
-            CGPathApply(path.platformPath(), &info, &findPathIntersections);
-            if (info.minX < info.maxX) {
-                result.append(info.minX - lineExtents.x());
-                result.append(info.maxX - lineExtents.x());
-            }
-            break;
-        }
-        case GlyphToPathTranslator::GlyphUnderlineType::SkipGlyph: {
-            std::pair<float, float> extents = translator.extents();
-            result.append(extents.first - lineExtents.x());
-            result.append(extents.second - lineExtents.x());
-            break;
-        }
-        case GlyphToPathTranslator::GlyphUnderlineType::DrawOverGlyph:
-            // Nothing to do
-            break;
-        }
-    }
-    return result;
-}
-#endif
-
</del><span class="cx"> bool FontCascade::primaryFontIsSystemFont() const
</span><span class="cx"> {
</span><span class="cx">     const auto& fontData = primaryFont();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaFontCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm        2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm   2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -597,6 +597,20 @@
</span><span class="cx">     return advance.width + m_syntheticBoldOffset;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Path Font::platformPathForGlyph(Glyph glyph) const
+{
+    auto result = adoptCF(CTFontCreatePathForGlyph(platformData().ctFont(), glyph, nullptr));
+    auto syntheticBoldOffset = this->syntheticBoldOffset();
+    if (syntheticBoldOffset) {
+        auto newPath = adoptCF(CGPathCreateMutable());
+        CGPathAddPath(newPath.get(), nullptr, result.get());
+        auto translation = CGAffineTransformMakeTranslation(syntheticBoldOffset, 0);
+        CGPathAddPath(newPath.get(), &translation, result.get());
+        return newPath;
+    }
+    return adoptCF(CGPathCreateMutableCopy(result.get()));
+}
+
</ins><span class="cx"> bool Font::platformSupportsCodePoint(UChar32 character) const
</span><span class="cx"> {
</span><span class="cx">     UniChar codeUnits[2];
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinSimpleFontDataCGWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp       2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp  2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -152,6 +152,21 @@
</span><span class="cx">     return advance.width + m_syntheticBoldOffset;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Path Font::platformPathForGlyph(Glyph glyph) const
+{
+    auto ctFont = adoptCF(CTFontCreateWithGraphicsFont(platformData().cgFont(), platformData().size(), nullptr, nullptr));
+    auto result = adoptCF(CTFontCreatePathForGlyph(ctFont.get(), glyph, nullptr));
+    auto syntheticBoldOffset = this->syntheticBoldOffset();
+    if (syntheticBoldOffset) {
+        auto newPath = adoptCF(CGPathCreateMutable());
+        CGPathAddPath(newPath.get(), nullptr, result.get());
+        auto translation = CGAffineTransformMakeTranslation(syntheticBoldOffset, 0);
+        CGPathAddPath(newPath.get(), &translation, result.get());
+        return newPath;
+    }
+    return adoptCF(CGPathCreateMutableCopy(result.get()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinSimpleFontDataDirect2Dcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/SimpleFontDataDirect2D.cpp (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/SimpleFontDataDirect2D.cpp    2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/platform/graphics/win/SimpleFontDataDirect2D.cpp       2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include "GlyphPage.h"
</span><span class="cx"> #include "GraphicsContext.h"
</span><span class="cx"> #include "HWndDC.h"
</span><ins>+#include "NotImplemented.h"
</ins><span class="cx"> #include <comutil.h>
</span><span class="cx"> #include <dwrite.h>
</span><span class="cx"> #include <mlang.h>
</span><span class="lines">@@ -230,6 +231,12 @@
</span><span class="cx">     return width + m_syntheticBoldOffset;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Path Font::platformPathForGlyph(Glyph) const
+{
+    notImplemented();
+    return Path();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingTextDecorationPaintercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/TextDecorationPainter.cpp (237844 => 237845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/TextDecorationPainter.cpp 2018-11-06 04:32:44 UTC (rev 237844)
+++ trunk/Source/WebCore/rendering/TextDecorationPainter.cpp    2018-11-06 04:35:50 UTC (rev 237845)
</span><span class="lines">@@ -116,7 +116,6 @@
</span><span class="cx">     context.setStrokeThickness(strokeThickness);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
</del><span class="cx"> static bool compareTuples(std::pair<float, float> l, std::pair<float, float> r)
</span><span class="cx"> {
</span><span class="cx">     return l.first < r.first;
</span><span class="lines">@@ -167,7 +166,6 @@
</span><span class="cx">     
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorationStyle)
</span><span class="cx"> {
</span><span class="lines">@@ -212,10 +210,6 @@
</span><span class="cx"> 
</span><span class="cx"> void TextDecorationPainter::paintTextDecoration(const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& boxOrigin)
</span><span class="cx"> {
</span><del>-#if !ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
-    UNUSED_PARAM(textRun);
-    UNUSED_PARAM(textOrigin);
-#endif
</del><span class="cx">     const auto& fontMetrics = m_lineStyle.fontMetrics();
</span><span class="cx">     float textDecorationThickness = textDecorationStrokeThickness(m_lineStyle.computedFontPixelSize());
</span><span class="cx">     FloatPoint localOrigin = boxOrigin;
</span><span class="lines">@@ -228,7 +222,6 @@
</span><span class="cx">         if (style == TextDecorationStyle::Wavy)
</span><span class="cx">             strokeWavyTextDecoration(m_context, rect, m_lineStyle.computedFontPixelSize());
</span><span class="cx">         else if (decoration == TextDecoration::Underline || decoration == TextDecoration::Overline) {
</span><del>-#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
</del><span class="cx">             if ((m_lineStyle.textDecorationSkip() == TextDecorationSkip::Ink || m_lineStyle.textDecorationSkip() == TextDecorationSkip::Auto) && m_isHorizontal) {
</span><span class="cx">                 if (!m_context.paintingDisabled()) {
</span><span class="cx">                     FloatRect underlineBoundingBox = m_context.computeUnderlineBoundsForText(rect, m_isPrinting);
</span><span class="lines">@@ -238,11 +231,10 @@
</span><span class="cx">                     // We don't use underlineBoundingBox here because drawLinesForText() will run computeUnderlineBoundsForText() internally.
</span><span class="cx">                     m_context.drawLinesForText(rect.location(), rect.height(), boundaries, m_isPrinting, style == TextDecorationStyle::Double, strokeStyle);
</span><span class="cx">                 }
</span><del>-            } else
</del><ins>+            } else {
</ins><span class="cx">                 // FIXME: Need to support text-decoration-skip: none.
</span><del>-#endif
</del><span class="cx">                 m_context.drawLineForText(rect, m_isPrinting, style == TextDecorationStyle::Double, strokeStyle);
</span><del>-            
</del><ins>+            }
</ins><span class="cx">         } else {
</span><span class="cx">             ASSERT(decoration == TextDecoration::LineThrough);
</span><span class="cx">             m_context.drawLineForText(rect, m_isPrinting, style == TextDecorationStyle::Double, strokeStyle);
</span></span></pre>
</div>
</div>

</body>
</html>