<!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>[211294] 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/211294">211294</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2017-01-27 12:28:11 -0800 (Fri, 27 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Cocoa] Prepare ComplexTextController for unit testing
https://bugs.webkit.org/show_bug.cgi?id=167493

Reviewed by Dean Jackson.

Source/WebCore:

ComplexTextController has three phases:
1. Interrogate Core Text about some text
2. Compute layout advances and paint advances from the information retrieved from
Core Text
3. Iterate through the layout advances or paint advances.

This patch tests phases 2 and 3 by chopping ComplexTextController between
phases 1 and 2, and injecting foreign metrics from a unit test. These metrics
have been gathered from real-world uses; however, a layout test is not appropriate
because the fonts which produced these metrics are not licensed appropriately.
The tests can enforce the correct behavior by using ComplexTextController's
public API.

This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=166013.
However, the fix for that bug is quite large, so I've split out this smaller piece
to ease the reviewing burden. The tests I've added are disabled for now (because
they fail), but will be enabled by the fix to that bug.

No new tests because there is no behavior change.

* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/FontCascade.h:
* platform/graphics/FontDescription.h:
* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::ComplexTextController):
(WebCore::ComplexTextController::finishConstruction):
* platform/graphics/mac/ComplexTextController.h:
(WebCore::ComplexTextController::ComplexTextRun::createForTesting):
* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):

Tools:

Create four unit tests.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp: Added.
(TestWebKitAPI::ComplexTextControllerTest::SetUp):
(TestWebKitAPI::TEST_F):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCascadeh">trunk/Source/WebCore/platform/graphics/FontCascade.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontDescriptionh">trunk/Source/WebCore/platform/graphics/FontDescription.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacComplexTextControllercpp">trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacComplexTextControllerh">trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacComplexTextControllerCoreTextmm">trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreComplexTextControllercpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (211293 => 211294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-27 19:37:05 UTC (rev 211293)
+++ trunk/Source/WebCore/ChangeLog        2017-01-27 20:28:11 UTC (rev 211294)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2017-01-27  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Cocoa] Prepare ComplexTextController for unit testing
+        https://bugs.webkit.org/show_bug.cgi?id=167493
+
+        Reviewed by Dean Jackson.
+
+        ComplexTextController has three phases:
+        1. Interrogate Core Text about some text
+        2. Compute layout advances and paint advances from the information retrieved from
+        Core Text
+        3. Iterate through the layout advances or paint advances.
+
+        This patch tests phases 2 and 3 by chopping ComplexTextController between
+        phases 1 and 2, and injecting foreign metrics from a unit test. These metrics
+        have been gathered from real-world uses; however, a layout test is not appropriate
+        because the fonts which produced these metrics are not licensed appropriately.
+        The tests can enforce the correct behavior by using ComplexTextController's
+        public API.
+
+        This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=166013.
+        However, the fix for that bug is quite large, so I've split out this smaller piece
+        to ease the reviewing burden. The tests I've added are disabled for now (because
+        they fail), but will be enabled by the fix to that bug.
+
+        No new tests because there is no behavior change.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/FontCascade.h:
+        * platform/graphics/FontDescription.h:
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::ComplexTextController):
+        (WebCore::ComplexTextController::finishConstruction):
+        * platform/graphics/mac/ComplexTextController.h:
+        (WebCore::ComplexTextController::ComplexTextRun::createForTesting):
+        * platform/graphics/mac/ComplexTextControllerCoreText.mm:
+        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
+
</ins><span class="cx"> 2017-01-27  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Simple line layout: Do not bail out on -webkit-line-box-contain: block glyphs unless text overflows vertically.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (211293 => 211294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-01-27 19:37:05 UTC (rev 211293)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-01-27 20:28:11 UTC (rev 211294)
</span><span class="lines">@@ -1452,7 +1452,7 @@
</span><span class="cx">                 37B327D31D17096A005737FA /* PIPSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 37B327D21D17096A005737FA /* PIPSPI.h */; };
</span><span class="cx">                 37BAAE581980D1DD005DFE71 /* ProtectionSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 37BAAE571980D1DD005DFE71 /* ProtectionSpace.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 37C236101097EE7700EF9F72 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C2360E1097EE7700EF9F72 /* ComplexTextController.cpp */; };
</span><del>-                37C236111097EE7700EF9F72 /* ComplexTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C2360F1097EE7700EF9F72 /* ComplexTextController.h */; };
</del><ins>+                37C236111097EE7700EF9F72 /* ComplexTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C2360F1097EE7700EF9F72 /* ComplexTextController.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 37C238221098C84200EF9F72 /* ComplexTextControllerCoreText.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.mm */; };
</span><span class="cx">                 37D456FD1A9A50D8003330A1 /* LocalizableStrings.pm in Copy Scripts */ = {isa = PBXBuildFile; fileRef = 37D456FB1A9A50B6003330A1 /* LocalizableStrings.pm */; };
</span><span class="cx">                 37DDCD9413844FD50008B793 /* MIMEHeader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37DDCD9213844FD50008B793 /* MIMEHeader.cpp */; };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCascadeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCascade.h (211293 => 211294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCascade.h        2017-01-27 19:37:05 UTC (rev 211293)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.h        2017-01-27 20:28:11 UTC (rev 211294)
</span><span class="lines">@@ -114,7 +114,7 @@
</span><span class="cx"> class FontCascade {
</span><span class="cx"> public:
</span><span class="cx">     WEBCORE_EXPORT FontCascade();
</span><del>-    WEBCORE_EXPORT FontCascade(const FontCascadeDescription&amp;, float letterSpacing, float wordSpacing);
</del><ins>+    WEBCORE_EXPORT FontCascade(const FontCascadeDescription&amp;, float letterSpacing = 0, float wordSpacing = 0);
</ins><span class="cx">     // This constructor is only used if the platform wants to start with a native font.
</span><span class="cx">     WEBCORE_EXPORT FontCascade(const FontPlatformData&amp;, FontSmoothingMode = AutoSmoothing);
</span><span class="cx"> 
</span><span class="lines">@@ -129,7 +129,7 @@
</span><span class="cx">     int pixelSize() const { return fontDescription().computedPixelSize(); }
</span><span class="cx">     float size() const { return fontDescription().computedSize(); }
</span><span class="cx"> 
</span><del>-    void update(RefPtr&lt;FontSelector&gt;&amp;&amp;) const;
</del><ins>+    WEBCORE_EXPORT void update(RefPtr&lt;FontSelector&gt;&amp;&amp;) const;
</ins><span class="cx"> 
</span><span class="cx">     enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontNotReady };
</span><span class="cx">     WEBCORE_EXPORT float drawText(GraphicsContext&amp;, const TextRun&amp;, const FloatPoint&amp;, unsigned from = 0, std::optional&lt;unsigned&gt; to = std::nullopt, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontDescriptionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontDescription.h (211293 => 211294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontDescription.h        2017-01-27 19:37:05 UTC (rev 211293)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.h        2017-01-27 20:28:11 UTC (rev 211294)
</span><span class="lines">@@ -197,7 +197,7 @@
</span><span class="cx"> // FIXME: Move to a file of its own.
</span><span class="cx"> class FontCascadeDescription : public FontDescription {
</span><span class="cx"> public:
</span><del>-    FontCascadeDescription();
</del><ins>+    WEBCORE_EXPORT FontCascadeDescription();
</ins><span class="cx"> 
</span><span class="cx">     bool operator==(const FontCascadeDescription&amp;) const;
</span><span class="cx">     bool operator!=(const FontCascadeDescription&amp; other) const { return !(*this == other); }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacComplexTextControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp (211293 => 211294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp        2017-01-27 19:37:05 UTC (rev 211293)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp        2017-01-27 20:28:11 UTC (rev 211294)
</span><span class="lines">@@ -128,6 +128,23 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     collectComplexTextRuns();
</span><ins>+
+    finishConstruction();
+}
+
+ComplexTextController::ComplexTextController(const FontCascade&amp; font, const TextRun&amp; run, Vector&lt;Ref&lt;ComplexTextRun&gt;&gt;&amp; runs)
+    : m_font(font)
+    , m_run(run)
+    , m_end(run.length())
+{
+    for (auto&amp; run : runs)
+        m_complexTextRuns.append(run.ptr());
+
+    finishConstruction();
+}
+
+void ComplexTextController::finishConstruction()
+{
</ins><span class="cx">     adjustGlyphsAndAdvances();
</span><span class="cx"> 
</span><span class="cx">     if (!m_isLTROnly) {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacComplexTextControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h (211293 => 211294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h        2017-01-27 19:37:05 UTC (rev 211293)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h        2017-01-27 20:28:11 UTC (rev 211294)
</span><span class="lines">@@ -58,8 +58,11 @@
</span><span class="cx"> public:
</span><span class="cx">     ComplexTextController(const FontCascade&amp;, const TextRun&amp;, bool mayUseNaturalWritingDirection = false, HashSet&lt;const Font*&gt;* fallbackFonts = 0, bool forTextEmphasis = false);
</span><span class="cx"> 
</span><ins>+    class ComplexTextRun;
+    WEBCORE_EXPORT ComplexTextController(const FontCascade&amp;, const TextRun&amp;, Vector&lt;Ref&lt;ComplexTextRun&gt;&gt;&amp;);
+
</ins><span class="cx">     // Advance and emit glyphs up to the specified character.
</span><del>-    void advance(unsigned to, GlyphBuffer* = nullptr, GlyphIterationStyle = IncludePartialGlyphs, HashSet&lt;const Font*&gt;* fallbackFonts = nullptr);
</del><ins>+    WEBCORE_EXPORT void advance(unsigned to, GlyphBuffer* = nullptr, GlyphIterationStyle = IncludePartialGlyphs, HashSet&lt;const Font*&gt;* fallbackFonts = nullptr);
</ins><span class="cx"> 
</span><span class="cx">     // Compute the character offset for a given x coordinate.
</span><span class="cx">     unsigned offsetForPosition(float x, bool includePartialGlyphs);
</span><span class="lines">@@ -75,8 +78,7 @@
</span><span class="cx">     float maxGlyphBoundingBoxY() const { return m_maxGlyphBoundingBoxY; }
</span><span class="cx"> 
</span><span class="cx">     float leadingExpansion() const { return m_leadingExpansion; }
</span><del>-    
-private:
</del><ins>+
</ins><span class="cx">     class ComplexTextRun : public RefCounted&lt;ComplexTextRun&gt; {
</span><span class="cx">     public:
</span><span class="cx">         static Ref&lt;ComplexTextRun&gt; create(CTRunRef ctRun, const Font&amp; font, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
</span><span class="lines">@@ -89,6 +91,11 @@
</span><span class="cx">             return adoptRef(*new ComplexTextRun(font, characters, stringLocation, stringLength, ltr));
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        static Ref&lt;ComplexTextRun&gt; createForTesting(Vector&lt;CGSize&gt; advances, Vector&lt;CGPoint&gt; origins, Vector&lt;CGGlyph&gt; glyphs, Vector&lt;CFIndex&gt; stringIndices, CGSize initialAdvance, const Font&amp; font, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange, bool ltr)
+        {
+            return adoptRef(*new ComplexTextRun(advances, origins, glyphs, stringIndices, initialAdvance, font, characters, stringLocation, stringLength, runRange, ltr));
+        }
+
</ins><span class="cx">         unsigned glyphCount() const { return m_glyphCount; }
</span><span class="cx">         const Font&amp; font() const { return m_font; }
</span><span class="cx">         const UChar* characters() const { return m_characters; }
</span><span class="lines">@@ -120,6 +127,7 @@
</span><span class="cx">     private:
</span><span class="cx">         ComplexTextRun(CTRunRef, const Font&amp;, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange);
</span><span class="cx">         ComplexTextRun(const Font&amp;, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr);
</span><ins>+        WEBCORE_EXPORT ComplexTextRun(Vector&lt;CGSize&gt; advances, Vector&lt;CGPoint&gt; origins, Vector&lt;CGGlyph&gt; glyphs, Vector&lt;CFIndex&gt; stringIndices, CGSize initialAdvance, const Font&amp;, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange, bool ltr);
</ins><span class="cx"> 
</span><span class="cx">         Vector&lt;CGSize, 64&gt; m_baseAdvancesVector;
</span><span class="cx">         Vector&lt;CGPoint, 64&gt; m_glyphOrigins;
</span><span class="lines">@@ -138,8 +146,10 @@
</span><span class="cx">         unsigned m_glyphCount;
</span><span class="cx">         unsigned m_stringLocation;
</span><span class="cx">         bool m_isLTR;
</span><del>-        bool m_isMonotonic;
</del><ins>+        bool m_isMonotonic { true };
</ins><span class="cx">     };
</span><ins>+private:
+    void finishConstruction();
</ins><span class="cx">     
</span><span class="cx">     static unsigned stringBegin(const ComplexTextRun&amp; run) { return run.stringLocation() + run.indexBegin(); }
</span><span class="cx">     static unsigned stringEnd(const ComplexTextRun&amp; run) { return run.stringLocation() + run.indexEnd(); }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacComplexTextControllerCoreTextmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm (211293 => 211294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm        2017-01-27 19:37:05 UTC (rev 211293)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm        2017-01-27 20:28:11 UTC (rev 211294)
</span><span class="lines">@@ -111,14 +111,14 @@
</span><span class="cx">     , m_font(font)
</span><span class="cx">     , m_characters(characters)
</span><span class="cx">     , m_stringLength(stringLength)
</span><ins>+    , m_coreTextIndices(CTRunGetStringIndicesPtr(ctRun))
+    , m_glyphs(CTRunGetGlyphsPtr(ctRun))
</ins><span class="cx">     , m_indexBegin(runRange.location)
</span><span class="cx">     , m_indexEnd(runRange.location + runRange.length)
</span><ins>+    , m_glyphCount(CTRunGetGlyphCount(ctRun))
</ins><span class="cx">     , m_stringLocation(stringLocation)
</span><span class="cx">     , m_isLTR(!(CTRunGetStatus(ctRun) &amp; kCTRunStatusRightToLeft))
</span><del>-    , m_isMonotonic(true)
</del><span class="cx"> {
</span><del>-    m_glyphCount = CTRunGetGlyphCount(ctRun);
-    m_coreTextIndices = CTRunGetStringIndicesPtr(ctRun);
</del><span class="cx">     if (!m_coreTextIndices) {
</span><span class="cx">         m_coreTextIndicesVector.grow(m_glyphCount);
</span><span class="cx">         CTRunGetStringIndices(ctRun, CFRangeMake(0, 0), m_coreTextIndicesVector.data());
</span><span class="lines">@@ -125,7 +125,6 @@
</span><span class="cx">         m_coreTextIndices = m_coreTextIndicesVector.data();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_glyphs = CTRunGetGlyphsPtr(ctRun);
</del><span class="cx">     if (!m_glyphs) {
</span><span class="cx">         m_glyphsVector.grow(m_glyphCount);
</span><span class="cx">         CTRunGetGlyphs(ctRun, CFRangeMake(0, 0), m_glyphsVector.data());
</span><span class="lines">@@ -161,7 +160,6 @@
</span><span class="cx">     , m_indexEnd(stringLength)
</span><span class="cx">     , m_stringLocation(stringLocation)
</span><span class="cx">     , m_isLTR(ltr)
</span><del>-    , m_isMonotonic(true)
</del><span class="cx"> {
</span><span class="cx">     m_coreTextIndicesVector.reserveInitialCapacity(m_stringLength);
</span><span class="cx">     unsigned r = 0;
</span><span class="lines">@@ -184,6 +182,27 @@
</span><span class="cx">     m_baseAdvances = m_baseAdvancesVector.data();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+
+ComplexTextController::ComplexTextRun::ComplexTextRun(Vector&lt;CGSize&gt; advances, Vector&lt;CGPoint&gt; origins, Vector&lt;CGGlyph&gt; glyphs, Vector&lt;CFIndex&gt; stringIndices, CGSize initialAdvance, const Font&amp; font, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange, bool ltr)
+    : m_baseAdvancesVector(advances)
+    , m_glyphOrigins(origins)
+    , m_glyphsVector(glyphs)
+    , m_coreTextIndicesVector(stringIndices)
+    , m_initialAdvance(initialAdvance)
+    , m_font(font)
+    , m_characters(characters)
+    , m_stringLength(stringLength)
+    , m_coreTextIndices(m_coreTextIndicesVector.data())
+    , m_glyphs(m_glyphsVector.data())
+    , m_baseAdvances(m_baseAdvancesVector.data())
+    , m_indexBegin(runRange.location)
+    , m_indexEnd(runRange.location + runRange.length)
+    , m_glyphCount(glyphs.size())
+    , m_stringLocation(stringLocation)
+    , m_isLTR(ltr)
+{
+}
+
</ins><span class="cx"> struct ProviderInfo {
</span><span class="cx">     const UChar* cp;
</span><span class="cx">     unsigned length;
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (211293 => 211294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-01-27 19:37:05 UTC (rev 211293)
+++ trunk/Tools/ChangeLog        2017-01-27 20:28:11 UTC (rev 211294)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2017-01-27  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Cocoa] Prepare ComplexTextController for unit testing
+        https://bugs.webkit.org/show_bug.cgi?id=167493
+
+        Reviewed by Dean Jackson.
+
+        Create four unit tests.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp: Added.
+        (TestWebKitAPI::ComplexTextControllerTest::SetUp):
+        (TestWebKitAPI::TEST_F):
+
</ins><span class="cx"> 2017-01-26  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Crash when navigating back to a page in PacheCache when one of its frames has been removed
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (211293 => 211294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-01-27 19:37:05 UTC (rev 211293)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-01-27 20:28:11 UTC (rev 211294)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx">                 1C2B81831C891F0900A5529F /* CancelFontSubresourcePlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */; };
</span><span class="cx">                 1C2B81861C89259D00A5529F /* webfont.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81841C8924A200A5529F /* webfont.html */; };
</span><span class="cx">                 1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81851C89252300A5529F /* Ahem.ttf */; };
</span><ins>+                1C9EB8411E380DA1005C6442 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */; };
</ins><span class="cx">                 1F83571B1D3FFB2300E3967B /* WKBackForwardList.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */; };
</span><span class="cx">                 26DF5A6315A2A27E003689C2 /* CancelLoadFromResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 26DF5A6115A2A22B003689C2 /* CancelLoadFromResourceLoadDelegate.html */; };
</span><span class="cx">                 26F52EAD1828827B0023D412 /* geolocationGetCurrentPosition.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 26F52EAC1828820E0023D412 /* geolocationGetCurrentPosition.html */; };
</span><span class="lines">@@ -823,6 +824,7 @@
</span><span class="cx">                 1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CancelFontSubresourcePlugIn.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1C2B81841C8924A200A5529F /* webfont.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = webfont.html; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1C2B81851C89252300A5529F /* Ahem.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Ahem.ttf; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 1CB9BC371A67482300FE5678 /* WeakPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WeakPtr.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1CF0D3781BBF2F3D00B4EF54 /* WKRetainPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKRetainPtr.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKBackForwardList.mm; path = Tests/WebKit2/WKBackForwardList.mm; sourceTree = SOURCE_ROOT; };
</span><span class="lines">@@ -1604,6 +1606,7 @@
</span><span class="cx">                                 440A1D3814A0103A008A66F2 /* URL.cpp */,
</span><span class="cx">                                 5C6E65411D5CEF8500F7862E /* URLParser.cpp */,
</span><span class="cx">                                 9C64DC311D76198A004B598E /* YouTubePluginReplacement.cpp */,
</span><ins>+                                1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = WebCore;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -2702,6 +2705,7 @@
</span><span class="cx">                                 2DFF7B6D1DA487AF00814614 /* SnapshotStore.mm in Sources */,
</span><span class="cx">                                 5C6E65441D5CEFD400F7862E /* URLParser.cpp in Sources */,
</span><span class="cx">                                 7CCE7F271A411AF600447C4C /* UserContentController.mm in Sources */,
</span><ins>+                                1C9EB8411E380DA1005C6442 /* ComplexTextController.cpp in Sources */,
</ins><span class="cx">                                 7CCE7F2D1A411B1000447C4C /* UserContentTest.mm in Sources */,
</span><span class="cx">                                 7C882E0A1C80C764006BF731 /* UserContentWorld.mm in Sources */,
</span><span class="cx">                                 7CCB99211D3B41F6003922F6 /* UserInitiatedActionInNavigationAction.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreComplexTextControllercpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp (0 => 211294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp        2017-01-27 20:28:11 UTC (rev 211294)
</span><span class="lines">@@ -0,0 +1,234 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+
+#include &lt;JavaScriptCore/InitializeThreading.h&gt;
+#include &lt;WebCore/ComplexTextController.h&gt;
+#include &lt;WebCore/FontCascade.h&gt;
+#include &lt;wtf/MainThread.h&gt;
+#include &lt;wtf/RunLoop.h&gt;
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+class ComplexTextControllerTest : public testing::Test {
+public:
+    virtual void SetUp()
+    {
+        WTF::initializeMainThread();
+        JSC::initializeThreading();
+        RunLoop::initializeMainRunLoop();
+    }
+};
+
+TEST_F(ComplexTextControllerTest, DISABLED_InitialAdvanceWithLeftRunInRTL)
+{
+    FontCascadeDescription description;
+    description.setOneFamily(&quot;Times&quot;);
+    description.setComputedSize(80);
+    FontCascade font(description);
+    font.update(nullptr);
+    auto spaceWidth = font.primaryFont().spaceWidth();
+
+#if USE_LAYOUT_SPECIFIC_ADVANCES
+    Vector&lt;CGSize&gt; advances = { CGSizeZero, CGSizeMake(21.640625, 0.0), CGSizeMake(42.3046875, 0.0), CGSizeMake(55.8984375, 0.0), CGSizeMake(22.34375, 0.0) };
+    Vector&lt;CGPoint&gt; origins = { CGPointMake(-15.15625, 18.046875), CGPointZero, CGPointZero, CGPointZero, CGPointZero };
+#else
+    Vector&lt;CGSize&gt; advances = { CGSizeMake(15.15625, -18.046875), CGSizeMake(21.640625, 0.0), CGSizeMake(42.3046875, 0.0), CGSizeMake(55.8984375, 0.0), CGSizeMake(22.34375, 0.0) };
+    Vector&lt;CGPoint&gt; origins = { };
+#endif
+
+    CGSize initialAdvance = CGSizeMake(-15.15625, 18.046875);
+
+    UChar characters[] = { 0x644, 0x637, 0x641, 0x627, 0x64b, 0x20 };
+    size_t charactersLength = WTF_ARRAY_LENGTH(characters);
+    TextRun textRun(StringView(characters, charactersLength));
+    Ref&lt;ComplexTextController::ComplexTextRun&gt; run1 = ComplexTextController::ComplexTextRun::createForTesting({ CGSizeMake(21.875, 0) }, { CGPointZero }, { 5 }, { 5 }, CGSizeZero, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(5, 1), false);
+    Ref&lt;ComplexTextController::ComplexTextRun&gt; run2 = ComplexTextController::ComplexTextRun::createForTesting(advances, origins, { 193, 377, 447, 431, 458 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 5), false);
+    Vector&lt;Ref&lt;ComplexTextController::ComplexTextRun&gt;&gt; runs;
+    runs.append(WTFMove(run1));
+    runs.append(WTFMove(run2));
+    ComplexTextController controller(font, textRun, runs);
+
+    CGFloat totalWidth = 0;
+    for (size_t i = 1; i &lt; advances.size(); ++i)
+        totalWidth += advances[i].width;
+    EXPECT_NEAR(controller.totalWidth(), spaceWidth + totalWidth, 0.0001);
+    GlyphBuffer glyphBuffer;
+    controller.advance(0, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
+    controller.advance(1, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width, 0.0001);
+    controller.advance(6, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + totalWidth, 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 0, 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 0, 0.0001);
+    EXPECT_EQ(glyphBuffer.size(), 6U);
+    EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(5).width(), spaceWidth + initialAdvance.width, 0.0001);
+}
+
+TEST_F(ComplexTextControllerTest, DISABLED_InitialAdvanceInRTL)
+{
+    FontCascadeDescription description;
+    description.setOneFamily(&quot;Times&quot;);
+    description.setComputedSize(80);
+    FontCascade font(description);
+    font.update(nullptr);
+
+#if USE_LAYOUT_SPECIFIC_ADVANCES
+    Vector&lt;CGSize&gt; advances = { CGSizeZero, CGSizeMake(21.640625, 0.0), CGSizeMake(42.3046875, 0.0), CGSizeMake(55.8984375, 0.0), CGSizeMake(22.34375, 0.0) };
+    Vector&lt;CGPoint&gt; origins = { CGPointMake(-15.15625, 18.046875), CGPointZero, CGPointZero, CGPointZero, CGPointZero };
+#else
+    Vector&lt;CGSize&gt; advances = { CGSizeMake(15.15625, -18.046875), CGSizeMake(21.640625, 0.0), CGSizeMake(42.3046875, 0.0), CGSizeMake(55.8984375, 0.0), CGSizeMake(22.34375, 0.0) };
+    Vector&lt;CGPoint&gt; origins = { };
+#endif
+
+    CGSize initialAdvance = CGSizeMake(-15.15625, 18.046875);
+
+    UChar characters[] = { 0x644, 0x637, 0x641, 0x627, 0x64b };
+    size_t charactersLength = WTF_ARRAY_LENGTH(characters);
+    TextRun textRun(StringView(characters, charactersLength));
+    Ref&lt;ComplexTextController::ComplexTextRun&gt; run = ComplexTextController::ComplexTextRun::createForTesting(advances, origins, { 193, 377, 447, 431, 458 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 5), false);
+    Vector&lt;Ref&lt;ComplexTextController::ComplexTextRun&gt;&gt; runs;
+    runs.append(WTFMove(run));
+    ComplexTextController controller(font, textRun, runs);
+
+    CGFloat totalWidth = 0;
+    for (size_t i = 1; i &lt; advances.size(); ++i)
+        totalWidth += advances[i].width;
+    EXPECT_NEAR(controller.totalWidth(), totalWidth, 0.0001);
+    GlyphBuffer glyphBuffer;
+    controller.advance(0, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
+    controller.advance(1, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width, 0.0001);
+    controller.advance(5, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height, 0.0001);
+    EXPECT_EQ(glyphBuffer.size(), 5U);
+    EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width, 0.0001);
+}
+
+TEST_F(ComplexTextControllerTest, DISABLED_InitialAdvanceWithLeftRunInLTR)
+{
+    FontCascadeDescription description;
+    description.setOneFamily(&quot;LucidaGrande&quot;);
+    description.setComputedSize(80);
+    FontCascade font(description);
+    font.update(nullptr);
+    auto spaceWidth = font.primaryFont().spaceWidth();
+
+#if USE_LAYOUT_SPECIFIC_ADVANCES
+    Vector&lt;CGSize&gt; advances = { CGSizeMake(76.347656, 0.000000), CGSizeMake(0.000000, 0.000000) };
+    Vector&lt;CGPoint&gt; origins = { CGPointZero, CGPointMake(-23.281250, -8.398438) };
+#else
+    Vector&lt;CGSize&gt; advances = { CGSizeMake(53.066406, -8.398438), CGSizeMake(23.281250, 8.398438) };
+    Vector&lt;CGPoint&gt; origins = { };
+#endif
+
+    CGSize initialAdvance = CGSizeMake(28.144531, 0);
+
+    UChar characters[] = { 0x20, 0x61, 0x20e3 };
+    size_t charactersLength = WTF_ARRAY_LENGTH(characters);
+    TextRun textRun(StringView(characters, charactersLength));
+    Ref&lt;ComplexTextController::ComplexTextRun&gt; run1 = ComplexTextController::ComplexTextRun::createForTesting({ CGSizeMake(spaceWidth, 0) }, { CGPointZero }, { 5 }, { 0 }, CGSizeZero, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 1), true);
+    Ref&lt;ComplexTextController::ComplexTextRun&gt; run2 = ComplexTextController::ComplexTextRun::createForTesting(advances, origins, { 68, 1471 }, { 1, 2 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(1, 2), true);
+    Vector&lt;Ref&lt;ComplexTextController::ComplexTextRun&gt;&gt; runs;
+    runs.append(WTFMove(run1));
+    runs.append(WTFMove(run2));
+    ComplexTextController controller(font, textRun, runs);
+
+    EXPECT_NEAR(controller.totalWidth(), spaceWidth + 76.347656 + initialAdvance.width, 0.0001);
+    GlyphBuffer glyphBuffer;
+    controller.advance(0, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
+    controller.advance(1, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth, 0.0001);
+    controller.advance(2, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + advances[0].width + initialAdvance.width, 0.0001);
+    controller.advance(3, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + 76.347656 + initialAdvance.width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 0, 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 0, 0.0001);
+    EXPECT_EQ(glyphBuffer.size(), 3U);
+    EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), spaceWidth + initialAdvance.width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 53.066406, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), 23.281250, 0.0001);
+}
+
+TEST_F(ComplexTextControllerTest, DISABLED_InitialAdvanceInLTR)
+{
+    FontCascadeDescription description;
+    description.setOneFamily(&quot;LucidaGrande&quot;);
+    description.setComputedSize(80);
+    FontCascade font(description);
+    font.update(nullptr);
+
+#if USE_LAYOUT_SPECIFIC_ADVANCES
+    Vector&lt;CGSize&gt; advances = { CGSizeMake(76.347656, 0.000000), CGSizeMake(0.000000, 0.000000) };
+    Vector&lt;CGPoint&gt; origins = { CGPointZero, CGPointMake(-23.281250, -8.398438) };
+#else
+    Vector&lt;CGSize&gt; advances = { CGSizeMake(53.066406, -8.398438), CGSizeMake(23.281250, 8.398438) };
+    Vector&lt;CGPoint&gt; origins = { };
+#endif
+
+    CGSize initialAdvance = CGSizeMake(28.144531, 0);
+
+    UChar characters[] = { 0x61, 0x20e3 };
+    size_t charactersLength = WTF_ARRAY_LENGTH(characters);
+    TextRun textRun(StringView(characters, charactersLength));
+    Ref&lt;ComplexTextController::ComplexTextRun&gt; run = ComplexTextController::ComplexTextRun::createForTesting(advances, origins, { 68, 1471 }, { 0, 1 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 2), true);
+    Vector&lt;Ref&lt;ComplexTextController::ComplexTextRun&gt;&gt; runs;
+    runs.append(WTFMove(run));
+    ComplexTextController controller(font, textRun, runs);
+
+    EXPECT_NEAR(controller.totalWidth(), 76.347656 + initialAdvance.width, 0.0001);
+    GlyphBuffer glyphBuffer;
+    controller.advance(0, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
+    controller.advance(1, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), advances[0].width + initialAdvance.width, 0.0001);
+    controller.advance(2, &amp;glyphBuffer);
+    EXPECT_NEAR(controller.runWidthSoFar(), 76.347656 + initialAdvance.width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height, 0.0001);
+    EXPECT_EQ(glyphBuffer.size(), 2U);
+    EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 53.066406, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 23.281250, 0.0001);
+}
+
+}
</ins></span></pre>
</div>
</div>

</body>
</html>