<!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>[178133] 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/178133">178133</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2015-01-08 14:30:06 -0800 (Thu, 08 Jan 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Remove the concept of "retained" font
https://bugs.webkit.org/show_bug.cgi?id=140246
Reviewed by Darin Adler.
FontCache currently maintains a secondary refcount for SimpleFontDatas. This is used to decide whether
a font is considered inactive and is eligible for purging. This is confusing and complex.
The new scheme in this patch considers fonts in font cache inactive if their refcount is 1 (they are
owned by the cache only). This simplifies the code and gives similar behavior. Types that "retained" the
font this way always also ref it.
We also avoid unnecessarily removing fonts that wouldn't get deleted from the cache.
Also modernized some names and code.
* WebCore.exp.in:
* css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::getFontData):
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::getFontData):
(WebCore::CSSFontSelector::getFallbackFontData):
* platform/graphics/FontCache.cpp:
(WebCore::fontPlatformDataCache):
(WebCore::FontCache::getCachedFontPlatformData):
(WebCore::cachedFonts):
(WebCore::FontCache::fontForFamily):
(WebCore::FontCache::fontDataForPlatformData):
(WebCore::FontCache::purgeInactiveFontDataIfNeeded):
(WebCore::FontCache::purgeInactiveFontData):
(WebCore::FontCache::fontDataCount):
(WebCore::FontCache::inactiveFontDataCount):
(WebCore::FontCache::fontForFamilyAtIndex):
(WebCore::FontCache::invalidate):
(WebCore::FontCache::getCachedFontData): Deleted.
(WebCore::FontCache::getNonRetainedLastResortFallbackFont): Deleted.
(WebCore::FontCache::releaseFontData): Deleted.
(WebCore::FontCache::getFontData): Deleted.
* platform/graphics/FontCache.h:
* platform/graphics/FontGlyphs.cpp:
(WebCore::FontGlyphs::FontGlyphs):
(WebCore::FontGlyphs::~FontGlyphs):
(WebCore::FontGlyphs::realizeFontDataAt):
(WebCore::FontGlyphs::releaseFontData): Deleted.
* platform/graphics/FontGlyphs.h:
(WebCore::FontGlyphs::~FontGlyphs): Deleted.
* platform/graphics/SimpleFontData.cpp:
(WebCore::SimpleFontData::~SimpleFontData):
* platform/graphics/SimpleFontData.h:
* platform/graphics/freetype/SimpleFontDataFreeType.cpp:
(WebCore::SimpleFontData::platformDestroy): Deleted.
* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::FontCache::systemFallbackForCharacters):
(WebCore::FontCache::similarFontPlatformData):
(WebCore::FontCache::lastResortFallbackFont):
(WebCore::FontCache::getLastResortFallbackFont): Deleted.
* platform/graphics/mac/SimpleFontDataMac.mm:
(WebCore::SimpleFontData::platformCreateScaledFontData):
(WebCore::SimpleFontData::platformDestroy): Deleted.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCorecssCSSFontFaceSourcecpp">trunk/Source/WebCore/css/CSSFontFaceSource.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSFontSelectorcpp">trunk/Source/WebCore/css/CSSFontSelector.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCachecpp">trunk/Source/WebCore/platform/graphics/FontCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCacheh">trunk/Source/WebCore/platform/graphics/FontCache.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontGlyphscpp">trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontGlyphsh">trunk/Source/WebCore/platform/graphics/FontGlyphs.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsSimpleFontDatacpp">trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsSimpleFontDatah">trunk/Source/WebCore/platform/graphics/SimpleFontData.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfreetypeFontCacheFreeTypecpp">trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfreetypeSimpleFontDataFreeTypecpp">trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsiosFontCacheIOSmm">trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsiosSimpleFontDataIOSmm">trunk/Source/WebCore/platform/graphics/ios/SimpleFontDataIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacComplexTextControllerCoreTextmm">trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacFontCacheMacmm">trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacSimpleFontDataMacmm">trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontCacheWincpp">trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp</a></li>
<li><a href="#trunkSourceWebKitiosMiscEmojiFallbackFontSelectorcpp">trunk/Source/WebKit/ios/Misc/EmojiFallbackFontSelector.cpp</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebHTMLViewmm">trunk/Source/WebKit/mac/WebView/WebHTMLView.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/ChangeLog        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -1,3 +1,67 @@
</span><ins>+2015-01-08 Antti Koivisto <antti@apple.com>
+
+ Remove the concept of "retained" font
+ https://bugs.webkit.org/show_bug.cgi?id=140246
+
+ Reviewed by Darin Adler.
+
+ FontCache currently maintains a secondary refcount for SimpleFontDatas. This is used to decide whether
+ a font is considered inactive and is eligible for purging. This is confusing and complex.
+
+ The new scheme in this patch considers fonts in font cache inactive if their refcount is 1 (they are
+ owned by the cache only). This simplifies the code and gives similar behavior. Types that "retained" the
+ font this way always also ref it.
+
+ We also avoid unnecessarily removing fonts that wouldn't get deleted from the cache.
+
+ Also modernized some names and code.
+
+ * WebCore.exp.in:
+ * css/CSSFontFaceSource.cpp:
+ (WebCore::CSSFontFaceSource::getFontData):
+ * css/CSSFontSelector.cpp:
+ (WebCore::CSSFontSelector::getFontData):
+ (WebCore::CSSFontSelector::getFallbackFontData):
+ * platform/graphics/FontCache.cpp:
+ (WebCore::fontPlatformDataCache):
+ (WebCore::FontCache::getCachedFontPlatformData):
+ (WebCore::cachedFonts):
+ (WebCore::FontCache::fontForFamily):
+ (WebCore::FontCache::fontDataForPlatformData):
+ (WebCore::FontCache::purgeInactiveFontDataIfNeeded):
+ (WebCore::FontCache::purgeInactiveFontData):
+ (WebCore::FontCache::fontDataCount):
+ (WebCore::FontCache::inactiveFontDataCount):
+ (WebCore::FontCache::fontForFamilyAtIndex):
+ (WebCore::FontCache::invalidate):
+ (WebCore::FontCache::getCachedFontData): Deleted.
+ (WebCore::FontCache::getNonRetainedLastResortFallbackFont): Deleted.
+ (WebCore::FontCache::releaseFontData): Deleted.
+ (WebCore::FontCache::getFontData): Deleted.
+ * platform/graphics/FontCache.h:
+ * platform/graphics/FontGlyphs.cpp:
+ (WebCore::FontGlyphs::FontGlyphs):
+ (WebCore::FontGlyphs::~FontGlyphs):
+ (WebCore::FontGlyphs::realizeFontDataAt):
+ (WebCore::FontGlyphs::releaseFontData): Deleted.
+ * platform/graphics/FontGlyphs.h:
+ (WebCore::FontGlyphs::~FontGlyphs): Deleted.
+ * platform/graphics/SimpleFontData.cpp:
+ (WebCore::SimpleFontData::~SimpleFontData):
+ * platform/graphics/SimpleFontData.h:
+ * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
+ (WebCore::SimpleFontData::platformDestroy): Deleted.
+ * platform/graphics/mac/ComplexTextControllerCoreText.mm:
+ (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
+ * platform/graphics/mac/FontCacheMac.mm:
+ (WebCore::FontCache::systemFallbackForCharacters):
+ (WebCore::FontCache::similarFontPlatformData):
+ (WebCore::FontCache::lastResortFallbackFont):
+ (WebCore::FontCache::getLastResortFallbackFont): Deleted.
+ * platform/graphics/mac/SimpleFontDataMac.mm:
+ (WebCore::SimpleFontData::platformCreateScaledFontData):
+ (WebCore::SimpleFontData::platformDestroy): Deleted.
+
</ins><span class="cx"> 2015-01-08 Anders Carlsson <andersca@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove AbstractSQLTransaction
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/WebCore.exp.in        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -75,8 +75,8 @@
</span><span class="cx"> __ZN7WebCore10CredentialC1EP15NSURLCredential
</span><span class="cx"> __ZN7WebCore10FloatPointC1ERK7CGPoint
</span><span class="cx"> __ZN7WebCore10FloatPointC1ERKNS_8IntPointE
</span><del>-__ZN7WebCore10FontGlyphs15releaseFontDataEv
</del><span class="cx"> __ZN7WebCore10FontGlyphs17realizeFontDataAtERKNS_15FontDescriptionEj
</span><ins>+__ZN7WebCore10FontGlyphsD1Ev
</ins><span class="cx"> __ZN7WebCore10JSDocument6s_infoE
</span><span class="cx"> __ZN7WebCore10JSDocument9toWrappedEN3JSC7JSValueE
</span><span class="cx"> __ZN7WebCore10LayoutRect5scaleEf
</span><span class="lines">@@ -1444,7 +1444,7 @@
</span><span class="cx"> __ZN7WebCore9FloatSizeC1ERKNS_7IntSizeE
</span><span class="cx"> __ZN7WebCore9FontCache10invalidateEv
</span><span class="cx"> __ZN7WebCore9FontCache13fontDataCountEv
</span><del>-__ZN7WebCore9FontCache17getCachedFontDataERKNS_15FontDescriptionERKN3WTF12AtomicStringEbNS0_12ShouldRetainE
</del><ins>+__ZN7WebCore9FontCache13fontForFamilyERKNS_15FontDescriptionERKN3WTF12AtomicStringEb
</ins><span class="cx"> __ZN7WebCore9FontCache21inactiveFontDataCountEv
</span><span class="cx"> __ZN7WebCore9FontCache21purgeInactiveFontDataEi
</span><span class="cx"> __ZN7WebCore9FontCache29purgeInactiveFontDataIfNeededEv
</span><span class="lines">@@ -2795,7 +2795,6 @@
</span><span class="cx"> __ZN7WebCore8Settings31setAudioSessionCategoryOverrideEj
</span><span class="cx"> __ZN7WebCore8Settings34setNetworkDataUsageTrackingEnabledEb
</span><span class="cx"> __ZN7WebCore8Settings38gShouldOptOutOfNetworkStateObservationE
</span><del>-__ZN7WebCore9FontCache25getLastResortFallbackFontERKNS_15FontDescriptionENS0_12ShouldRetainE
</del><span class="cx"> __ZN7WebCore9FrameView17setScrollVelocityEdddd
</span><span class="cx"> __ZN7WebCore9FrameView20setWasScrolledByUserEb
</span><span class="cx"> __ZN7WebCore9FrameView24renderedCharactersExceedEj
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontFaceSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontFaceSource.cpp (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontFaceSource.cpp        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/css/CSSFontFaceSource.cpp        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -109,7 +109,7 @@
</span><span class="cx"> ) {
</span><span class="cx"> // We're local. Just return a SimpleFontData from the normal cache.
</span><span class="cx"> // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
</span><del>- return fontCache().getCachedFontData(fontDescription, m_string, true);
</del><ins>+ return fontCache().fontForFamily(fontDescription, m_string, true);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // See if we have a mapping in our FontData cache.
</span><span class="lines">@@ -144,10 +144,9 @@
</span><span class="cx"> // and the loader may invoke arbitrary delegate or event handler code.
</span><span class="cx"> fontSelector->beginLoadingFontSoon(m_font.get());
</span><span class="cx">
</span><del>- // This temporary font is not retained and should not be returned.
- FontCachePurgePreventer fontCachePurgePreventer;
- SimpleFontData* temporaryFont = fontCache().getNonRetainedLastResortFallbackFont(fontDescription);
- fontData = SimpleFontData::create(temporaryFont->platformData(), true, true);
</del><ins>+ Ref<SimpleFontData> placeholderFont = fontCache().lastResortFallbackFont(fontDescription);
+ Ref<SimpleFontData> placeholderFontCopyInLoadingState = SimpleFontData::create(placeholderFont->platformData(), true, true);
+ return WTF::move(placeholderFontCopyInLoadingState);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return fontData.release();
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontSelectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontSelector.cpp        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -478,7 +478,7 @@
</span><span class="cx"> if (!face) {
</span><span class="cx"> if (!resolveGenericFamilyFirst)
</span><span class="cx"> familyForLookup = resolveGenericFamily(m_document, fontDescription, familyName);
</span><del>- return fontCache().getCachedFontData(fontDescription, familyForLookup);
</del><ins>+ return fontCache().fontForFamily(fontDescription, familyForLookup);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return face->getFontData(fontDescription);
</span><span class="lines">@@ -634,7 +634,7 @@
</span><span class="cx"> if (!settings || !settings->fontFallbackPrefersPictographs())
</span><span class="cx"> return 0;
</span><span class="cx">
</span><del>- return fontCache().getCachedFontData(fontDescription, settings->pictographFontFamily());
</del><ins>+ return fontCache().fontForFamily(fontDescription, settings->pictographFontFamily());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCache.cpp        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> #include <wtf/ListHashSet.h>
</span><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="cx"> #include <wtf/StdLibExtras.h>
</span><ins>+#include <wtf/TemporaryChange.h>
</ins><span class="cx"> #include <wtf/text/AtomicStringHash.h>
</span><span class="cx"> #include <wtf/text/StringHash.h>
</span><span class="cx">
</span><span class="lines">@@ -88,7 +89,7 @@
</span><span class="cx"> FontCache& fontCache()
</span><span class="cx"> {
</span><span class="cx"> static NeverDestroyed<FontCache> globalFontCache;
</span><del>- return globalFontCache.get();
</del><ins>+ return globalFontCache;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> FontCache::FontCache()
</span><span class="lines">@@ -143,7 +144,11 @@
</span><span class="cx">
</span><span class="cx"> typedef HashMap<FontPlatformDataCacheKey, std::unique_ptr<FontPlatformData>, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyTraits> FontPlatformDataCache;
</span><span class="cx">
</span><del>-static FontPlatformDataCache* gFontPlatformDataCache = 0;
</del><ins>+static FontPlatformDataCache& fontPlatformDataCache()
+{
+ static NeverDestroyed<FontPlatformDataCache> cache;
+ return cache;
+}
</ins><span class="cx">
</span><span class="cx"> static bool familyNameEqualIgnoringCase(const AtomicString& familyName, const char* reference, unsigned length)
</span><span class="cx"> {
</span><span class="lines">@@ -234,16 +239,17 @@
</span><span class="cx"> const AtomicString& familyName = passedFamilyName;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- if (!gFontPlatformDataCache) {
- gFontPlatformDataCache = new FontPlatformDataCache;
</del><ins>+ static bool initialized;
+ if (!initialized) {
</ins><span class="cx"> platformInit();
</span><ins>+ initialized = true;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> FontPlatformDataCacheKey key(familyName, fontDescription);
</span><span class="cx">
</span><del>- FontPlatformDataCache::AddResult result = gFontPlatformDataCache->add(key, nullptr);
- FontPlatformDataCache::iterator it = result.iterator;
- if (result.isNewEntry) {
</del><ins>+ auto addResult = fontPlatformDataCache().add(key, nullptr);
+ FontPlatformDataCache::iterator it = addResult.iterator;
+ if (addResult.isNewEntry) {
</ins><span class="cx"> it->value = createFontPlatformData(fontDescription, familyName);
</span><span class="cx">
</span><span class="cx"> if (!it->value && !checkingAlternateName) {
</span><span class="lines">@@ -254,8 +260,8 @@
</span><span class="cx"> FontPlatformData* fontPlatformDataForAlternateName = getCachedFontPlatformData(fontDescription, alternateName, true);
</span><span class="cx"> // Lookup the key in the hash table again as the previous iterator may have
</span><span class="cx"> // been invalidated by the recursive call to getCachedFontPlatformData().
</span><del>- it = gFontPlatformDataCache->find(key);
- ASSERT(it != gFontPlatformDataCache->end());
</del><ins>+ it = fontPlatformDataCache().find(key);
+ ASSERT(it != fontPlatformDataCache().end());
</ins><span class="cx"> if (fontPlatformDataForAlternateName)
</span><span class="cx"> it->value = std::make_unique<FontPlatformData>(*fontPlatformDataForAlternateName);
</span><span class="cx"> }
</span><span class="lines">@@ -353,10 +359,15 @@
</span><span class="cx"> }
</span><span class="cx"> };
</span><span class="cx">
</span><del>-typedef HashMap<FontPlatformData, std::pair<RefPtr<SimpleFontData>, unsigned>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache;
</del><ins>+typedef HashMap<FontPlatformData, RefPtr<SimpleFontData>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache;
</ins><span class="cx">
</span><del>-static FontDataCache* gFontDataCache = 0;
</del><ins>+static FontDataCache& cachedFonts()
+{
+ static NeverDestroyed<FontDataCache> cache;
+ return cache;
+}
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> const int cMaxInactiveFontData = 120;
</span><span class="cx"> const int cTargetInactiveFontData = 100;
</span><span class="lines">@@ -368,190 +379,118 @@
</span><span class="cx"> const int cMaxUnderMemoryPressureInactiveFontData = 50;
</span><span class="cx"> const int cTargetUnderMemoryPressureInactiveFontData = 30;
</span><span class="cx">
</span><del>-static ListHashSet<RefPtr<SimpleFontData>>* gInactiveFontData = 0;
-
-PassRefPtr<SimpleFontData> FontCache::getCachedFontData(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName, ShouldRetain shouldRetain)
</del><ins>+RefPtr<SimpleFontData> FontCache::fontForFamily(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName)
</ins><span class="cx"> {
</span><span class="cx"> FontPlatformData* platformData = getCachedFontPlatformData(fontDescription, family, checkingAlternateName);
</span><span class="cx"> if (!platformData)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><del>- return getCachedFontData(platformData, shouldRetain);
</del><ins>+ return fontForPlatformData(*platformData);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<SimpleFontData> FontCache::getCachedFontData(const FontPlatformData* platformData, ShouldRetain shouldRetain)
</del><ins>+Ref<SimpleFontData> FontCache::fontForPlatformData(const FontPlatformData& platformData)
</ins><span class="cx"> {
</span><del>- if (!platformData)
- return 0;
-
-#if !ASSERT_DISABLED
- if (shouldRetain == DoNotRetain)
- ASSERT(m_purgePreventCount);
-#endif
-
</del><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> FontLocker fontLocker;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- if (!gFontDataCache) {
- gFontDataCache = new FontDataCache;
- gInactiveFontData = new ListHashSet<RefPtr<SimpleFontData>>;
- }
</del><ins>+ auto addResult = cachedFonts().add(platformData, nullptr);
+ if (addResult.isNewEntry)
+ addResult.iterator->value = SimpleFontData::create(platformData);
</ins><span class="cx">
</span><del>- FontDataCache::iterator result = gFontDataCache->find(*platformData);
- if (result == gFontDataCache->end()) {
- std::pair<RefPtr<SimpleFontData>, unsigned> newValue(SimpleFontData::create(*platformData), shouldRetain == Retain ? 1 : 0);
- gFontDataCache->set(*platformData, newValue);
- if (shouldRetain == DoNotRetain)
- gInactiveFontData->add(newValue.first);
- return newValue.first.release();
- }
-
- if (!result.get()->value.second) {
- ASSERT(gInactiveFontData->contains(result.get()->value.first));
- gInactiveFontData->remove(result.get()->value.first);
- }
-
- if (shouldRetain == Retain)
- result.get()->value.second++;
- else if (!result.get()->value.second) {
- // If shouldRetain is DoNotRetain and count is 0, we want to remove the fontData from
- // gInactiveFontData (above) and re-add here to update LRU position.
- gInactiveFontData->add(result.get()->value.first);
- }
-
- return result.get()->value.first;
</del><ins>+ return *addResult.iterator->value;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont(const FontDescription& fontDescription)
-{
- return getLastResortFallbackFont(fontDescription, DoNotRetain).leakRef();
-}
-
-void FontCache::releaseFontData(const SimpleFontData* fontData)
-{
- ASSERT(gFontDataCache);
- ASSERT(!fontData->isCustomFont());
-
-#if PLATFORM(IOS)
- FontLocker fontLocker;
-#endif
-
- FontDataCache::iterator it = gFontDataCache->find(fontData->platformData());
- ASSERT(it != gFontDataCache->end());
- if (it == gFontDataCache->end())
- return;
-
- ASSERT(it->value.second);
- if (!--it->value.second)
- gInactiveFontData->add(it->value.first);
-}
-
</del><span class="cx"> void FontCache::purgeInactiveFontDataIfNeeded()
</span><span class="cx"> {
</span><span class="cx"> bool underMemoryPressure = memoryPressureHandler().isUnderMemoryPressure();
</span><span class="cx"> int inactiveFontDataLimit = underMemoryPressure ? cMaxUnderMemoryPressureInactiveFontData : cMaxInactiveFontData;
</span><del>- int targetFontDataLimit = underMemoryPressure ? cTargetUnderMemoryPressureInactiveFontData : cTargetInactiveFontData;
</del><span class="cx">
</span><del>- if (gInactiveFontData && !m_purgePreventCount && gInactiveFontData->size() > inactiveFontDataLimit)
- purgeInactiveFontData(gInactiveFontData->size() - targetFontDataLimit);
</del><ins>+ if (cachedFonts().size() < inactiveFontDataLimit)
+ return;
+ int inactiveCount = inactiveFontDataCount();
+ if (inactiveCount <= inactiveFontDataLimit)
+ return;
+
+ int targetFontDataLimit = underMemoryPressure ? cTargetUnderMemoryPressureInactiveFontData : cTargetInactiveFontData;
+ purgeInactiveFontData(inactiveCount - targetFontDataLimit);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void FontCache::purgeInactiveFontData(int count)
</del><ins>+void FontCache::purgeInactiveFontData(int purgeCount)
</ins><span class="cx"> {
</span><span class="cx"> pruneUnreferencedEntriesFromFontGlyphsCache();
</span><span class="cx">
</span><del>- if (!gInactiveFontData || m_purgePreventCount)
</del><ins>+ if (m_purgePreventCount)
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- static bool isPurging; // Guard against reentry when e.g. a deleted FontData releases its small caps FontData.
- if (isPurging)
- return;
-
- isPurging = true;
-
</del><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> FontLocker fontLocker;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- Vector<RefPtr<SimpleFontData>, 20> fontDataToDelete;
- ListHashSet<RefPtr<SimpleFontData>>::iterator end = gInactiveFontData->end();
- ListHashSet<RefPtr<SimpleFontData>>::iterator it = gInactiveFontData->begin();
- for (int i = 0; i < count && it != end; ++it, ++i) {
- RefPtr<SimpleFontData>& fontData = *it.get();
- gFontDataCache->remove(fontData->platformData());
- // We should not delete SimpleFontData here because deletion can modify gInactiveFontData. See http://trac.webkit.org/changeset/44011
- fontDataToDelete.append(fontData);
</del><ins>+ Vector<RefPtr<SimpleFontData>, 20> fontsToDelete;
+ for (auto& font : cachedFonts().values()) {
+ if (!font->hasOneRef())
+ continue;
+ fontsToDelete.append(WTF::move(font));
+ if (!--purgeCount)
+ break;
</ins><span class="cx"> }
</span><ins>+ for (auto& font : fontsToDelete)
+ cachedFonts().remove(font->platformData());
</ins><span class="cx">
</span><del>- if (it == end) {
- // Removed everything
- gInactiveFontData->clear();
- } else {
- for (int i = 0; i < count; ++i)
- gInactiveFontData->remove(gInactiveFontData->begin());
</del><ins>+ Vector<FontPlatformDataCacheKey> keysToRemove;
+ keysToRemove.reserveInitialCapacity(fontPlatformDataCache().size());
+ for (auto& entry : fontPlatformDataCache()) {
+ if (entry.value && !cachedFonts().contains(*entry.value))
+ keysToRemove.append(entry.key);
</ins><span class="cx"> }
</span><ins>+ for (auto key : keysToRemove)
+ fontPlatformDataCache().remove(key);
</ins><span class="cx">
</span><del>- fontDataToDelete.clear();
-
- if (gFontPlatformDataCache) {
- Vector<FontPlatformDataCacheKey> keysToRemove;
- keysToRemove.reserveInitialCapacity(gFontPlatformDataCache->size());
- FontPlatformDataCache::iterator platformDataEnd = gFontPlatformDataCache->end();
- for (FontPlatformDataCache::iterator platformData = gFontPlatformDataCache->begin(); platformData != platformDataEnd; ++platformData) {
- if (platformData->value && !gFontDataCache->contains(*platformData->value))
- keysToRemove.append(platformData->key);
- }
-
- size_t keysToRemoveCount = keysToRemove.size();
- for (size_t i = 0; i < keysToRemoveCount; ++i)
- gFontPlatformDataCache->remove(keysToRemove[i]);
- }
-
</del><span class="cx"> #if ENABLE(OPENTYPE_VERTICAL)
</span><span class="cx"> FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance();
</span><span class="cx"> if (!fontVerticalDataCache.isEmpty()) {
</span><span class="cx"> // Mark & sweep unused verticalData
</span><del>- FontVerticalDataCache::iterator verticalDataEnd = fontVerticalDataCache.end();
- for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCache.begin(); verticalData != verticalDataEnd; ++verticalData) {
- if (verticalData->value)
- verticalData->value->m_inFontCache = false;
</del><ins>+ for (auto& verticalData : fontVerticalDataCache.values()) {
+ if (verticalData)
+ verticalData->m_inFontCache = false;
</ins><span class="cx"> }
</span><del>- FontDataCache::iterator fontDataEnd = gFontDataCache->end();
- for (FontDataCache::iterator fontData = gFontDataCache->begin(); fontData != fontDataEnd; ++fontData) {
- OpenTypeVerticalData* verticalData = const_cast<OpenTypeVerticalData*>(fontData->value.first->verticalData());
</del><ins>+ for (auto& fontData : cachedFonts().values()) {
+ auto* verticalData = const_cast<OpenTypeVerticalData*>(fontData->verticalData());
</ins><span class="cx"> if (verticalData)
</span><span class="cx"> verticalData->m_inFontCache = true;
</span><span class="cx"> }
</span><span class="cx"> Vector<FontFileKey> keysToRemove;
</span><span class="cx"> keysToRemove.reserveInitialCapacity(fontVerticalDataCache.size());
</span><del>- for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCache.begin(); verticalData != verticalDataEnd; ++verticalData) {
- if (!verticalData->value || !verticalData->value->m_inFontCache)
- keysToRemove.append(verticalData->key);
</del><ins>+ for (auto& it : fontVerticalDataCache) {
+ if (!it.value || !it.value->m_inFontCache)
+ keysToRemove.append(it.key);
</ins><span class="cx"> }
</span><del>- for (size_t i = 0, count = keysToRemove.size(); i < count; ++i)
- fontVerticalDataCache.take(keysToRemove[i]);
</del><ins>+ for (auto& key : keysToRemove)
+ fontVerticalDataCache.remove(key);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><del>-
- isPurging = false;
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> size_t FontCache::fontDataCount()
</span><span class="cx"> {
</span><del>- if (gFontDataCache)
- return gFontDataCache->size();
- return 0;
</del><ins>+ return cachedFonts().size();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> size_t FontCache::inactiveFontDataCount()
</span><span class="cx"> {
</span><del>- if (gInactiveFontData)
- return gInactiveFontData->size();
- return 0;
</del><ins>+#if PLATFORM(IOS)
+ FontLocker fontLocker;
+#endif
+ unsigned count = 0;
+ for (auto& font : cachedFonts().values()) {
+ if (font->hasOneRef())
+ ++count;
+ }
+ return count;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<FontData> FontCache::getFontData(const FontDescription& description, int& familyIndex, FontSelector* fontSelector)
</del><ins>+RefPtr<FontData> FontCache::fontForFamilyAtIndex(const FontDescription& description, int& familyIndex, FontSelector* fontSelector)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(familyIndex != cAllFamiliesScanned);
</span><span class="cx"> RefPtr<FontData> result;
</span><span class="lines">@@ -565,7 +504,7 @@
</span><span class="cx"> if (fontSelector)
</span><span class="cx"> result = fontSelector->getFontData(description, family);
</span><span class="cx"> if (!result)
</span><del>- result = getCachedFontData(description, family);
</del><ins>+ result = fontForFamily(description, family);
</ins><span class="cx"> }
</span><span class="cx"> if (familyIndex == familyCount)
</span><span class="cx"> familyIndex = cAllFamiliesScanned;
</span><span class="lines">@@ -588,7 +527,7 @@
</span><span class="cx"> return data.release();
</span><span class="cx"> }
</span><span class="cx"> // Still no result. Hand back our last resort fallback font.
</span><del>- result = getLastResortFallbackFont(description);
</del><ins>+ result = lastResortFallbackFont(description);
</ins><span class="cx"> }
</span><span class="cx"> return result.release();
</span><span class="cx"> }
</span><span class="lines">@@ -622,12 +561,11 @@
</span><span class="cx"> void FontCache::invalidate()
</span><span class="cx"> {
</span><span class="cx"> if (!gClients) {
</span><del>- ASSERT(!gFontPlatformDataCache);
</del><ins>+ ASSERT(fontPlatformDataCache().isEmpty());
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (gFontPlatformDataCache)
- gFontPlatformDataCache->clear();
</del><ins>+ fontPlatformDataCache().clear();
</ins><span class="cx"> invalidateFontGlyphsCache();
</span><span class="cx">
</span><span class="cx"> gGeneration++;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCache.h        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -111,13 +111,10 @@
</span><span class="cx"> public:
</span><span class="cx"> friend FontCache& fontCache();
</span><span class="cx">
</span><del>- enum ShouldRetain { Retain, DoNotRetain };
</del><ins>+ RefPtr<FontData> fontForFamilyAtIndex(const FontDescription&, int& familyIndex, FontSelector*);
</ins><span class="cx">
</span><del>- PassRefPtr<FontData> getFontData(const FontDescription&, int& familyIndex, FontSelector*);
- void releaseFontData(const SimpleFontData*);
-
</del><span class="cx"> // This method is implemented by the platform.
</span><del>- PassRefPtr<SimpleFontData> systemFallbackForCharacters(const FontDescription&, const SimpleFontData* originalFontData, bool isPlatformFont, const UChar* characters, int length);
</del><ins>+ RefPtr<SimpleFontData> systemFallbackForCharacters(const FontDescription&, const SimpleFontData* originalFontData, bool isPlatformFont, const UChar* characters, int length);
</ins><span class="cx">
</span><span class="cx"> // Also implemented by the platform.
</span><span class="cx"> void platformInit();
</span><span class="lines">@@ -134,9 +131,8 @@
</span><span class="cx">
</span><span class="cx"> void getTraitsInFamily(const AtomicString&, Vector<unsigned>&);
</span><span class="cx">
</span><del>- WEBCORE_EXPORT PassRefPtr<SimpleFontData> getCachedFontData(const FontDescription&, const AtomicString&, bool checkingAlternateName = false, ShouldRetain = Retain);
- WEBCORE_EXPORT PassRefPtr<SimpleFontData> getLastResortFallbackFont(const FontDescription&, ShouldRetain = Retain);
- SimpleFontData* getNonRetainedLastResortFallbackFont(const FontDescription&);
</del><ins>+ WEBCORE_EXPORT RefPtr<SimpleFontData> fontForFamily(const FontDescription&, const AtomicString&, bool checkingAlternateName = false);
+ WEBCORE_EXPORT Ref<SimpleFontData> lastResortFallbackFont(const FontDescription&);
</ins><span class="cx">
</span><span class="cx"> void addClient(FontSelector*);
</span><span class="cx"> void removeClient(FontSelector*);
</span><span class="lines">@@ -149,7 +145,7 @@
</span><span class="cx"> WEBCORE_EXPORT void purgeInactiveFontData(int count = INT_MAX);
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(WIN)
</span><del>- PassRefPtr<SimpleFontData> fontDataFromDescriptionAndLogFont(const FontDescription&, ShouldRetain, const LOGFONT&, AtomicString& outFontFamilyName);
</del><ins>+ PassRef<SimpleFontData> fontDataFromDescriptionAndLogFont(const FontDescription&, const LOGFONT&, AtomicString& outFontFamilyName);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(OPENTYPE_VERTICAL)
</span><span class="lines">@@ -191,7 +187,7 @@
</span><span class="cx"> PassRefPtr<SimpleFontData> similarFontPlatformData(const FontDescription&);
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- WEBCORE_EXPORT PassRefPtr<SimpleFontData> getCachedFontData(const FontPlatformData*, ShouldRetain = Retain);
</del><ins>+ WEBCORE_EXPORT Ref<SimpleFontData> fontForPlatformData(const FontPlatformData&);
</ins><span class="cx">
</span><span class="cx"> // Don't purge if this count is > 0;
</span><span class="cx"> int m_purgePreventCount;
</span><span class="lines">@@ -199,7 +195,7 @@
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> friend class ComplexTextController;
</span><span class="cx"> #endif
</span><del>- friend class SimpleFontData; // For getCachedFontData(const FontPlatformData*)
</del><ins>+ friend class SimpleFontData;
</ins><span class="cx"> friend class FontGlyphs;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontGlyphscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -59,18 +59,11 @@
</span><span class="cx"> , m_loadingCustomFonts(false)
</span><span class="cx"> , m_isForPlatformFont(true)
</span><span class="cx"> {
</span><del>- RefPtr<FontData> fontData = fontCache().getCachedFontData(&platformData);
- m_realizedFontData.append(fontData.release());
</del><ins>+ m_realizedFontData.append(fontCache().fontForPlatformData(platformData));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void FontGlyphs::releaseFontData()
</del><ins>+FontGlyphs::~FontGlyphs()
</ins><span class="cx"> {
</span><del>- unsigned numFonts = m_realizedFontData.size();
- for (unsigned i = 0; i < numFonts; ++i) {
- if (m_realizedFontData[i]->isCustomFont())
- continue;
- fontCache().releaseFontData(downcast<SimpleFontData>(m_realizedFontData[i].get()));
- }
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void FontGlyphs::determinePitch(const FontDescription& description)
</span><span class="lines">@@ -113,10 +106,10 @@
</span><span class="cx">
</span><span class="cx"> // Ask the font cache for the font data.
</span><span class="cx"> // We are obtaining this font for the first time. We keep track of the families we've looked at before
</span><del>- // in |m_familyIndex|, so that we never scan the same spot in the list twice. getFontData will adjust our
</del><ins>+ // in |m_familyIndex|, so that we never scan the same spot in the list twice. fontForFamilyAtIndex will adjust our
</ins><span class="cx"> // |m_familyIndex| as it scans for the right font to make.
</span><span class="cx"> ASSERT(fontCache().generation() == m_generation);
</span><del>- RefPtr<FontData> result = fontCache().getFontData(description, m_familyIndex, m_fontSelector.get());
</del><ins>+ RefPtr<FontData> result = fontCache().fontForFamilyAtIndex(description, m_familyIndex, m_fontSelector.get());
</ins><span class="cx"> if (result) {
</span><span class="cx"> m_realizedFontData.append(result);
</span><span class="cx"> if (result->isLoading())
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontGlyphsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontGlyphs.h (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontGlyphs.h        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/FontGlyphs.h        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> static Ref<FontGlyphs> create(PassRefPtr<FontSelector> fontSelector) { return adoptRef(*new FontGlyphs(fontSelector)); }
</span><span class="cx"> static Ref<FontGlyphs> createForPlatformFont(const FontPlatformData& platformData) { return adoptRef(*new FontGlyphs(platformData)); }
</span><span class="cx">
</span><del>- ~FontGlyphs() { releaseFontData(); }
</del><ins>+ ~FontGlyphs();
</ins><span class="cx">
</span><span class="cx"> bool isForPlatformFont() const { return m_isForPlatformFont; }
</span><span class="cx">
</span><span class="lines">@@ -77,8 +77,6 @@
</span><span class="cx"> GlyphData glyphDataForSystemFallback(UChar32, const FontDescription&, FontDataVariant);
</span><span class="cx"> GlyphData glyphDataForNormalVariant(UChar32, const FontDescription&);
</span><span class="cx"> GlyphData glyphDataForVariant(UChar32, const FontDescription&, FontDataVariant, unsigned fallbackLevel);
</span><del>-
- WEBCORE_EXPORT void releaseFontData();
</del><span class="cx">
</span><span class="cx"> Vector<RefPtr<FontData>, 1> m_realizedFontData;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsSimpleFontDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -154,9 +154,6 @@
</span><span class="cx">
</span><span class="cx"> SimpleFontData::~SimpleFontData()
</span><span class="cx"> {
</span><del>- if (!isSVGFont())
- platformDestroy();
-
</del><span class="cx"> removeFromSystemFallbackCache();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsSimpleFontDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/SimpleFontData.h (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/SimpleFontData.h        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/SimpleFontData.h        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -81,15 +81,15 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> // Used to create platform fonts.
</span><del>- static PassRefPtr<SimpleFontData> create(const FontPlatformData& platformData, bool isCustomFont = false, bool isLoading = false, bool isTextOrientationFallback = false)
</del><ins>+ static Ref<SimpleFontData> create(const FontPlatformData& platformData, bool isCustomFont = false, bool isLoading = false, bool isTextOrientationFallback = false)
</ins><span class="cx"> {
</span><del>- return adoptRef(new SimpleFontData(platformData, isCustomFont, isLoading, isTextOrientationFallback));
</del><ins>+ return adoptRef(*new SimpleFontData(platformData, isCustomFont, isLoading, isTextOrientationFallback));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Used to create SVG Fonts.
</span><del>- static PassRefPtr<SimpleFontData> create(std::unique_ptr<SVGData> svgData, float fontSize, bool syntheticBold, bool syntheticItalic)
</del><ins>+ static Ref<SimpleFontData> create(std::unique_ptr<SVGData> svgData, float fontSize, bool syntheticBold, bool syntheticItalic)
</ins><span class="cx"> {
</span><del>- return adoptRef(new SimpleFontData(WTF::move(svgData), fontSize, syntheticBold, syntheticItalic));
</del><ins>+ return adoptRef(*new SimpleFontData(WTF::move(svgData), fontSize, syntheticBold, syntheticItalic));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> virtual ~SimpleFontData();
</span><span class="lines">@@ -222,7 +222,6 @@
</span><span class="cx"> void platformInit();
</span><span class="cx"> void platformGlyphInit();
</span><span class="cx"> void platformCharWidthInit();
</span><del>- void platformDestroy();
</del><span class="cx">
</span><span class="cx"> void initCharWidths();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfreetypeFontCacheFreeTypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx"> return FcFontSetMatch(0, sets, 1, pattern, &fontConfigResult);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)
</del><ins>+RefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)
</ins><span class="cx"> {
</span><span class="cx"> RefPtr<FcPattern> pattern = adoptRef(createFontConfigPatternForCharacters(characters, length));
</span><span class="cx"> const FontPlatformData& fontData = originalFontData->platformData();
</span><span class="lines">@@ -89,7 +89,7 @@
</span><span class="cx"> RefPtr<FcPattern> fallbackPattern = adoptRef(findBestFontGivenFallbacks(fontData, pattern.get()));
</span><span class="cx"> if (fallbackPattern) {
</span><span class="cx"> FontPlatformData alternateFontData(fallbackPattern.get(), description);
</span><del>- return getCachedFontData(&alternateFontData, DoNotRetain);
</del><ins>+ return fontForPlatformData(alternateFontData);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> FcResult fontConfigResult;
</span><span class="lines">@@ -97,15 +97,15 @@
</span><span class="cx"> if (!resultPattern)
</span><span class="cx"> return 0;
</span><span class="cx"> FontPlatformData alternateFontData(resultPattern.get(), description);
</span><del>- return getCachedFontData(&alternateFontData, DoNotRetain);
</del><ins>+ return fontForPlatformData(alternateFontData);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
</del><ins>+Ref<SimpleFontData> FontCache::lastResortFallbackFont(const FontDescription& fontDescription)
</ins><span class="cx"> {
</span><span class="cx"> // We want to return a fallback font here, otherwise the logic preventing FontConfig
</span><span class="cx"> // matches for non-fallback fonts might return 0. See isFallbackFontAllowed.
</span><span class="cx"> static AtomicString timesStr("serif");
</span><del>- return getCachedFontData(fontDescription, timesStr, false, shouldRetain);
</del><ins>+ return *fontForFamily(fontDescription, timesStr, false);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void FontCache::getTraitsInFamily(const AtomicString&, Vector<unsigned>&)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfreetypeSimpleFontDataFreeTypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -101,10 +101,6 @@
</span><span class="cx"> initCharWidths();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void SimpleFontData::platformDestroy()
-{
-}
-
</del><span class="cx"> PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
</span><span class="cx"> {
</span><span class="cx"> ASSERT(m_platformData.scaledFont());
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsiosFontCacheIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -94,7 +94,7 @@
</span><span class="cx"> FontPlatformData alternateFont(substituteFont.get(), platformData.size(), platformData.isPrinterFont(), syntheticBold, syntheticOblique, platformData.m_orientation);
</span><span class="cx"> alternateFont.m_isEmoji = CTFontIsAppleColorEmoji(substituteFont.get());
</span><span class="cx">
</span><del>- return getCachedFontData(&alternateFont, DoNotRetain);
</del><ins>+ return fontForPlatformData(alternateFont);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> enum class LanguageSpecificFont {
</span><span class="lines">@@ -194,12 +194,16 @@
</span><span class="cx"> return LanguageSpecificFont::None;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)
</del><ins>+RefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)
</ins><span class="cx"> {
</span><span class="cx"> // Unlike OS X, our fallback font on iPhone is Arial Unicode, which doesn't have some apple-specific glyphs like F8FF.
</span><span class="cx"> // Fall back to the Apple Fallback font in this case.
</span><del>- if (length > 0 && requiresCustomFallbackFont(*characters))
- return getCachedFontData(getCustomFallbackFont(*characters, description), DoNotRetain);
</del><ins>+ if (length > 0 && requiresCustomFallbackFont(*characters)) {
+ auto* fallback = getCustomFallbackFont(*characters, description);
+ if (!fallback)
+ return nullptr;
+ return fontForPlatformData(*fallback);
+ }
</ins><span class="cx">
</span><span class="cx"> UChar32 c = *characters;
</span><span class="cx"> if (length > 1 && U16_IS_LEAD(c) && U16_IS_TRAIL(characters[1]))
</span><span class="lines">@@ -294,7 +298,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? *cjkBold[preferredCJKFont] : *cjkPlain[preferredCJKFont], false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? *cjkBold[preferredCJKFont] : *cjkPlain[preferredCJKFont], false);
</ins><span class="cx"> bool useSecondaryFont = true;
</span><span class="cx"> if (simpleFontData) {
</span><span class="cx"> CGGlyph glyphs[2];
</span><span class="lines">@@ -306,31 +310,31 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (useSecondaryFont)
</span><del>- simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? *cjkBold[secondaryCJKFont] : *cjkPlain[secondaryCJKFont], false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? *cjkBold[secondaryCJKFont] : *cjkPlain[secondaryCJKFont], false);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case LanguageSpecificFont::Korean: {
</span><span class="cx"> static NeverDestroyed<AtomicString> koreanPlain("AppleSDGothicNeo-Medium", AtomicString::ConstructFromLiteral);
</span><span class="cx"> static NeverDestroyed<AtomicString> koreanBold("AppleSDGothicNeo-Bold", AtomicString::ConstructFromLiteral);
</span><del>- simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? koreanBold : koreanPlain, false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? koreanBold : koreanPlain, false);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case LanguageSpecificFont::Cyrillic: {
</span><span class="cx"> static NeverDestroyed<AtomicString> cyrillicPlain("HelveticaNeue", AtomicString::ConstructFromLiteral);
</span><span class="cx"> static NeverDestroyed<AtomicString> cyrillicBold("HelveticaNeue-Bold", AtomicString::ConstructFromLiteral);
</span><del>- simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? cyrillicBold : cyrillicPlain, false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? cyrillicBold : cyrillicPlain, false);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case LanguageSpecificFont::Arabic: {
</span><span class="cx"> static NeverDestroyed<AtomicString> arabicPlain("GeezaPro", AtomicString::ConstructFromLiteral);
</span><span class="cx"> static NeverDestroyed<AtomicString> arabicBold("GeezaPro-Bold", AtomicString::ConstructFromLiteral);
</span><del>- simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? arabicBold : arabicPlain, false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? arabicBold : arabicPlain, false);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case LanguageSpecificFont::Hebrew: {
</span><span class="cx"> static NeverDestroyed<AtomicString> hebrewPlain("ArialHebrew", AtomicString::ConstructFromLiteral);
</span><span class="cx"> static NeverDestroyed<AtomicString> hebrewBold("ArialHebrew-Bold", AtomicString::ConstructFromLiteral);
</span><del>- simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? hebrewBold : hebrewPlain, false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? hebrewBold : hebrewPlain, false);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case LanguageSpecificFont::Indic: {
</span><span class="lines">@@ -386,36 +390,36 @@
</span><span class="cx"> if (indicPageOrderIndex < (sizeof(indicUnicodePageFonts) / sizeof(AtomicString*))) {
</span><span class="cx"> AtomicString* indicFontString = isFontWeightBold(description.weight()) ? indicUnicodePageFontsBold[indicPageOrderIndex] : indicUnicodePageFonts[indicPageOrderIndex];
</span><span class="cx"> if (indicFontString)
</span><del>- simpleFontData = getCachedFontData(description, *indicFontString, false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, *indicFontString, false);
</ins><span class="cx"> }
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case LanguageSpecificFont::Thai: {
</span><span class="cx"> static NeverDestroyed<AtomicString> thaiPlain("Thonburi", AtomicString::ConstructFromLiteral);
</span><span class="cx"> static NeverDestroyed<AtomicString> thaiBold("Thonburi-Bold", AtomicString::ConstructFromLiteral);
</span><del>- simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? thaiBold : thaiPlain, false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? thaiBold : thaiPlain, false);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case LanguageSpecificFont::Tibetan: {
</span><span class="cx"> static NeverDestroyed<AtomicString> tibetanPlain("Kailasa", AtomicString::ConstructFromLiteral);
</span><span class="cx"> static NeverDestroyed<AtomicString> tibetanBold("Kailasa-Bold", AtomicString::ConstructFromLiteral);
</span><del>- simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? tibetanBold : tibetanPlain, false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? tibetanBold : tibetanPlain, false);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case LanguageSpecificFont::CanadianAboriginalSyllabic: {
</span><span class="cx"> static NeverDestroyed<AtomicString> casPlain("EuphemiaUCAS", AtomicString::ConstructFromLiteral);
</span><span class="cx"> static NeverDestroyed<AtomicString> casBold("EuphemiaUCAS-Bold", AtomicString::ConstructFromLiteral);
</span><del>- simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? casBold : casPlain, false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? casBold : casPlain, false);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case LanguageSpecificFont::Khmer: {
</span><span class="cx"> static NeverDestroyed<AtomicString> khmer("KhmerSangamMN", AtomicString::ConstructFromLiteral);
</span><del>- simpleFontData = getCachedFontData(description, khmer, false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, khmer, false);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case LanguageSpecificFont::Lao: {
</span><span class="cx"> static NeverDestroyed<AtomicString> lao("LaoSangamMN", AtomicString::ConstructFromLiteral);
</span><del>- simpleFontData = getCachedFontData(description, lao, false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, lao, false);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> default: {
</span><span class="lines">@@ -426,11 +430,11 @@
</span><span class="cx"> useEmojiFont = CFCharacterSetIsLongCharacterMember(appleColorEmojiCharacterSet(), c);
</span><span class="cx"> }
</span><span class="cx"> if (useEmojiFont)
</span><del>- simpleFontData = getCachedFontData(description, appleColorEmoji, false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, appleColorEmoji, false);
</ins><span class="cx"> else {
</span><span class="cx"> RetainPtr<CTFontRef> fallbackFont = adoptCF(CTFontCreateForCharacters(originalFontData->getCTFont(), characters, length, nullptr));
</span><span class="cx"> if (RetainPtr<CFStringRef> foundFontName = adoptCF(CTFontCopyPostScriptName(fallbackFont.get())))
</span><del>- simpleFontData = getCachedFontData(description, foundFontName.get(), false, DoNotRetain);
</del><ins>+ simpleFontData = fontForFamily(description, foundFontName.get(), false);
</ins><span class="cx"> }
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="lines">@@ -439,7 +443,7 @@
</span><span class="cx"> if (simpleFontData)
</span><span class="cx"> return simpleFontData.release();
</span><span class="cx">
</span><del>- return getNonRetainedLastResortFallbackFont(description);
</del><ins>+ return lastResortFallbackFont(description);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PassRefPtr<SimpleFontData> FontCache::similarFontPlatformData(const FontDescription& description)
</span><span class="lines">@@ -457,7 +461,7 @@
</span><span class="cx"> static NeverDestroyed<AtomicString> menlo("menlo", AtomicString::ConstructFromLiteral);
</span><span class="cx"> static NeverDestroyed<AtomicString> courier("courier", AtomicString::ConstructFromLiteral);
</span><span class="cx"> if (equalIgnoringCase(family, monaco) || equalIgnoringCase(family, menlo)) {
</span><del>- simpleFontData = getCachedFontData(description, courier);
</del><ins>+ simpleFontData = fontForFamily(description, courier);
</ins><span class="cx"> continue;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -465,7 +469,7 @@
</span><span class="cx"> static NeverDestroyed<AtomicString> lucidaGrande("lucida grande", AtomicString::ConstructFromLiteral);
</span><span class="cx"> static NeverDestroyed<AtomicString> verdana("verdana", AtomicString::ConstructFromLiteral);
</span><span class="cx"> if (equalIgnoringCase(family, lucidaGrande)) {
</span><del>- simpleFontData = getCachedFontData(description, verdana);
</del><ins>+ simpleFontData = fontForFamily(description, verdana);
</ins><span class="cx"> continue;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -477,16 +481,16 @@
</span><span class="cx"> static NeverDestroyed<AtomicString> geezaBold("GeezaPro-Bold", AtomicString::ConstructFromLiteral);
</span><span class="cx"> for (int j = 0; j < 3 && !simpleFontData; ++j)
</span><span class="cx"> if (family.contains(*matchWords[j], false))
</span><del>- simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? geezaBold : geezaPlain);
</del><ins>+ simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? geezaBold : geezaPlain);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return simpleFontData.release();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
</del><ins>+Ref<SimpleFontData> FontCache::lastResortFallbackFont(const FontDescription& fontDescription)
</ins><span class="cx"> {
</span><span class="cx"> static NeverDestroyed<AtomicString> fallbackFontFamily(".PhoneFallback", AtomicString::ConstructFromLiteral);
</span><del>- return getCachedFontData(fontDescription, fallbackFontFamily, false, shouldRetain);
</del><ins>+ return *fontForFamily(fontDescription, fallbackFontFamily, false);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> FontPlatformData* FontCache::getCustomFallbackFont(const UInt32 c, const FontDescription& description)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsiosSimpleFontDataIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ios/SimpleFontDataIOS.mm (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ios/SimpleFontDataIOS.mm        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/ios/SimpleFontDataIOS.mm        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -161,7 +161,7 @@
</span><span class="cx"> scaledFontData.m_syntheticBold = (fontTraits & kCTFontBoldTrait) && !(scaledFontTraits & kCTFontTraitBold);
</span><span class="cx"> scaledFontData.m_syntheticOblique = (fontTraits & kCTFontItalicTrait) && !(scaledFontTraits & kCTFontTraitItalic);
</span><span class="cx">
</span><del>- return fontCache().getCachedFontData(&scaledFontData);
</del><ins>+ return fontCache().fontForPlatformData(scaledFontData);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return nullptr;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacComplexTextControllerCoreTextmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -276,13 +276,13 @@
</span><span class="cx"> m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFontData(), cp, stringLocation + runRange.location, runRange.length, m_run.ltr()));
</span><span class="cx"> continue;
</span><span class="cx"> }
</span><del>- runFontData = fontCache().getCachedFontData(m_font.fontDescription(), fontName.get(), false, FontCache::DoNotRetain).get();
</del><ins>+ runFontData = fontCache().fontForFamily(m_font.fontDescription(), fontName.get(), false).get();
</ins><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> // Core Text may have used a font that is not known to NSFontManager. In that case, fall back on
</span><span class="cx"> // using the font as returned, even though it may not have the best NSFontRenderingMode.
</span><span class="cx"> if (!runFontData) {
</span><span class="cx"> FontPlatformData runFontPlatformData((NSFont *)runFont, CTFontGetSize(runFont), m_font.fontDescription().usePrinterFont());
</span><del>- runFontData = fontCache().getCachedFontData(&runFontPlatformData, FontCache::DoNotRetain).get();
</del><ins>+ runFontData = &fontCache().fontForPlatformData(runFontPlatformData).get();
</ins><span class="cx"> }
</span><span class="cx"> #else
</span><span class="cx"> // FIXME: Just assert for now, until we can devise a better fix that works with iOS.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacFontCacheMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -337,7 +337,7 @@
</span><span class="cx"> return knownFamilies.get().add(family).isNewEntry;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool isPlatformFont, const UChar* characters, int length)
</del><ins>+RefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool isPlatformFont, const UChar* characters, int length)
</ins><span class="cx"> {
</span><span class="cx"> UChar32 character;
</span><span class="cx"> U16_GET(characters, 0, 0, length, character);
</span><span class="lines">@@ -402,7 +402,7 @@
</span><span class="cx"> !isPlatformFont && (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTrait),
</span><span class="cx"> platformData.m_orientation);
</span><span class="cx">
</span><del>- return getCachedFontData(&alternateFont, DoNotRetain);
</del><ins>+ return fontForPlatformData(alternateFont);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PassRefPtr<SimpleFontData> FontCache::similarFontPlatformData(const FontDescription& description)
</span><span class="lines">@@ -419,27 +419,27 @@
</span><span class="cx"> DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, geezaStr, ("Geeza Pro", AtomicString::ConstructFromLiteral));
</span><span class="cx"> for (int j = 0; j < 3 && !simpleFontData; ++j)
</span><span class="cx"> if (family.contains(*matchWords[j], false))
</span><del>- simpleFontData = getCachedFontData(description, geezaStr);
</del><ins>+ simpleFontData = fontForFamily(description, geezaStr);
</ins><span class="cx"> }
</span><span class="cx"> return simpleFontData.release();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
</del><ins>+Ref<SimpleFontData> FontCache::lastResortFallbackFont(const FontDescription& fontDescription)
</ins><span class="cx"> {
</span><span class="cx"> DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times", AtomicString::ConstructFromLiteral));
</span><span class="cx">
</span><span class="cx"> // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick
</span><span class="cx"> // the default that the user would get without changing any prefs.
</span><del>- RefPtr<SimpleFontData> simpleFontData = getCachedFontData(fontDescription, timesStr, false, shouldRetain);
</del><ins>+ RefPtr<SimpleFontData> simpleFontData = fontForFamily(fontDescription, timesStr, false);
</ins><span class="cx"> if (simpleFontData)
</span><del>- return simpleFontData.release();
</del><ins>+ return *simpleFontData;
</ins><span class="cx">
</span><span class="cx"> // The Times fallback will almost always work, but in the highly unusual case where
</span><span class="cx"> // the user doesn't have it, we fall back on Lucida Grande because that's
</span><span class="cx"> // guaranteed to be there, according to Nathan Taylor. This is good enough
</span><span class="cx"> // to avoid a crash at least.
</span><span class="cx"> DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande", AtomicString::ConstructFromLiteral));
</span><del>- return getCachedFontData(fontDescription, lucidaGrandeStr, false, shouldRetain);
</del><ins>+ return *fontForFamily(fontDescription, lucidaGrandeStr, false);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacSimpleFontDataMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -262,18 +262,6 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // USE(APPKIT)
</span><span class="cx">
</span><del>-void SimpleFontData::platformDestroy()
-{
- if (!isCustomFont() && m_derivedFontData) {
- // These come from the cache.
- if (m_derivedFontData->smallCaps)
- fontCache().releaseFontData(m_derivedFontData->smallCaps.get());
-
- if (m_derivedFontData->emphasisMark)
- fontCache().releaseFontData(m_derivedFontData->emphasisMark.get());
- }
-}
-
</del><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
</span><span class="cx"> {
</span><span class="lines">@@ -304,8 +292,7 @@
</span><span class="cx"> scaledFontData.m_syntheticBold = (fontTraits & NSBoldFontMask) && !(scaledFontTraits & NSBoldFontMask);
</span><span class="cx"> scaledFontData.m_syntheticOblique = (fontTraits & NSItalicFontMask) && !(scaledFontTraits & NSItalicFontMask);
</span><span class="cx">
</span><del>- // SimpleFontData::platformDestroy() takes care of not deleting the cached font data twice.
- return fontCache().getCachedFontData(&scaledFontData);
</del><ins>+ return fontCache().fontForPlatformData(scaledFontData);
</ins><span class="cx"> }
</span><span class="cx"> END_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontCacheWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -199,7 +199,7 @@
</span><span class="cx"> return hfont;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)
</del><ins>+RefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)
</ins><span class="cx"> {
</span><span class="cx"> UChar character = characters[0];
</span><span class="cx"> RefPtr<SimpleFontData> fontData;
</span><span class="lines">@@ -299,7 +299,7 @@
</span><span class="cx"> if (!familyName.isEmpty()) {
</span><span class="cx"> FontPlatformData* result = getCachedFontPlatformData(description, familyName);
</span><span class="cx"> if (result)
</span><del>- fontData = getCachedFontData(result, DoNotRetain);
</del><ins>+ fontData = fontForPlatformData(*result);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SelectObject(hdc, oldFont);
</span><span class="lines">@@ -309,20 +309,20 @@
</span><span class="cx"> return fontData.release();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<SimpleFontData> FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, ShouldRetain shouldRetain, const LOGFONT& font, AtomicString& outFontFamilyName)
</del><ins>+PassRef<SimpleFontData> FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, const LOGFONT& font, AtomicString& outFontFamilyName)
</ins><span class="cx"> {
</span><span class="cx"> AtomicString familyName = String(font.lfFaceName, wcsnlen(font.lfFaceName, LF_FACESIZE));
</span><del>- RefPtr<SimpleFontData> fontData = getCachedFontData(fontDescription, familyName, false, shouldRetain);
</del><ins>+ RefPtr<SimpleFontData> fontData = fontForFamily(fontDescription, familyName);
</ins><span class="cx"> if (fontData)
</span><span class="cx"> outFontFamilyName = familyName;
</span><del>- return fontData.release();
</del><ins>+ return fontData;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
</del><ins>+Ref<SimpleFontData> FontCache:lastResortFallbackFont(const FontDescription& fontDescription)
</ins><span class="cx"> {
</span><span class="cx"> DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, fallbackFontName, ());
</span><span class="cx"> if (!fallbackFontName.isEmpty())
</span><del>- return getCachedFontData(fontDescription, fallbackFontName, false, shouldRetain);
</del><ins>+ return *fontForFamily(fontDescription, fallbackFontName);
</ins><span class="cx">
</span><span class="cx"> // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick
</span><span class="cx"> // the default that the user would get without changing any prefs.
</span><span class="lines">@@ -339,9 +339,9 @@
</span><span class="cx"> };
</span><span class="cx"> RefPtr<SimpleFontData> simpleFont;
</span><span class="cx"> for (size_t i = 0; i < WTF_ARRAY_LENGTH(fallbackFonts); ++i) {
</span><del>- if (simpleFont = getCachedFontData(fontDescription, fallbackFonts[i], false, shouldRetain)) {
</del><ins>+ if (simpleFont = fontForFamily(fontDescription, fallbackFonts[i])) {
</ins><span class="cx"> fallbackFontName = fallbackFonts[i];
</span><del>- return simpleFont.release();
</del><ins>+ return *simpleFont;
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -349,28 +349,28 @@
</span><span class="cx"> if (HFONT defaultGUIFont = static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT))) {
</span><span class="cx"> LOGFONT defaultGUILogFont;
</span><span class="cx"> GetObject(defaultGUIFont, sizeof(defaultGUILogFont), &defaultGUILogFont);
</span><del>- if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, defaultGUILogFont, fallbackFontName))
- return simpleFont.release();
</del><ins>+ if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, defaultGUILogFont, fallbackFontName))
+ return *simpleFont;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Fall back to Non-client metrics fonts.
</span><span class="cx"> NONCLIENTMETRICS nonClientMetrics = {0};
</span><span class="cx"> nonClientMetrics.cbSize = sizeof(nonClientMetrics);
</span><span class="cx"> if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nonClientMetrics), &nonClientMetrics, 0)) {
</span><del>- if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfMessageFont, fallbackFontName))
- return simpleFont.release();
- if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfMenuFont, fallbackFontName))
- return simpleFont.release();
- if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfStatusFont, fallbackFontName))
- return simpleFont.release();
- if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfCaptionFont, fallbackFontName))
- return simpleFont.release();
- if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfSmCaptionFont, fallbackFontName))
- return simpleFont.release();
</del><ins>+ if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, nonClientMetrics.lfMessageFont, fallbackFontName))
+ return *simpleFont;
+ if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, nonClientMetrics.lfMenuFont, fallbackFontName))
+ return *simpleFont;
+ if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, nonClientMetrics.lfStatusFont, fallbackFontName))
+ return *simpleFont;
+ if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, nonClientMetrics.lfCaptionFont, fallbackFontName))
+ return *simpleFont;
+ if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, nonClientMetrics.lfSmCaptionFont, fallbackFontName))
+ return *simpleFont;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ASSERT_NOT_REACHED();
</span><del>- return 0;
</del><ins>+ return *simpleFont;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static LONG toGDIFontWeight(FontWeight fontWeight)
</span></span></pre></div>
<a id="trunkSourceWebKitiosMiscEmojiFallbackFontSelectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ios/Misc/EmojiFallbackFontSelector.cpp (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ios/Misc/EmojiFallbackFontSelector.cpp        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebKit/ios/Misc/EmojiFallbackFontSelector.cpp        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -37,10 +37,10 @@
</span><span class="cx"> PassRefPtr<FontData> EmojiFallbackFontSelector::getFallbackFontData(const FontDescription& fontDescription, size_t)
</span><span class="cx"> {
</span><span class="cx"> DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, appleColorEmoji, ("Apple Color Emoji"));
</span><del>- RefPtr<FontData> fontData = fontCache().getCachedFontData(fontDescription, appleColorEmoji);
</del><ins>+ RefPtr<FontData> fontData = fontCache().fontForFamily(fontDescription, appleColorEmoji);
</ins><span class="cx"> if (!fontData) {
</span><span class="cx"> LOG_ERROR("Failed to get \"Apple Color Emoji\" from the font cache. Using the last resort fallback font instead.");
</span><del>- fontData = fontCache().getLastResortFallbackFont(fontDescription);
</del><ins>+ fontData = fontCache().lastResortFallbackFont(fontDescription);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return fontData.release();
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebHTMLViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (178132 => 178133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2015-01-08 22:11:44 UTC (rev 178132)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2015-01-08 22:30:06 UTC (rev 178133)
</span><span class="lines">@@ -4879,7 +4879,7 @@
</span><span class="cx"> fontDescription.setWeight(bold ? FontWeight900 : FontWeight500);
</span><span class="cx"> fontDescription.setSpecifiedSize(pointSize);
</span><span class="cx"> FontCachePurgePreventer purgePreventer;
</span><del>- RefPtr<SimpleFontData> simpleFontData = fontCache().getCachedFontData(fontDescription, familyName, false, WebCore::FontCache::DoNotRetain);
</del><ins>+ RefPtr<SimpleFontData> simpleFontData = fontCache().fontForFamily(fontDescription, familyName);
</ins><span class="cx"> return [simpleFontData->platformData().nsFont() fontName];
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>