<!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>[205826] trunk/Source</title>
</head>
<body>

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

<h3>Log Message</h3>
<pre>[Cocoa] Reduce uses of CGFonts in favor of CTFonts
https://bugs.webkit.org/show_bug.cgi?id=161809

Reviewed by Daniel Bates.

Source/WebCore:

Eventually, we want to remove the cgFont() member of PlatformFontData for both memory
savings and conceptual clarity. Because there is no performance loss from moving from
CGFontGetGlyphsForUnichars() to CTFontGetGlyphsForCharacters(), making this switch
gets us closer to reducing the uses of cgFont().

No new tests because there is no behavior change.

* platform/graphics/Font.cpp:
(WebCore::createAndFillGlyphPage):
* platform/graphics/GlyphPage.h:
(WebCore::GlyphData::GlyphData):
* platform/graphics/mac/GlyphPageMac.cpp:
(WebCore::shouldFillWithVerticalGlyphs):
(WebCore::GlyphPage::fill):
(WebCore::shouldUseCoreText): Deleted.

Source/WTF:

* wtf/unicode/CharacterNames.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfunicodeCharacterNamesh">trunk/Source/WTF/wtf/unicode/CharacterNames.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontcpp">trunk/Source/WebCore/platform/graphics/Font.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGlyphPageh">trunk/Source/WebCore/platform/graphics/GlyphPage.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacGlyphPageMaccpp">trunk/Source/WebCore/platform/graphics/mac/GlyphPageMac.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (205825 => 205826)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-09-12 21:42:31 UTC (rev 205825)
+++ trunk/Source/WTF/ChangeLog        2016-09-12 21:44:29 UTC (rev 205826)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2016-09-12  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Cocoa] Reduce uses of CGFonts in favor of CTFonts
+        https://bugs.webkit.org/show_bug.cgi?id=161809
+
+        Reviewed by Daniel Bates.
+
+        * wtf/unicode/CharacterNames.h:
+
</ins><span class="cx"> 2016-09-12  Saam Barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         MapHash should do constant folding when it has a constant argument and its legal to hash that value
</span></span></pre></div>
<a id="trunkSourceWTFwtfunicodeCharacterNamesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/unicode/CharacterNames.h (205825 => 205826)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/unicode/CharacterNames.h        2016-09-12 21:42:31 UTC (rev 205825)
+++ trunk/Source/WTF/wtf/unicode/CharacterNames.h        2016-09-12 21:44:29 UTC (rev 205826)
</span><span class="lines">@@ -37,8 +37,9 @@
</span><span class="cx"> // more convenient for WebCore code that mostly uses UTF-16.
</span><span class="cx"> 
</span><span class="cx"> const UChar AppleLogo = 0xF8FF;
</span><ins>+const UChar HiraganaLetterSmallA = 0x3041;
+const UChar32 aegeanWordSeparatorDot = 0x10101;
</ins><span class="cx"> const UChar32 aegeanWordSeparatorLine = 0x10100;
</span><del>-const UChar32 aegeanWordSeparatorDot = 0x10101;
</del><span class="cx"> const UChar apostrophe = 0x0027;
</span><span class="cx"> const UChar blackCircle = 0x25CF;
</span><span class="cx"> const UChar blackSquare = 0x25A0;
</span><span class="lines">@@ -50,10 +51,8 @@
</span><span class="cx"> const UChar ethiopicWordspace = 0x1361;
</span><span class="cx"> const UChar firstStrongIsolate = 0x2068;
</span><span class="cx"> const UChar fisheye = 0x25C9;
</span><del>-const UChar quotationMark = 0x0022;
</del><span class="cx"> const UChar hebrewPunctuationGeresh = 0x05F3;
</span><span class="cx"> const UChar hebrewPunctuationGershayim = 0x05F4;
</span><del>-const UChar HiraganaLetterSmallA = 0x3041;
</del><span class="cx"> const UChar horizontalEllipsis = 0x2026;
</span><span class="cx"> const UChar hyphen = 0x2010;
</span><span class="cx"> const UChar hyphenMinus = 0x002D;
</span><span class="lines">@@ -67,6 +66,7 @@
</span><span class="cx"> const UChar leftToRightMark = 0x200E;
</span><span class="cx"> const UChar leftToRightOverride = 0x202D;
</span><span class="cx"> const UChar minusSign = 0x2212;
</span><ins>+const UChar narrowNoBreakSpace = 0x202F;
</ins><span class="cx"> const UChar narrowNonBreakingSpace = 0x202F;
</span><span class="cx"> const UChar newlineCharacter = 0x000A;
</span><span class="cx"> const UChar noBreakSpace = 0x00A0;
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx"> const UChar objectReplacementCharacter = 0xFFFC;
</span><span class="cx"> const UChar popDirectionalFormatting = 0x202C;
</span><span class="cx"> const UChar popDirectionalIsolate = 0x2069;
</span><ins>+const UChar quotationMark = 0x0022;
</ins><span class="cx"> const UChar replacementCharacter = 0xFFFD;
</span><span class="cx"> const UChar rightDoubleQuotationMark = 0x201D;
</span><span class="cx"> const UChar rightSingleQuotationMark = 0x2019;
</span><span class="lines">@@ -84,8 +85,8 @@
</span><span class="cx"> const UChar smallLetterSharpS = 0x00DF;
</span><span class="cx"> const UChar softHyphen = 0x00AD;
</span><span class="cx"> const UChar space = 0x0020;
</span><ins>+const UChar tibetanMarkDelimiterTshegBstar = 0x0F0C;
</ins><span class="cx"> const UChar tibetanMarkIntersyllabicTsheg = 0x0F0B;
</span><del>-const UChar tibetanMarkDelimiterTshegBstar = 0x0F0C;
</del><span class="cx"> const UChar32 ugariticWordDivider = 0x1039F;
</span><span class="cx"> const UChar whiteBullet = 0x25E6;
</span><span class="cx"> const UChar whiteCircle = 0x25CB;
</span><span class="lines">@@ -93,16 +94,17 @@
</span><span class="cx"> const UChar whiteUpPointingTriangle = 0x25B3;
</span><span class="cx"> const UChar yenSign = 0x00A5;
</span><span class="cx"> const UChar zeroWidthJoiner = 0x200D;
</span><ins>+const UChar zeroWidthNoBreakSpace = 0xFEFF;
</ins><span class="cx"> const UChar zeroWidthNonJoiner = 0x200C;
</span><span class="cx"> const UChar zeroWidthSpace = 0x200B;
</span><del>-const UChar zeroWidthNoBreakSpace = 0xFEFF;
</del><span class="cx"> 
</span><span class="cx"> } // namespace Unicode
</span><span class="cx"> } // namespace WTF
</span><span class="cx"> 
</span><span class="cx"> using WTF::Unicode::AppleLogo;
</span><ins>+using WTF::Unicode::HiraganaLetterSmallA;
+using WTF::Unicode::aegeanWordSeparatorDot;
</ins><span class="cx"> using WTF::Unicode::aegeanWordSeparatorLine;
</span><del>-using WTF::Unicode::aegeanWordSeparatorDot;
</del><span class="cx"> using WTF::Unicode::blackCircle;
</span><span class="cx"> using WTF::Unicode::blackSquare;
</span><span class="cx"> using WTF::Unicode::blackUpPointingTriangle;
</span><span class="lines">@@ -115,7 +117,6 @@
</span><span class="cx"> using WTF::Unicode::fisheye;
</span><span class="cx"> using WTF::Unicode::hebrewPunctuationGeresh;
</span><span class="cx"> using WTF::Unicode::hebrewPunctuationGershayim;
</span><del>-using WTF::Unicode::HiraganaLetterSmallA;
</del><span class="cx"> using WTF::Unicode::horizontalEllipsis;
</span><span class="cx"> using WTF::Unicode::hyphen;
</span><span class="cx"> using WTF::Unicode::hyphenMinus;
</span><span class="lines">@@ -129,6 +130,7 @@
</span><span class="cx"> using WTF::Unicode::leftToRightMark;
</span><span class="cx"> using WTF::Unicode::leftToRightOverride;
</span><span class="cx"> using WTF::Unicode::minusSign;
</span><ins>+using WTF::Unicode::narrowNoBreakSpace;
</ins><span class="cx"> using WTF::Unicode::narrowNonBreakingSpace;
</span><span class="cx"> using WTF::Unicode::newlineCharacter;
</span><span class="cx"> using WTF::Unicode::noBreakSpace;
</span><span class="lines">@@ -145,8 +147,8 @@
</span><span class="cx"> using WTF::Unicode::sesameDot;
</span><span class="cx"> using WTF::Unicode::softHyphen;
</span><span class="cx"> using WTF::Unicode::space;
</span><ins>+using WTF::Unicode::tibetanMarkDelimiterTshegBstar;
</ins><span class="cx"> using WTF::Unicode::tibetanMarkIntersyllabicTsheg;
</span><del>-using WTF::Unicode::tibetanMarkDelimiterTshegBstar;
</del><span class="cx"> using WTF::Unicode::ugariticWordDivider;
</span><span class="cx"> using WTF::Unicode::whiteBullet;
</span><span class="cx"> using WTF::Unicode::whiteCircle;
</span><span class="lines">@@ -154,8 +156,8 @@
</span><span class="cx"> using WTF::Unicode::whiteUpPointingTriangle;
</span><span class="cx"> using WTF::Unicode::yenSign;
</span><span class="cx"> using WTF::Unicode::zeroWidthJoiner;
</span><ins>+using WTF::Unicode::zeroWidthNoBreakSpace;
</ins><span class="cx"> using WTF::Unicode::zeroWidthNonJoiner;
</span><span class="cx"> using WTF::Unicode::zeroWidthSpace;
</span><del>-using WTF::Unicode::zeroWidthNoBreakSpace;
</del><span class="cx"> 
</span><span class="cx"> #endif // CharacterNames_h
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205825 => 205826)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-12 21:42:31 UTC (rev 205825)
+++ trunk/Source/WebCore/ChangeLog        2016-09-12 21:44:29 UTC (rev 205826)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2016-09-12  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Cocoa] Reduce uses of CGFonts in favor of CTFonts
+        https://bugs.webkit.org/show_bug.cgi?id=161809
+
+        Reviewed by Daniel Bates.
+
+        Eventually, we want to remove the cgFont() member of PlatformFontData for both memory
+        savings and conceptual clarity. Because there is no performance loss from moving from
+        CGFontGetGlyphsForUnichars() to CTFontGetGlyphsForCharacters(), making this switch
+        gets us closer to reducing the uses of cgFont().
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/Font.cpp:
+        (WebCore::createAndFillGlyphPage):
+        * platform/graphics/GlyphPage.h:
+        (WebCore::GlyphData::GlyphData):
+        * platform/graphics/mac/GlyphPageMac.cpp:
+        (WebCore::shouldFillWithVerticalGlyphs):
+        (WebCore::GlyphPage::fill):
+        (WebCore::shouldUseCoreText): Deleted.
+
</ins><span class="cx"> 2016-09-12  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove trailing control characters and spaces before parsing a URL
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (205825 => 205826)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Font.cpp        2016-09-12 21:42:31 UTC (rev 205825)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp        2016-09-12 21:44:29 UTC (rev 205826)
</span><span class="lines">@@ -187,6 +187,7 @@
</span><span class="cx">         overwriteCodePoint('\n', space);
</span><span class="cx">         overwriteCodePoint('\t', space);
</span><span class="cx">         overwriteCodePoint(noBreakSpace, space);
</span><ins>+        overwriteCodePoint(narrowNoBreakSpace, zeroWidthSpace);
</ins><span class="cx">         overwriteCodePoint(leftToRightMark, zeroWidthSpace);
</span><span class="cx">         overwriteCodePoint(rightToLeftMark, zeroWidthSpace);
</span><span class="cx">         overwriteCodePoint(leftToRightEmbed, zeroWidthSpace);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGlyphPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GlyphPage.h (205825 => 205826)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GlyphPage.h        2016-09-12 21:42:31 UTC (rev 205825)
+++ trunk/Source/WebCore/platform/graphics/GlyphPage.h        2016-09-12 21:44:29 UTC (rev 205826)
</span><span class="lines">@@ -31,7 +31,6 @@
</span><span class="cx"> #define GlyphPage_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Glyph.h&quot;
</span><del>-#include &lt;string.h&gt;
</del><span class="cx"> #include &lt;unicode/utypes.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/Ref.h&gt;
</span><span class="lines">@@ -43,9 +42,9 @@
</span><span class="cx"> // Holds the glyph index and the corresponding Font information for a given
</span><span class="cx"> // character.
</span><span class="cx"> struct GlyphData {
</span><del>-    GlyphData(Glyph g = 0, const Font* f = 0)
-        : glyph(g)
-        , font(f)
</del><ins>+    GlyphData(Glyph glyph = 0, const Font* font = nullptr)
+        : glyph(glyph)
+        , font(font)
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacGlyphPageMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/GlyphPageMac.cpp (205825 => 205826)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/GlyphPageMac.cpp        2016-09-12 21:42:31 UTC (rev 205825)
+++ trunk/Source/WebCore/platform/graphics/mac/GlyphPageMac.cpp        2016-09-12 21:44:29 UTC (rev 205826)
</span><span class="lines">@@ -40,21 +40,14 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-static bool shouldUseCoreText(const UChar* buffer, unsigned bufferLength, const Font&amp; fontData)
</del><ins>+static bool shouldFillWithVerticalGlyphs(const UChar* buffer, unsigned bufferLength, const Font&amp; font)
</ins><span class="cx"> {
</span><del>-    // This needs to be kept in sync with GlyphPage::fill(). Currently, the CoreText paths are not able to handle
-    // every situtation. Returning true from this function in a new situation will require you to explicitly add
-    // handling for that situation in the CoreText paths of GlyphPage::fill().
-    if (fontData.platformData().isSystemFont())
-        return true;
-    if (fontData.platformData().isForTextCombine() || fontData.hasVerticalGlyphs()) {
-        // Ideographs don't have a vertical variant or width variants.
-        for (unsigned i = 0; i &lt; bufferLength; ++i) {
-            if (!FontCascade::isCJKIdeograph(buffer[i]))
-                return true;
-        }
</del><ins>+    if (!font.hasVerticalGlyphs())
+        return false;
+    for (unsigned i = 0; i &lt; bufferLength; ++i) {
+        if (!FontCascade::isCJKIdeograph(buffer[i]))
+            return true;
</ins><span class="cx">     }
</span><del>-
</del><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -64,26 +57,12 @@
</span><span class="cx"> 
</span><span class="cx">     const Font&amp; font = this-&gt;font();
</span><span class="cx">     Vector&lt;CGGlyph, 512&gt; glyphs(bufferLength);
</span><del>-    unsigned glyphStep;
-    if (!shouldUseCoreText(buffer, bufferLength, font)) {
-        // We pass in either 256 or 512 UTF-16 characters: 256 for U+FFFF and less, 512 (double character surrogates)
-        // for U+10000 and above. It is indeed possible to get back 512 glyphs back from the API, so the glyph buffer
-        // we pass in must be 512. If we get back more than 256 glyphs though we'll ignore all the ones after 256,
-        // this should not happen as the only time we pass in 512 characters is when they are surrogates.
-        CGFontGetGlyphsForUnichars(font.platformData().cgFont(), buffer, glyphs.data(), bufferLength);
-        glyphStep = 1;
-    } else {
-        // Because we know the implementation of shouldUseCoreText(), if the font isn't for text combine and it isn't a system font,
-        // we know it must have vertical glyphs.
-        if (font.platformData().isForTextCombine() || font.platformData().isSystemFont())
-            CTFontGetGlyphsForCharacters(font.platformData().ctFont(), buffer, glyphs.data(), bufferLength);
-        else
-            CTFontGetVerticalGlyphsForCharacters(font.platformData().ctFont(), buffer, glyphs.data(), bufferLength);
</del><ins>+    unsigned glyphStep = bufferLength / GlyphPage::size;
</ins><span class="cx"> 
</span><del>-        // When buffer consists of surrogate pairs, CTFontGetVerticalGlyphsForCharacters and CTFontGetGlyphsForCharacters
-        // place the glyphs at indices corresponding to the first character of each pair.
-        glyphStep = bufferLength / GlyphPage::size;
-    }
</del><ins>+    if (shouldFillWithVerticalGlyphs(buffer, bufferLength, font))
+        CTFontGetVerticalGlyphsForCharacters(font.platformData().ctFont(), buffer, glyphs.data(), bufferLength);
+    else
+        CTFontGetGlyphsForCharacters(font.platformData().ctFont(), buffer, glyphs.data(), bufferLength);
</ins><span class="cx"> 
</span><span class="cx">     bool haveGlyphs = false;
</span><span class="cx">     for (unsigned i = 0; i &lt; GlyphPage::size; ++i) {
</span></span></pre>
</div>
</div>

</body>
</html>