<!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>[185175] 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/185175">185175</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2015-06-03 15:48:27 -0700 (Wed, 03 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>SoftBank Emoji are not transformed by shaping when in a run of their own
https://bugs.webkit.org/show_bug.cgi?id=145569
&lt;rdar://problem/20671711&gt;

Reviewed by Dean Jackson.

Normally, we don't perform shaping on single glyphs. However, these particular codepoints
need to have shaping run on them, even if they are alone.

Test: fast/text/softbank-emoji.html Note that this test may fail in different locales on
different platforms. This patch disables the test on iOS.

* Source/WebCore/platform/graphics/WidthIterator.cpp:
(WebCore::applyFontTransforms): Move the length-of-1 check into shouldApplyFontTransforms()
(WebCore::shouldApplyFontTransforms): Return true if we have one of these emoji characters in
a run of its own
(WebCore::advanceInternal): Keep track of the previous character, and use it to call
shouldApplyFontTransforms.
* Source/WebCore/platform/graphics/WidthIterator.h: shouldApplyFontTransforms() needs
some more information to perform its duties.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsplatformiossimulatorTestExpectations">trunk/LayoutTests/platform/ios-simulator/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsWidthIteratorcpp">trunk/Source/WebCore/platform/graphics/WidthIterator.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsWidthIteratorh">trunk/Source/WebCore/platform/graphics/WidthIterator.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttextsoftbankemojihtml">trunk/LayoutTests/fast/text/softbank-emoji.html</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorfasttextsoftbankemojiexpectedtxt">trunk/LayoutTests/platform/ios-simulator/fast/text/softbank-emoji-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacfasttextsoftbankemojiexpectedtxt">trunk/LayoutTests/platform/mac/fast/text/softbank-emoji-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsfasttextsoftbankemojihtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/softbank-emoji.html (0 => 185175)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/softbank-emoji.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/softbank-emoji.html        2015-06-03 22:48:27 UTC (rev 185175)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div style=&quot;font: 100px sans-serif, AppleColorEmoji;&quot;&gt;
+&lt;div&gt;&amp;#xE001; a &amp;#xE001;&lt;/div&gt;
+&lt;div&gt;&amp;#xE001;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (185174 => 185175)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/TestExpectations        2015-06-03 22:46:35 UTC (rev 185174)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations        2015-06-03 22:48:27 UTC (rev 185175)
</span><span class="lines">@@ -2616,3 +2616,7 @@
</span><span class="cx"> 
</span><span class="cx"> # Not implemented
</span><span class="cx"> webkit.org/b/145617 compositing/layer-creation/zoomed-clip-intersection.html [ Skip ]
</span><ins>+
+# This test depends on location, and it is impossible to mock the particular mechanism
+# this test uses to determine location.
+fast/text/softbank-emoji.html [ Failure Pass ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorfasttextsoftbankemojiexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-simulator/fast/text/softbank-emoji-expected.txt (0 => 185175)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/fast/text/softbank-emoji-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/fast/text/softbank-emoji-expected.txt        2015-06-03 22:48:27 UTC (rev 185175)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x250
+  RenderBlock {HTML} at (0,0) size 800x250
+    RenderBody {BODY} at (8,8) size 784x234
+      RenderBlock {DIV} at (0,0) size 784x234
+        RenderBlock {DIV} at (0,0) size 784x117
+          RenderText {#text} at (0,0) size 154x117
+            text run at (0,0) width 154: &quot;\x{E001} a \x{E001}&quot;
+        RenderBlock {DIV} at (0,117) size 784x117
+          RenderText {#text} at (0,0) size 21x117
+            text run at (0,0) width 21: &quot;\x{E001}&quot;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacfasttextsoftbankemojiexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/fast/text/softbank-emoji-expected.txt (0 => 185175)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/text/softbank-emoji-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/text/softbank-emoji-expected.txt        2015-06-03 22:48:27 UTC (rev 185175)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x246
+  RenderBlock {HTML} at (0,0) size 800x246
+    RenderBody {BODY} at (8,8) size 784x230
+      RenderBlock {DIV} at (0,0) size 784x230
+        RenderBlock {DIV} at (0,0) size 784x115
+          RenderText {#text} at (0,0) size 112x115
+            text run at (0,0) width 112: &quot;\x{E001} a \x{E001}&quot;
+        RenderBlock {DIV} at (0,115) size 784x115
+          RenderText {#text} at (0,0) size 0x115
+            text run at (0,0) width 0: &quot;\x{E001}&quot;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (185174 => 185175)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-06-03 22:46:35 UTC (rev 185174)
+++ trunk/Source/WebCore/ChangeLog        2015-06-03 22:48:27 UTC (rev 185175)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2015-06-02  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        SoftBank Emoji are not transformed by shaping when in a run of their own
+        https://bugs.webkit.org/show_bug.cgi?id=145569
+        &lt;rdar://problem/20671711&gt;
+
+        Reviewed by Dean Jackson.
+
+        Normally, we don't perform shaping on single glyphs. However, these particular codepoints
+        need to have shaping run on them, even if they are alone.
+
+        Test: fast/text/softbank-emoji.html Note that this test may fail in different locales on
+        different platforms. This patch disables the test on iOS.
+
+        * Source/WebCore/platform/graphics/WidthIterator.cpp:
+        (WebCore::applyFontTransforms): Move the length-of-1 check into shouldApplyFontTransforms()
+        (WebCore::shouldApplyFontTransforms): Return true if we have one of these emoji characters in
+        a run of its own
+        (WebCore::advanceInternal): Keep track of the previous character, and use it to call
+        shouldApplyFontTransforms. 
+        * Source/WebCore/platform/graphics/WidthIterator.h: shouldApplyFontTransforms() needs
+        some more information to perform its duties.
+
</ins><span class="cx"> 2015-06-03  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Caps lock indicator should not be shown in read-only or disabled field
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsWidthIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (185174 => 185175)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp        2015-06-03 22:46:35 UTC (rev 185174)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp        2015-06-03 22:48:27 UTC (rev 185175)
</span><span class="lines">@@ -97,7 +97,7 @@
</span><span class="cx"> 
</span><span class="cx"> typedef Vector&lt;std::pair&lt;int, OriginalAdvancesForCharacterTreatedAsSpace&gt;, 64&gt; CharactersTreatedAsSpace;
</span><span class="cx"> 
</span><del>-static inline float applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, int&amp; lastGlyphCount, const Font* font, WidthIterator&amp; iterator, TypesettingFeatures typesettingFeatures, CharactersTreatedAsSpace&amp; charactersTreatedAsSpace)
</del><ins>+static inline float applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, int&amp; lastGlyphCount, const Font* font, WidthIterator&amp; iterator, TypesettingFeatures typesettingFeatures, bool force, CharactersTreatedAsSpace&amp; charactersTreatedAsSpace)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(typesettingFeatures &amp; (Kerning | Ligatures));
</span><span class="cx"> 
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx">         return 0;
</span><span class="cx"> 
</span><span class="cx">     int glyphBufferSize = glyphBuffer-&gt;size();
</span><del>-    if (glyphBuffer-&gt;size() &lt;= lastGlyphCount + 1) {
</del><ins>+    if (!force &amp;&amp; glyphBufferSize &lt;= lastGlyphCount + 1) {
</ins><span class="cx">         lastGlyphCount = glyphBufferSize;
</span><span class="cx">         return 0;
</span><span class="cx">     }
</span><span class="lines">@@ -194,6 +194,20 @@
</span><span class="cx">     return std::make_pair(expandLeft, expandRight);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline bool isSoftBankEmoji(UChar32 codepoint)
+{
+    return codepoint &gt;= 0xE001 &amp;&amp; codepoint &lt;= 0xE537;
+}
+
+inline auto WidthIterator::shouldApplyFontTransforms(const GlyphBuffer* glyphBuffer, int lastGlyphCount, UChar32 previousCharacter) const -&gt; TransformsType
+{
+    if (glyphBuffer &amp;&amp; glyphBuffer-&gt;size() == lastGlyphCount + 1 &amp;&amp; isSoftBankEmoji(previousCharacter))
+        return TransformsType::Forced;
+    if (m_run.length() &lt;= 1 || !(m_typesettingFeatures &amp; (Kerning | Ligatures)))
+        return TransformsType::None;
+    return TransformsType::NotForced;
+}
+
</ins><span class="cx"> template &lt;typename TextIterator&gt;
</span><span class="cx"> inline unsigned WidthIterator::advanceInternal(TextIterator&amp; textIterator, GlyphBuffer* glyphBuffer)
</span><span class="cx"> {
</span><span class="lines">@@ -217,6 +231,7 @@
</span><span class="cx">     int lastGlyphCount = glyphBuffer ? glyphBuffer-&gt;size() : 0;
</span><span class="cx"> 
</span><span class="cx">     UChar32 character = 0;
</span><ins>+    UChar32 previousCharacter = 0;
</ins><span class="cx">     unsigned clusterLength = 0;
</span><span class="cx">     CharactersTreatedAsSpace charactersTreatedAsSpace;
</span><span class="cx">     String normalizedSpacesStringCache;
</span><span class="lines">@@ -252,8 +267,9 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (font != lastFontData &amp;&amp; width) {
</span><del>-            if (shouldApplyFontTransforms()) {
-                m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, *this, m_typesettingFeatures, charactersTreatedAsSpace);
</del><ins>+            auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
+            if (transformsType != TransformsType::None) {
+                m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, *this, m_typesettingFeatures, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
</ins><span class="cx">                 if (glyphBuffer)
</span><span class="cx">                     glyphBuffer-&gt;shrink(lastGlyphCount);
</span><span class="cx">             }
</span><span class="lines">@@ -343,7 +359,8 @@
</span><span class="cx">                 m_isAfterExpansion = false;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (shouldApplyFontTransforms() &amp;&amp; glyphBuffer &amp;&amp; FontCascade::treatAsSpace(character)) {
</del><ins>+        auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
+        if (transformsType != TransformsType::None &amp;&amp; glyphBuffer &amp;&amp; FontCascade::treatAsSpace(character)) {
</ins><span class="cx">             charactersTreatedAsSpace.append(std::make_pair(glyphBuffer-&gt;size(),
</span><span class="cx">                 OriginalAdvancesForCharacterTreatedAsSpace(character == ' ', glyphBuffer-&gt;size() ? glyphBuffer-&gt;advanceAt(glyphBuffer-&gt;size() - 1).width() : 0, width)));
</span><span class="cx">         }
</span><span class="lines">@@ -398,6 +415,7 @@
</span><span class="cx">             m_minGlyphBoundingBoxY = std::min(m_minGlyphBoundingBoxY, bounds.y());
</span><span class="cx">             m_lastGlyphOverflow = std::max&lt;float&gt;(0, bounds.maxX() - width);
</span><span class="cx">         }
</span><ins>+        previousCharacter = character;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (leftoverJustificationWidth) {
</span><span class="lines">@@ -407,8 +425,9 @@
</span><span class="cx">             glyphBuffer-&gt;add(lastFontData-&gt;spaceGlyph(), lastFontData, leftoverJustificationWidth, m_run.length());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (shouldApplyFontTransforms()) {
-        m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, *this, m_typesettingFeatures, charactersTreatedAsSpace);
</del><ins>+    auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
+    if (transformsType != TransformsType::None) {
+        m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, *this, m_typesettingFeatures, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
</ins><span class="cx">         if (glyphBuffer)
</span><span class="cx">             glyphBuffer-&gt;shrink(lastGlyphCount);
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsWidthIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.h (185174 => 185175)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/WidthIterator.h        2015-06-03 22:46:35 UTC (rev 185174)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.h        2015-06-03 22:48:27 UTC (rev 185175)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include &quot;SVGGlyph.h&quot;
</span><span class="cx"> #include &quot;TextRun.h&quot;
</span><span class="cx"> #include &lt;wtf/HashSet.h&gt;
</span><ins>+#include &lt;wtf/Optional.h&gt;
</ins><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -88,7 +89,8 @@
</span><span class="cx">     template &lt;typename TextIterator&gt;
</span><span class="cx">     inline unsigned advanceInternal(TextIterator&amp;, GlyphBuffer*);
</span><span class="cx"> 
</span><del>-    bool shouldApplyFontTransforms() const { return m_run.length() &gt; 1 &amp;&amp; (m_typesettingFeatures &amp; (Kerning | Ligatures)); }
</del><ins>+    enum class TransformsType { None, Forced, NotForced };
+    TransformsType shouldApplyFontTransforms(const GlyphBuffer*, int lastGlyphCount, UChar32 previousCharacter) const;
</ins><span class="cx"> 
</span><span class="cx">     TypesettingFeatures m_typesettingFeatures;
</span><span class="cx">     HashSet&lt;const Font*&gt;* m_fallbackFonts;
</span></span></pre>
</div>
</div>

</body>
</html>