<!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>[208675] 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/208675">208675</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-11-13 23:12:50 -0800 (Sun, 13 Nov 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[HarfBuzz] HarfBuzzShaper should not assume numGlyphs is greater than 0
https://bugs.webkit.org/show_bug.cgi?id=164500

Patch by Fujii Hironori &lt;Hironori.Fujii@sony.com&gt; on 2016-11-13
Reviewed by Myles C. Maxfield.

Source/WebCore:

Test: fast/text/international/harfbuzz-runs-with-no-glyph.html

HarfBuzzShaper assumes numGlyphs of HarfBuzzRun is greater than
zero. But this is not necessarily true. If a font does not have a
glyph of SPACE (U+0020), HarfBuzz removes ignorable glyphs. In
this case, HarfBuzzRun can have no glyphs.

* platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
(WebCore::HarfBuzzShaper::HarfBuzzRun::applyShapeResult): Resize
m_offsets to one if m_numGlyphs is zero.
* platform/graphics/harfbuzz/HarfBuzzShaper.h:
(WebCore::HarfBuzzShaper::HarfBuzzRun::glyphs): Use Vector::data()
instread of operator[0].
(WebCore::HarfBuzzShaper::HarfBuzzRun::advances): Ditto.
(WebCore::HarfBuzzShaper::HarfBuzzRun::offsets): Ditto.
(WebCore::HarfBuzzShaper::HarfBuzzRun::glyphToCharacterIndexes): Ditto.

LayoutTests:

* fast/text/international/harfbuzz-runs-with-no-glyph-expected.txt: Added.
* fast/text/international/harfbuzz-runs-with-no-glyph.html: Added.
* fast/text/international/resources/ignorables.woff: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsharfbuzzHarfBuzzShapercpp">trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsharfbuzzHarfBuzzShaperh">trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttextinternationalharfbuzzrunswithnoglyphexpectedtxt">trunk/LayoutTests/fast/text/international/harfbuzz-runs-with-no-glyph-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasttextinternationalharfbuzzrunswithnoglyphhtml">trunk/LayoutTests/fast/text/international/harfbuzz-runs-with-no-glyph.html</a></li>
<li><a href="#trunkLayoutTestsfasttextinternationalresourcesignorableswoff">trunk/LayoutTests/fast/text/international/resources/ignorables.woff</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208674 => 208675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-14 07:06:52 UTC (rev 208674)
+++ trunk/LayoutTests/ChangeLog        2016-11-14 07:12:50 UTC (rev 208675)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-11-13  Fujii Hironori  &lt;Hironori.Fujii@sony.com&gt;
+
+        [HarfBuzz] HarfBuzzShaper should not assume numGlyphs is greater than 0
+        https://bugs.webkit.org/show_bug.cgi?id=164500
+
+        Reviewed by Myles C. Maxfield.
+
+        * fast/text/international/harfbuzz-runs-with-no-glyph-expected.txt: Added.
+        * fast/text/international/harfbuzz-runs-with-no-glyph.html: Added.
+        * fast/text/international/resources/ignorables.woff: Added.
+
</ins><span class="cx"> 2016-11-13  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (204441): newsplex.com map does not load
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextinternationalharfbuzzrunswithnoglyphexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/international/harfbuzz-runs-with-no-glyph-expected.txt (0 => 208675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/harfbuzz-runs-with-no-glyph-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/text/international/harfbuzz-runs-with-no-glyph-expected.txt        2016-11-14 07:12:50 UTC (rev 208675)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+‏ا‎
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttextinternationalharfbuzzrunswithnoglyphhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/international/harfbuzz-runs-with-no-glyph.html (0 => 208675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/harfbuzz-runs-with-no-glyph.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/international/harfbuzz-runs-with-no-glyph.html        2016-11-14 07:12:50 UTC (rev 208675)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;style&gt;
+@font-face {
+    font-family: test-font;
+    src: url(resources/ignorables.woff);
+}
+body {
+    font-family: test-font;
+}
+&lt;/style&gt;
+&lt;body&gt;
+&lt;p&gt;&amp;#x200f;&amp;#x0627;&amp;#x200e;&lt;/p&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    // Force layout.
+    testRunner.display();
+    testRunner.dumpAsText();
+}
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttextinternationalresourcesignorableswoff"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/international/resources/ignorables.woff (0 => 208675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/resources/ignorables.woff                                (rev 0)
+++ trunk/LayoutTests/fast/text/international/resources/ignorables.woff        2016-11-14 07:12:50 UTC (rev 208675)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+wOFFOTTOd `CFF \xE8\xFB\xA3]\xECCFFTM\xF0{e\xF2\xE7GDEF OS/2$E`u\x85\xFD\x93cmapl7B+&quot;\xB5head\xA4(6        \xAAIhhea\xCC$|&amp;hmtx\xE8tmaxpPnameH.\xFC\x97%postP \xFF\x862x\x9Ccd`aa`ddd+I-.a`db`d\xD0\xF8\xC1\xCF\xF0C\x81\xF1\x87&quot;\xD3%\xE6,\xDD@\xC0*ð\x99_\x86\x81A@\x86a\x9F\xA0 \xA7 \xC3'!\x90j~1Y\x86(\x868\x86\xA4ҼL#'\xE5 \xA1\ \x94+\x84rs\xCE/\xA8,\xCAL\xCF(Q\xD0p\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ȱ\x85\x85\xA0\xC7j\x9Fq\x85\x98+vv        \x8C\x9A\xFD        RR\x8E3\xC1\xEC\xB7ny\x923\xDB33\xB5\x9E\xBB\x93&quot;\xA6\xC5\xE1\\xE6\xD9\xD6Joڗ\xA1\x8AG\xB2*\xCCY\xC6\xEA2Im~\xD22sl\x93\xDC쵱&lt;IyoM\xA9\x8ARX\xEB\x8A\xFB\x92i\x86#\xFFC\xC2yX\xEA\xEC\xB8K\xF3\xFA\x95\xB6\x8E%;t\xED!\xA2 \xC1\x84\xEB*s\xC9\xC6\xD0]\xCC\xFD\xEA\xF3\xC2\xD8yQfZ\x86\x91\x92\x
 89\xB8q \xE3A\xDCk\xFF\xBDdS;\xAE\xE8\xD7M\xEA8\xA5\xA8\x8En*6\xBA\xAC\xF2ˆRq\xA4\x94\x92\xBF
+?\xDE^W\x85x\x9Cc`f\x83\xFF\xCD F X(D\xB8
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208674 => 208675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-14 07:06:52 UTC (rev 208674)
+++ trunk/Source/WebCore/ChangeLog        2016-11-14 07:12:50 UTC (rev 208675)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-11-13  Fujii Hironori  &lt;Hironori.Fujii@sony.com&gt;
+
+        [HarfBuzz] HarfBuzzShaper should not assume numGlyphs is greater than 0
+        https://bugs.webkit.org/show_bug.cgi?id=164500
+
+        Reviewed by Myles C. Maxfield.
+
+        Test: fast/text/international/harfbuzz-runs-with-no-glyph.html
+
+        HarfBuzzShaper assumes numGlyphs of HarfBuzzRun is greater than
+        zero. But this is not necessarily true. If a font does not have a
+        glyph of SPACE (U+0020), HarfBuzz removes ignorable glyphs. In
+        this case, HarfBuzzRun can have no glyphs.
+
+        * platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
+        (WebCore::HarfBuzzShaper::HarfBuzzRun::applyShapeResult): Resize
+        m_offsets to one if m_numGlyphs is zero.
+        * platform/graphics/harfbuzz/HarfBuzzShaper.h:
+        (WebCore::HarfBuzzShaper::HarfBuzzRun::glyphs): Use Vector::data()
+        instread of operator[0].
+        (WebCore::HarfBuzzShaper::HarfBuzzRun::advances): Ditto.
+        (WebCore::HarfBuzzShaper::HarfBuzzRun::offsets): Ditto.
+        (WebCore::HarfBuzzShaper::HarfBuzzRun::glyphToCharacterIndexes): Ditto.
+
</ins><span class="cx"> 2016-11-13  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (204441): newsplex.com map does not load
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsharfbuzzHarfBuzzShapercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp (208674 => 208675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp        2016-11-14 07:06:52 UTC (rev 208674)
+++ trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp        2016-11-14 07:12:50 UTC (rev 208675)
</span><span class="lines">@@ -83,6 +83,11 @@
</span><span class="cx"> void HarfBuzzShaper::HarfBuzzRun::applyShapeResult(hb_buffer_t* harfBuzzBuffer)
</span><span class="cx"> {
</span><span class="cx">     m_numGlyphs = hb_buffer_get_length(harfBuzzBuffer);
</span><ins>+    if (!m_numGlyphs) {
+        // HarfBuzzShaper::fillGlyphBuffer gets offsets()[0]
+        m_offsets.resize(1);
+        return;
+    }
</ins><span class="cx">     m_glyphs.resize(m_numGlyphs);
</span><span class="cx">     m_advances.resize(m_numGlyphs);
</span><span class="cx">     m_glyphToCharacterIndexes.resize(m_numGlyphs);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsharfbuzzHarfBuzzShaperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.h (208674 => 208675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.h        2016-11-14 07:06:52 UTC (rev 208674)
+++ trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.h        2016-11-14 07:12:50 UTC (rev 208675)
</span><span class="lines">@@ -77,10 +77,10 @@
</span><span class="cx">         unsigned startIndex() const { return m_startIndex; }
</span><span class="cx">         unsigned numCharacters() const { return m_numCharacters; }
</span><span class="cx">         unsigned numGlyphs() const { return m_numGlyphs; }
</span><del>-        uint16_t* glyphs() { return &amp;m_glyphs[0]; }
-        float* advances() { return &amp;m_advances[0]; }
-        FloatPoint* offsets() { return &amp;m_offsets[0]; }
-        uint16_t* glyphToCharacterIndexes() { return &amp;m_glyphToCharacterIndexes[0]; }
</del><ins>+        uint16_t* glyphs() { return m_glyphs.data(); }
+        float* advances() { return m_advances.data(); }
+        FloatPoint* offsets() { return m_offsets.data(); }
+        uint16_t* glyphToCharacterIndexes() { return m_glyphToCharacterIndexes.data(); }
</ins><span class="cx">         float width() { return m_width; }
</span><span class="cx">         bool rtl() { return m_direction == RTL; }
</span><span class="cx">         hb_script_t script() { return m_script; }
</span></span></pre>
</div>
</div>

</body>
</html>