<!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>[178180] trunk/Source/WebCore</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/178180">178180</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2015-01-09 11:33:40 -0800 (Fri, 09 Jan 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>FontCache should only deal with SimpleFontData
https://bugs.webkit.org/show_bug.cgi?id=140293
Reviewed by Andreas Kling.
FontCache::fontForFamilyAtIndex hands out FontData objects and calls to FontSelector. That sort
of code does not belong to the cache layer. Move the functionality up to FontGlyphs.
* platform/graphics/Font.cpp:
(WebCore::Font::operator==):
(WebCore::Font::drawText):
(WebCore::Font::drawEmphasisMarks):
(WebCore::Font::isLoadingCustomFonts):
* platform/graphics/Font.h:
(WebCore::Font::loadingCustomFonts): Deleted.
* platform/graphics/FontCache.cpp:
(WebCore::FontCache::similarFontPlatformData):
Generic null implementation to reduce #ifs.
(WebCore::FontCache::fontForFamilyAtIndex): Deleted.
* platform/graphics/FontCache.h:
Unfriend FontGlyphs.
* platform/graphics/FontGlyphs.cpp:
(WebCore::FontGlyphs::FontGlyphs):
(WebCore::FontGlyphs::isLoadingCustomFonts):
We can figure thus out cheaply without caching a bit.
(WebCore::realizeNextFamily):
(WebCore::FontGlyphs::realizeFontDataAt):
Reorganize a bit to make the logic clearer.
Get rid of the strange cAllFamiliesScanned constant.
(WebCore::FontGlyphs::glyphDataForVariant):
(WebCore::FontGlyphs::glyphDataForNormalVariant):
Loop until null, that always works.
* platform/graphics/FontGlyphs.h:
(WebCore::FontGlyphs::loadingCustomFonts): Deleted.
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::FontCache::similarFontPlatformData):
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::FontCache::similarFontPlatformData):
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::dashesForIntersectionsWithRect):</pre>
<h3>Modified Paths</h3>
<ul>
<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="#trunkSourceWebCoreplatformgraphicsFonth">trunk/Source/WebCore/platform/graphics/Font.h</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="#trunkSourceWebCoreplatformgraphicscairoFontCairocpp">trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsiosFontCacheIOSmm">trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacFontCacheMacmm">trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacFontMacmm">trunk/Source/WebCore/platform/graphics/mac/FontMac.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (178179 => 178180)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-09 19:29:40 UTC (rev 178179)
+++ trunk/Source/WebCore/ChangeLog        2015-01-09 19:33:40 UTC (rev 178180)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2015-01-09 Antti Koivisto <antti@apple.com>
+
+ FontCache should only deal with SimpleFontData
+ https://bugs.webkit.org/show_bug.cgi?id=140293
+
+ Reviewed by Andreas Kling.
+
+ FontCache::fontForFamilyAtIndex hands out FontData objects and calls to FontSelector. That sort
+ of code does not belong to the cache layer. Move the functionality up to FontGlyphs.
+
+ * platform/graphics/Font.cpp:
+ (WebCore::Font::operator==):
+ (WebCore::Font::drawText):
+ (WebCore::Font::drawEmphasisMarks):
+ (WebCore::Font::isLoadingCustomFonts):
+ * platform/graphics/Font.h:
+ (WebCore::Font::loadingCustomFonts): Deleted.
+ * platform/graphics/FontCache.cpp:
+ (WebCore::FontCache::similarFontPlatformData):
+
+ Generic null implementation to reduce #ifs.
+
+ (WebCore::FontCache::fontForFamilyAtIndex): Deleted.
+ * platform/graphics/FontCache.h:
+
+ Unfriend FontGlyphs.
+
+ * platform/graphics/FontGlyphs.cpp:
+ (WebCore::FontGlyphs::FontGlyphs):
+ (WebCore::FontGlyphs::isLoadingCustomFonts):
+
+ We can figure thus out cheaply without caching a bit.
+
+ (WebCore::realizeNextFamily):
+ (WebCore::FontGlyphs::realizeFontDataAt):
+
+ Reorganize a bit to make the logic clearer.
+ Get rid of the strange cAllFamiliesScanned constant.
+
+ (WebCore::FontGlyphs::glyphDataForVariant):
+ (WebCore::FontGlyphs::glyphDataForNormalVariant):
+
+ Loop until null, that always works.
+
+ * platform/graphics/FontGlyphs.h:
+ (WebCore::FontGlyphs::loadingCustomFonts): Deleted.
+ * platform/graphics/ios/FontCacheIOS.mm:
+ (WebCore::FontCache::similarFontPlatformData):
+ * platform/graphics/mac/FontCacheMac.mm:
+ (WebCore::FontCache::similarFontPlatformData):
+ * platform/graphics/mac/FontMac.mm:
+ (WebCore::Font::dashesForIntersectionsWithRect):
+
</ins><span class="cx"> 2015-01-09 Csaba Osztrogonác <ossy@webkit.org>
</span><span class="cx">
</span><span class="cx"> REGRESSION(r177925): It broke the !ENABLE(INSPECTOR) build
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (178179 => 178180)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Font.cpp        2015-01-09 19:29:40 UTC (rev 178179)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp        2015-01-09 19:33:40 UTC (rev 178180)
</span><span class="lines">@@ -182,9 +182,7 @@
</span><span class="cx">
</span><span class="cx"> bool Font::operator==(const Font& other) const
</span><span class="cx"> {
</span><del>- // Our FontData don't have to be checked, since checking the font description will be fine.
- // FIXME: This does not work if the font was made with the FontPlatformData constructor.
- if (loadingCustomFonts() || other.loadingCustomFonts())
</del><ins>+ if (isLoadingCustomFonts() || other.isLoadingCustomFonts())
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> if (m_fontDescription != other.m_fontDescription || m_letterSpacing != other.m_letterSpacing || m_wordSpacing != other.m_wordSpacing)
</span><span class="lines">@@ -337,7 +335,7 @@
</span><span class="cx"> // Don't draw anything while we are using custom fonts that are in the process of loading,
</span><span class="cx"> // except if the 'force' argument is set to true (in which case it will use a fallback
</span><span class="cx"> // font).
</span><del>- if (loadingCustomFonts() && customFontNotReadyAction == DoNotPaintIfFontNotReady)
</del><ins>+ if (isLoadingCustomFonts() && customFontNotReadyAction == DoNotPaintIfFontNotReady)
</ins><span class="cx"> return 0;
</span><span class="cx">
</span><span class="cx"> to = (to == -1 ? run.length() : to);
</span><span class="lines">@@ -355,7 +353,7 @@
</span><span class="cx">
</span><span class="cx"> void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
</span><span class="cx"> {
</span><del>- if (loadingCustomFonts())
</del><ins>+ if (isLoadingCustomFonts())
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> if (to < 0)
</span><span class="lines">@@ -1083,6 +1081,11 @@
</span><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><ins>+
+bool Font::isLoadingCustomFonts() const
+{
+ return m_glyphs && m_glyphs->isLoadingCustomFonts();
+}
</ins><span class="cx">
</span><span class="cx"> GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun& textRun, const GlyphBuffer& glyphBuffer, int index)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFonth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Font.h (178179 => 178180)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Font.h        2015-01-09 19:29:40 UTC (rev 178179)
+++ trunk/Source/WebCore/platform/graphics/Font.h        2015-01-09 19:33:40 UTC (rev 178180)
</span><span class="lines">@@ -289,10 +289,7 @@
</span><span class="cx"> FontGlyphs* glyphs() const { return m_glyphs.get(); }
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- bool loadingCustomFonts() const
- {
- return m_glyphs && m_glyphs->loadingCustomFonts();
- }
</del><ins>+ bool isLoadingCustomFonts() const;
</ins><span class="cx">
</span><span class="cx"> TypesettingFeatures computeTypesettingFeatures() const
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (178179 => 178180)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCache.cpp        2015-01-09 19:29:40 UTC (rev 178179)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp        2015-01-09 19:33:40 UTC (rev 178180)
</span><span class="lines">@@ -490,48 +490,6 @@
</span><span class="cx"> return count;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<FontData> FontCache::fontForFamilyAtIndex(const FontDescription& description, int& familyIndex, FontSelector* fontSelector)
-{
- ASSERT(familyIndex != cAllFamiliesScanned);
- RefPtr<FontData> result;
-
- bool isFirst = !familyIndex;
- int familyCount = description.familyCount();
- for (;familyIndex < familyCount && !result; ++familyIndex) {
- const AtomicString& family = description.familyAt(familyIndex);
- if (family.isEmpty())
- continue;
- if (fontSelector)
- result = fontSelector->getFontData(description, family);
- if (!result)
- result = fontForFamily(description, family);
- }
- if (familyIndex == familyCount)
- familyIndex = cAllFamiliesScanned;
-
-#if PLATFORM(COCOA)
- if (!result) {
- // We didn't find a font. Try to find a similar font using our own specific knowledge about our platform.
- // For example on OS X, we know to map any families containing the words Arabic, Pashto, or Urdu to the
- // Geeza Pro font.
- result = similarFontPlatformData(description);
- }
-#endif
-
- if (!result && isFirst) {
- // If it's the primary font that we couldn't find, we try the following. In all other cases, we will
- // just use per-character system fallback.
- if (fontSelector) {
- // Try the user's preferred standard font.
- if (RefPtr<FontData> data = fontSelector->getFontData(description, standardFamily))
- return data.release();
- }
- // Still no result. Hand back our last resort fallback font.
- result = lastResortFallbackFont(description);
- }
- return result.release();
-}
-
</del><span class="cx"> static HashSet<FontSelector*>* gClients;
</span><span class="cx">
</span><span class="cx"> void FontCache::addClient(FontSelector* client)
</span><span class="lines">@@ -581,4 +539,11 @@
</span><span class="cx"> purgeInactiveFontData();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if !PLATFORM(COCOA)
+RefPtr<SimpleFontData> FontCache::similarFontPlatformData(const FontDescription&)
+{
+ return nullptr;
+}
+#endif
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (178179 => 178180)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCache.h        2015-01-09 19:29:40 UTC (rev 178179)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h        2015-01-09 19:33:40 UTC (rev 178180)
</span><span class="lines">@@ -52,7 +52,6 @@
</span><span class="cx">
</span><span class="cx"> class Font;
</span><span class="cx"> class FontPlatformData;
</span><del>-class FontData;
</del><span class="cx"> class FontSelector;
</span><span class="cx"> class OpenTypeVerticalData;
</span><span class="cx"> class SimpleFontData;
</span><span class="lines">@@ -111,8 +110,6 @@
</span><span class="cx"> public:
</span><span class="cx"> friend FontCache& fontCache();
</span><span class="cx">
</span><del>- RefPtr<FontData> fontForFamilyAtIndex(const FontDescription&, int& familyIndex, FontSelector*);
-
</del><span class="cx"> // This method is implemented by the platform.
</span><span class="cx"> RefPtr<SimpleFontData> systemFallbackForCharacters(const FontDescription&, const SimpleFontData* originalFontData, bool isPlatformFont, const UChar* characters, int length);
</span><span class="cx">
</span><span class="lines">@@ -133,6 +130,8 @@
</span><span class="cx">
</span><span class="cx"> WEBCORE_EXPORT RefPtr<SimpleFontData> fontForFamily(const FontDescription&, const AtomicString&, bool checkingAlternateName = false);
</span><span class="cx"> WEBCORE_EXPORT Ref<SimpleFontData> lastResortFallbackFont(const FontDescription&);
</span><ins>+ WEBCORE_EXPORT Ref<SimpleFontData> fontForPlatformData(const FontPlatformData&);
+ RefPtr<SimpleFontData> similarFontPlatformData(const FontDescription&);
</ins><span class="cx">
</span><span class="cx"> void addClient(FontSelector*);
</span><span class="cx"> void removeClient(FontSelector*);
</span><span class="lines">@@ -183,12 +182,7 @@
</span><span class="cx"> PassRefPtr<SimpleFontData> getSystemFontFallbackForCharacters(const FontDescription&, const SimpleFontData*, const UChar* characters, int length);
</span><span class="cx"> #endif
</span><span class="cx"> std::unique_ptr<FontPlatformData> createFontPlatformData(const FontDescription&, const AtomicString& family);
</span><del>-#if PLATFORM(COCOA)
- PassRefPtr<SimpleFontData> similarFontPlatformData(const FontDescription&);
-#endif
</del><span class="cx">
</span><del>- WEBCORE_EXPORT Ref<SimpleFontData> fontForPlatformData(const FontPlatformData&);
-
</del><span class="cx"> // Don't purge if this count is > 0;
</span><span class="cx"> int m_purgePreventCount;
</span><span class="cx">
</span><span class="lines">@@ -196,7 +190,6 @@
</span><span class="cx"> friend class ComplexTextController;
</span><span class="cx"> #endif
</span><span class="cx"> friend class SimpleFontData;
</span><del>- friend class FontGlyphs;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> // Get the global fontCache.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontGlyphscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp (178179 => 178180)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp        2015-01-09 19:29:40 UTC (rev 178179)
+++ trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp        2015-01-09 19:33:40 UTC (rev 178180)
</span><span class="lines">@@ -41,11 +41,7 @@
</span><span class="cx"> : m_cachedPrimarySimpleFontData(0)
</span><span class="cx"> , m_fontSelector(fontSelector)
</span><span class="cx"> , m_fontSelectorVersion(m_fontSelector ? m_fontSelector->version() : 0)
</span><del>- , m_familyIndex(0)
</del><span class="cx"> , m_generation(fontCache().generation())
</span><del>- , m_pitch(UnknownPitch)
- , m_loadingCustomFonts(false)
- , m_isForPlatformFont(false)
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -53,10 +49,7 @@
</span><span class="cx"> : m_cachedPrimarySimpleFontData(0)
</span><span class="cx"> , m_fontSelector(0)
</span><span class="cx"> , m_fontSelectorVersion(0)
</span><del>- , m_familyIndex(cAllFamiliesScanned)
</del><span class="cx"> , m_generation(fontCache().generation())
</span><del>- , m_pitch(UnknownPitch)
- , m_loadingCustomFonts(false)
</del><span class="cx"> , m_isForPlatformFont(true)
</span><span class="cx"> {
</span><span class="cx"> m_realizedFontData.append(fontCache().fontForPlatformData(platformData));
</span><span class="lines">@@ -81,40 +74,72 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-const FontData* FontGlyphs::realizeFontDataAt(const FontDescription& description, unsigned realizedFontIndex)
</del><ins>+bool FontGlyphs::isLoadingCustomFonts() const
</ins><span class="cx"> {
</span><del>- if (realizedFontIndex < m_realizedFontData.size())
- return m_realizedFontData[realizedFontIndex].get(); // This fallback font is already in our list.
</del><ins>+ for (auto& font : m_realizedFontData) {
+ if (font->isLoading())
+ return true;
+ }
+ return false;
+}
</ins><span class="cx">
</span><del>- // Make sure we're not passing in some crazy value here.
- ASSERT(realizedFontIndex == m_realizedFontData.size());
</del><ins>+static RefPtr<FontData> realizeNextFamily(const FontDescription& description, unsigned& index, FontSelector* fontSelector)
+{
+ ASSERT(index < description.familyCount());
</ins><span class="cx">
</span><del>- if (m_familyIndex <= cAllFamiliesScanned) {
- if (!m_fontSelector)
- return 0;
</del><ins>+ while (index < description.familyCount()) {
+ const AtomicString& family = description.familyAt(index++);
+ if (family.isEmpty())
+ continue;
+ if (fontSelector) {
+ if (auto font = fontSelector->getFontData(description, family))
+ return font;
+ }
+ if (auto font = fontCache().fontForFamily(description, family))
+ return font;
+ }
+ // We didn't find a font. Try to find a similar font using our own specific knowledge about our platform.
+ // For example on OS X, we know to map any families containing the words Arabic, Pashto, or Urdu to the
+ // Geeza Pro font.
+ return fontCache().similarFontPlatformData(description);
+}
</ins><span class="cx">
</span><del>- size_t index = cAllFamiliesScanned - m_familyIndex;
- if (index == m_fontSelector->fallbackFontDataCount())
- return 0;
</del><ins>+const FontData* FontGlyphs::realizeFontDataAt(const FontDescription& description, unsigned index)
+{
+ if (index < m_realizedFontData.size())
+ return &m_realizedFontData[index].get();
</ins><span class="cx">
</span><del>- m_familyIndex--;
- RefPtr<FontData> fallback = m_fontSelector->getFallbackFontData(description, index);
- if (fallback)
- m_realizedFontData.append(fallback);
- return fallback.get();
</del><ins>+ ASSERT(index == m_realizedFontData.size());
+ ASSERT(fontCache().generation() == m_generation);
+
+ if (!index) {
+ RefPtr<FontData> result = realizeNextFamily(description, m_lastRealizedFamilyIndex, m_fontSelector.get());
+ if (!result && m_fontSelector)
+ result = m_fontSelector->getFontData(description, standardFamily);
+ if (!result)
+ result = fontCache().lastResortFallbackFont(description);
+
+ m_realizedFontData.append(*result);
+ return result.get();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- // Ask the font cache for the font data.
- // We are obtaining this font for the first time. We keep track of the families we've looked at before
- // in |m_familyIndex|, so that we never scan the same spot in the list twice. fontForFamilyAtIndex will adjust our
- // |m_familyIndex| as it scans for the right font to make.
- ASSERT(fontCache().generation() == m_generation);
- RefPtr<FontData> result = fontCache().fontForFamilyAtIndex(description, m_familyIndex, m_fontSelector.get());
- if (result) {
- m_realizedFontData.append(result);
- if (result->isLoading())
- m_loadingCustomFonts = true;
</del><ins>+ RefPtr<FontData> result;
+ if (m_lastRealizedFamilyIndex < description.familyCount())
+ result = realizeNextFamily(description, m_lastRealizedFamilyIndex, m_fontSelector.get());
+
+ if (!result && m_fontSelector) {
+ ASSERT(m_lastRealizedFamilyIndex >= description.familyCount());
+
+ unsigned fontSelectorFallbackIndex = m_lastRealizedFamilyIndex - description.familyCount();
+ if (fontSelectorFallbackIndex == m_fontSelector->fallbackFontDataCount())
+ return nullptr;
+ ++m_lastRealizedFamilyIndex;
+ result = m_fontSelector->getFallbackFontData(description, fontSelectorFallbackIndex);
</ins><span class="cx"> }
</span><ins>+ if (!result)
+ return nullptr;
+
+ m_realizedFontData.append(*result);
</ins><span class="cx"> return result.get();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -268,13 +293,9 @@
</span><span class="cx"> return fallbackGlyphData;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-GlyphData FontGlyphs::glyphDataForVariant(UChar32 c, const FontDescription& description, FontDataVariant variant, unsigned fallbackLevel)
</del><ins>+GlyphData FontGlyphs::glyphDataForVariant(UChar32 c, const FontDescription& description, FontDataVariant variant, unsigned fallbackIndex)
</ins><span class="cx"> {
</span><del>- for (; fallbackLevel <= description.familyCount(); ++fallbackLevel) {
- auto* fontData = realizeFontDataAt(description, fallbackLevel);
- if (!fontData)
- break;
-
</del><ins>+ while (auto* fontData = realizeFontDataAt(description, fallbackIndex++)) {
</ins><span class="cx"> auto* simpleFontData = fontData->simpleFontDataForCharacter(c);
</span><span class="cx"> GlyphData data = simpleFontData ? simpleFontData->glyphDataForCharacter(c) : GlyphData();
</span><span class="cx"> if (data.fontData) {
</span><span class="lines">@@ -295,10 +316,7 @@
</span><span class="cx"> {
</span><span class="cx"> const unsigned pageNumber = c / GlyphPage::size;
</span><span class="cx">
</span><del>- for (unsigned fallbackLevel = 0; fallbackLevel <= description.familyCount(); ++fallbackLevel) {
- auto* fontData = realizeFontDataAt(description, fallbackLevel);
- if (!fontData)
- break;
</del><ins>+ for (unsigned fallbackIndex = 0; auto* fontData = realizeFontDataAt(description, fallbackIndex); ++fallbackIndex) {
</ins><span class="cx"> auto* simpleFontData = fontData->simpleFontDataForCharacter(c);
</span><span class="cx"> auto* page = simpleFontData ? simpleFontData->glyphPage(pageNumber) : nullptr;
</span><span class="cx"> if (!page)
</span><span class="lines">@@ -312,7 +330,7 @@
</span><span class="cx"> if (!data.fontData->hasVerticalGlyphs()) {
</span><span class="cx"> // Use the broken ideograph font data. The broken ideograph font will use the horizontal width of glyphs
</span><span class="cx"> // to make sure you get a square (even for broken glyphs like symbols used for punctuation).
</span><del>- return glyphDataForVariant(c, description, BrokenIdeographVariant, fallbackLevel);
</del><ins>+ return glyphDataForVariant(c, description, BrokenIdeographVariant, fallbackIndex);
</ins><span class="cx"> }
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> if (data.fontData->platformData().syntheticOblique())
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontGlyphsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontGlyphs.h (178179 => 178180)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontGlyphs.h        2015-01-09 19:29:40 UTC (rev 178179)
+++ trunk/Source/WebCore/platform/graphics/FontGlyphs.h        2015-01-09 19:33:40 UTC (rev 178180)
</span><span class="lines">@@ -40,8 +40,6 @@
</span><span class="cx"> class FontPlatformData;
</span><span class="cx"> class FontSelector;
</span><span class="cx">
</span><del>-const int cAllFamiliesScanned = -1;
-
</del><span class="cx"> class FontGlyphs : public RefCounted<FontGlyphs> {
</span><span class="cx"> WTF_MAKE_NONCOPYABLE(FontGlyphs);
</span><span class="cx"> public:
</span><span class="lines">@@ -57,7 +55,7 @@
</span><span class="cx"> bool isFixedPitch(const FontDescription&);
</span><span class="cx"> void determinePitch(const FontDescription&);
</span><span class="cx">
</span><del>- bool loadingCustomFonts() const { return m_loadingCustomFonts; }
</del><ins>+ bool isLoadingCustomFonts() const;
</ins><span class="cx">
</span><span class="cx"> FontSelector* fontSelector() { return m_fontSelector.get(); }
</span><span class="cx"> // FIXME: It should be possible to combine fontSelectorVersion and generation.
</span><span class="lines">@@ -76,10 +74,10 @@
</span><span class="cx">
</span><span class="cx"> GlyphData glyphDataForSystemFallback(UChar32, const FontDescription&, FontDataVariant);
</span><span class="cx"> GlyphData glyphDataForNormalVariant(UChar32, const FontDescription&);
</span><del>- GlyphData glyphDataForVariant(UChar32, const FontDescription&, FontDataVariant, unsigned fallbackLevel);
-
- Vector<RefPtr<FontData>, 1> m_realizedFontData;
</del><ins>+ GlyphData glyphDataForVariant(UChar32, const FontDescription&, FontDataVariant, unsigned fallbackIndex);
</ins><span class="cx">
</span><ins>+ Vector<Ref<FontData>, 1> m_realizedFontData;
+
</ins><span class="cx"> RefPtr<GlyphPage> m_cachedPageZero;
</span><span class="cx"> HashMap<int, RefPtr<GlyphPage>> m_cachedPages;
</span><span class="cx">
</span><span class="lines">@@ -89,11 +87,10 @@
</span><span class="cx"> RefPtr<FontSelector> m_fontSelector;
</span><span class="cx"> WidthCache m_widthCache;
</span><span class="cx"> unsigned m_fontSelectorVersion;
</span><del>- int m_familyIndex;
</del><span class="cx"> unsigned short m_generation;
</span><del>- unsigned m_pitch : 3; // Pitch
- unsigned m_loadingCustomFonts : 1;
- unsigned m_isForPlatformFont : 1;
</del><ins>+ unsigned m_lastRealizedFamilyIndex { 0 };
+ Pitch m_pitch { UnknownPitch };
+ bool m_isForPlatformFont { false };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> inline bool FontGlyphs::isFixedPitch(const FontDescription& description)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoFontCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp (178179 => 178180)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp        2015-01-09 19:29:40 UTC (rev 178179)
+++ trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp        2015-01-09 19:33:40 UTC (rev 178180)
</span><span class="lines">@@ -292,7 +292,7 @@
</span><span class="cx">
</span><span class="cx"> DashArray Font::dashesForIntersectionsWithRect(const TextRun& run, const FloatPoint& textOrigin, const FloatRect& lineExtents) const
</span><span class="cx"> {
</span><del>- if (loadingCustomFonts())
</del><ins>+ if (isLoadingCustomFonts())
</ins><span class="cx"> return DashArray();
</span><span class="cx">
</span><span class="cx"> GlyphBuffer glyphBuffer;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsiosFontCacheIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm (178179 => 178180)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm        2015-01-09 19:29:40 UTC (rev 178179)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm        2015-01-09 19:33:40 UTC (rev 178180)
</span><span class="lines">@@ -446,7 +446,7 @@
</span><span class="cx"> return lastResortFallbackFont(description);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<SimpleFontData> FontCache::similarFontPlatformData(const FontDescription& description)
</del><ins>+RefPtr<SimpleFontData> FontCache::similarFontPlatformData(const FontDescription& description)
</ins><span class="cx"> {
</span><span class="cx"> // Attempt to find an appropriate font using a match based on the presence of keywords in
</span><span class="cx"> // the requested names. For example, we'll match any name that contains "Arabic" to Geeza Pro.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacFontCacheMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (178179 => 178180)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm        2015-01-09 19:29:40 UTC (rev 178179)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm        2015-01-09 19:33:40 UTC (rev 178180)
</span><span class="lines">@@ -405,7 +405,7 @@
</span><span class="cx"> return fontForPlatformData(alternateFont);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<SimpleFontData> FontCache::similarFontPlatformData(const FontDescription& description)
</del><ins>+RefPtr<SimpleFontData> FontCache::similarFontPlatformData(const FontDescription& description)
</ins><span class="cx"> {
</span><span class="cx"> // Attempt to find an appropriate font using a match based on
</span><span class="cx"> // the presence of keywords in the the requested names. For example, we'll
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacFontMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/FontMac.mm (178179 => 178180)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/FontMac.mm        2015-01-09 19:29:40 UTC (rev 178179)
+++ trunk/Source/WebCore/platform/graphics/mac/FontMac.mm        2015-01-09 19:33:40 UTC (rev 178180)
</span><span class="lines">@@ -528,7 +528,7 @@
</span><span class="cx">
</span><span class="cx"> DashArray Font::dashesForIntersectionsWithRect(const TextRun& run, const FloatPoint& textOrigin, const FloatRect& lineExtents) const
</span><span class="cx"> {
</span><del>- if (loadingCustomFonts())
</del><ins>+ if (isLoadingCustomFonts())
</ins><span class="cx"> return DashArray();
</span><span class="cx">
</span><span class="cx"> GlyphBuffer glyphBuffer;
</span></span></pre>
</div>
</div>
</body>
</html>