<!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>[51699] trunk/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/51699">51699</a></dd>
<dt>Author</dt> <dd>eric@webkit.org</dd>
<dt>Date</dt> <dd>2009-12-04 09:50:42 -0800 (Fri, 04 Dec 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>2009-12-04  Benjamin Poulain  &lt;benjamin.poulain@nokia.com&gt;

        Reviewed by Kenneth Rohde Christiansen.

        [Qt] WebKit crashes when loading certain SVG images
        https://bugs.webkit.org/show_bug.cgi?id=29443

        Remove FontFallbackListQt and rely on the common FontFallbackList
        to handle the fonts. FontCache and FontPlatformData have been
        updated to work with the common FontFallbackList.

        In the previous implementation, FontPlatformDataCacheKey
        was a clone of FontPlatformData with the hashing
        capabilities added in order to use it as a key in the cache's
        hashmap. FontPlatformData has been modified to handle the hashing
        function directly so the data are not copied twice in memory.

        FontFallbackList::fontDataAt() from FontFallbackListQt was a copy of
        code from FontCache::getFontData() and FontFallbackList::fontDataAt().
        The behavior is similar except currFamily-&gt;family().length() was
        not tested and the fallback fonts selector were not used.

        Existing tests cover the change.

        * WebCore.pro:
        * platform/graphics/qt/FontCacheQt.cpp:
        (WebCore::FontCache::platformInit):
        (WebCore::FontCache::getFontDataForCharacters):
        (WebCore::FontCache::getSimilarFontPlatformData):
        (WebCore::FontCache::getLastResortFallbackFont):
        (WebCore::FontCache::getTraitsInFamily):
        (WebCore::FontCache::createFontPlatformData):
        * platform/graphics/qt/FontCustomPlatformData.cpp:
        (WebCore::FontCustomPlatformData::fontPlatformData):
        * platform/graphics/qt/FontFallbackListQt.cpp:
        Removed. We now use the implementation from FontFallbackList.cpp
        * platform/graphics/qt/FontPlatformData.h:
        Add hashing capabilities to be able to use the data with the FontCache.
        This was previously done in FontCacheQt.cpp
        (WebCore::FontPlatformDataPrivate::FontPlatformDataPrivate):
        (WebCore::FontPlatformData::FontPlatformData):
        (WebCore::FontPlatformData::isHashTableDeletedValue):
        (WebCore::FontPlatformData::font):
        (WebCore::FontPlatformData::size):
        (WebCore::FontPlatformData::family):
        (WebCore::FontPlatformData::bold):
        (WebCore::FontPlatformData::italic):
        (WebCore::FontPlatformData::smallCaps):
        (WebCore::FontPlatformData::pixelSize):
        * platform/graphics/qt/FontPlatformDataQt.cpp:
        (WebCore::FontPlatformData::FontPlatformData):
        (WebCore::FontPlatformData::~FontPlatformData):
        (WebCore::FontPlatformData::operator=):
        (WebCore::FontPlatformData::operator==):
        (WebCore::FontPlatformData::hash):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreWebCorepro">trunk/WebCore/WebCore.pro</a></li>
<li><a href="#trunkWebCoreplatformgraphicsqtFontCacheQtcpp">trunk/WebCore/platform/graphics/qt/FontCacheQt.cpp</a></li>
<li><a href="#trunkWebCoreplatformgraphicsqtFontCustomPlatformDatacpp">trunk/WebCore/platform/graphics/qt/FontCustomPlatformData.cpp</a></li>
<li><a href="#trunkWebCoreplatformgraphicsqtFontPlatformDatah">trunk/WebCore/platform/graphics/qt/FontPlatformData.h</a></li>
<li><a href="#trunkWebCoreplatformgraphicsqtFontPlatformDataQtcpp">trunk/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkWebCoreplatformgraphicsqtFontFallbackListQtcpp">trunk/WebCore/platform/graphics/qt/FontFallbackListQt.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (51698 => 51699)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2009-12-04 17:43:29 UTC (rev 51698)
+++ trunk/WebCore/ChangeLog        2009-12-04 17:50:42 UTC (rev 51699)
</span><span class="lines">@@ -1,3 +1,59 @@
</span><ins>+2009-12-04  Benjamin Poulain  &lt;benjamin.poulain@nokia.com&gt;
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] WebKit crashes when loading certain SVG images
+        https://bugs.webkit.org/show_bug.cgi?id=29443
+
+        Remove FontFallbackListQt and rely on the common FontFallbackList
+        to handle the fonts. FontCache and FontPlatformData have been
+        updated to work with the common FontFallbackList.
+
+        In the previous implementation, FontPlatformDataCacheKey
+        was a clone of FontPlatformData with the hashing
+        capabilities added in order to use it as a key in the cache's
+        hashmap. FontPlatformData has been modified to handle the hashing
+        function directly so the data are not copied twice in memory.
+
+        FontFallbackList::fontDataAt() from FontFallbackListQt was a copy of
+        code from FontCache::getFontData() and FontFallbackList::fontDataAt().
+        The behavior is similar except currFamily-&gt;family().length() was
+        not tested and the fallback fonts selector were not used.
+
+        Existing tests cover the change.
+
+        * WebCore.pro:
+        * platform/graphics/qt/FontCacheQt.cpp:
+        (WebCore::FontCache::platformInit):
+        (WebCore::FontCache::getFontDataForCharacters):
+        (WebCore::FontCache::getSimilarFontPlatformData):
+        (WebCore::FontCache::getLastResortFallbackFont):
+        (WebCore::FontCache::getTraitsInFamily):
+        (WebCore::FontCache::createFontPlatformData):
+        * platform/graphics/qt/FontCustomPlatformData.cpp:
+        (WebCore::FontCustomPlatformData::fontPlatformData):
+        * platform/graphics/qt/FontFallbackListQt.cpp:
+        Removed. We now use the implementation from FontFallbackList.cpp
+        * platform/graphics/qt/FontPlatformData.h:
+        Add hashing capabilities to be able to use the data with the FontCache.
+        This was previously done in FontCacheQt.cpp
+        (WebCore::FontPlatformDataPrivate::FontPlatformDataPrivate):
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::isHashTableDeletedValue):
+        (WebCore::FontPlatformData::font):
+        (WebCore::FontPlatformData::size):
+        (WebCore::FontPlatformData::family):
+        (WebCore::FontPlatformData::bold):
+        (WebCore::FontPlatformData::italic):
+        (WebCore::FontPlatformData::smallCaps):
+        (WebCore::FontPlatformData::pixelSize):
+        * platform/graphics/qt/FontPlatformDataQt.cpp:
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::~FontPlatformData):
+        (WebCore::FontPlatformData::operator=):
+        (WebCore::FontPlatformData::operator==):
+        (WebCore::FontPlatformData::hash):
+
</ins><span class="cx"> 2009-12-04  Adam Treat  &lt;atreat@rim.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Dan Bernstein.
</span></span></pre></div>
<a id="trunkWebCoreWebCorepro"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/WebCore.pro (51698 => 51699)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/WebCore.pro        2009-12-04 17:43:29 UTC (rev 51698)
+++ trunk/WebCore/WebCore.pro        2009-12-04 17:50:42 UTC (rev 51699)
</span><span class="lines">@@ -1195,6 +1195,7 @@
</span><span class="cx">     platform/image-decoders/qt/RGBA32BufferQt.cpp \
</span><span class="cx">     platform/graphics/filters/FEGaussianBlur.cpp \
</span><span class="cx">     platform/graphics/FontDescription.cpp \
</span><ins>+    platform/graphics/FontFallbackList.cpp \
</ins><span class="cx">     platform/graphics/FontFamily.cpp \
</span><span class="cx">     platform/graphics/BitmapImage.cpp \
</span><span class="cx">     platform/graphics/Color.cpp \
</span><span class="lines">@@ -1205,6 +1206,7 @@
</span><span class="cx">     platform/graphics/FloatSize.cpp \
</span><span class="cx">     platform/graphics/FontData.cpp \
</span><span class="cx">     platform/graphics/Font.cpp \
</span><ins>+    platform/graphics/FontCache.cpp \
</ins><span class="cx">     platform/graphics/GeneratedImage.cpp \
</span><span class="cx">     platform/graphics/Gradient.cpp \
</span><span class="cx">     platform/graphics/GraphicsContext.cpp \
</span><span class="lines">@@ -2392,7 +2394,6 @@
</span><span class="cx">     platform/qt/SharedBufferQt.cpp \
</span><span class="cx">     platform/graphics/qt/FontCacheQt.cpp \
</span><span class="cx">     platform/graphics/qt/FontCustomPlatformData.cpp \
</span><del>-    platform/graphics/qt/FontFallbackListQt.cpp \
</del><span class="cx">     platform/graphics/qt/GlyphPageTreeNodeQt.cpp \
</span><span class="cx">     platform/graphics/qt/SimpleFontDataQt.cpp \
</span><span class="cx">     platform/qt/KURLQt.cpp \
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsqtFontCacheQtcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/qt/FontCacheQt.cpp (51698 => 51699)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/qt/FontCacheQt.cpp        2009-12-04 17:43:29 UTC (rev 51698)
+++ trunk/WebCore/platform/graphics/qt/FontCacheQt.cpp        2009-12-04 17:50:42 UTC (rev 51699)
</span><span class="lines">@@ -38,256 +38,33 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-FontCache* fontCache()
</del><ins>+void FontCache::platformInit()
</ins><span class="cx"> {
</span><del>-    DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ());
-    return &amp;globalFontCache;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-FontCache::FontCache()
</del><ins>+const SimpleFontData* FontCache::getFontDataForCharacters(const Font&amp;, const UChar*, int)
</ins><span class="cx"> {
</span><del>-}
-
-void FontCache::getTraitsInFamily(const AtomicString&amp;, Vector&lt;unsigned&gt;&amp;)
-{
-}
-
-// This type must be consistent with FontPlatformData's ctor - the one which
-// gets FontDescription as it's parameter.
-class FontPlatformDataCacheKey {
-public:
-    FontPlatformDataCacheKey(const FontDescription&amp; description)
-        : m_familyName()
-        , m_size(description.computedPixelSize())
-        , m_bold(false)
-        , m_italic(description.italic())
-        , m_smallCaps(description.smallCaps())
-        , m_hash(0)
-    {
-        // FIXME: Map all FontWeight values to QFont weights in FontPlatformData's ctor and follow it here
-        if (FontPlatformData::toQFontWeight(description.weight()) &gt; QFont::Normal)
-            m_bold = true;
-
-        const FontFamily* family = &amp;description.family();
-        while (family) {
-            m_familyName.append(family-&gt;family());
-            family = family-&gt;next();
-            if (family)
-                m_familyName.append(',');
-        }
-
-        computeHash();
-    }
-
-    FontPlatformDataCacheKey(const FontPlatformData&amp; fontData)
-        : m_familyName(static_cast&lt;String&gt;(fontData.family()))
-        , m_size(fontData.pixelSize())
-        , m_bold(fontData.bold())
-        , m_italic(fontData.italic())
-        , m_smallCaps(fontData.smallCaps())
-        , m_hash(0)
-    {
-        computeHash();
-    }
-
-    FontPlatformDataCacheKey(HashTableDeletedValueType) : m_size(hashTableDeletedSize()) { }
-    bool isHashTableDeletedValue() const { return m_size == hashTableDeletedSize(); }
-
-    enum HashTableEmptyValueType { HashTableEmptyValue };
-
-    FontPlatformDataCacheKey(HashTableEmptyValueType)
-        : m_familyName()
-        , m_size(0)
-        , m_bold(false)
-        , m_italic(false)
-        , m_smallCaps(false)
-        , m_hash(0)
-    {
-    }
-
-    bool operator==(const FontPlatformDataCacheKey&amp; other) const
-    {
-        if (m_hash != other.m_hash)
-            return false;
-
-        return equalIgnoringCase(m_familyName, other.m_familyName) &amp;&amp; m_size == other.m_size &amp;&amp;
-            m_bold == other.m_bold &amp;&amp; m_italic == other.m_italic &amp;&amp; m_smallCaps == other.m_smallCaps;
-    }
-
-    unsigned hash() const
-    {
-        return m_hash;
-    }
-
-    void computeHash()
-    {
-        unsigned hashCodes[] = {
-            CaseFoldingHash::hash(m_familyName),
-            m_size | static_cast&lt;unsigned&gt;(m_bold &lt;&lt; (sizeof(unsigned) * 8 - 1))
-                | static_cast&lt;unsigned&gt;(m_italic) &lt;&lt; (sizeof(unsigned) * 8 - 2)
-                | static_cast&lt;unsigned&gt;(m_smallCaps) &lt;&lt; (sizeof(unsigned) * 8 - 3)
-        };
-        m_hash = StringImpl::computeHash(reinterpret_cast&lt;UChar*&gt;(hashCodes), sizeof(hashCodes) / sizeof(UChar));
-    }
-
-private:
-    String m_familyName;
-    int m_size;
-    bool m_bold;
-    bool m_italic;
-    bool m_smallCaps;
-    unsigned m_hash;
-
-    static unsigned hashTableDeletedSize() { return 0xFFFFFFFFU; }
-};
-
-struct FontPlatformDataCacheKeyHash {
-    static unsigned hash(const FontPlatformDataCacheKey&amp; key)
-    {
-        return key.hash();
-    }
-
-    static bool equal(const FontPlatformDataCacheKey&amp; a, const FontPlatformDataCacheKey&amp; b)
-    {
-        return a == b;
-    }
-
-    static const bool safeToCompareToEmptyOrDeleted = true;
-};
-
-struct FontPlatformDataCacheKeyTraits : WTF::GenericHashTraits&lt;FontPlatformDataCacheKey&gt; {
-    static const bool needsDestruction = true;
-    static const FontPlatformDataCacheKey&amp; emptyValue()
-    {
-        DEFINE_STATIC_LOCAL(FontPlatformDataCacheKey, key, (FontPlatformDataCacheKey::HashTableEmptyValue));
-        return key;
-    }
-    static void constructDeletedValue(FontPlatformDataCacheKey&amp; slot)
-    {
-        new (&amp;slot) FontPlatformDataCacheKey(HashTableDeletedValue);
-    }
-    static bool isDeletedValue(const FontPlatformDataCacheKey&amp; value)
-    {
-        return value.isHashTableDeletedValue();
-    }
-};
-
-typedef HashMap&lt;FontPlatformDataCacheKey, FontPlatformData*, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyTraits&gt; FontPlatformDataCache;
-
-// using Q_GLOBAL_STATIC leads to crash. TODO investigate the way to fix this.
-static FontPlatformDataCache* gFontPlatformDataCache = 0;
-
-FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription&amp; description, const AtomicString&amp;, bool)
-{
-    if (!gFontPlatformDataCache)
-        gFontPlatformDataCache = new FontPlatformDataCache;
-
-    FontPlatformDataCacheKey key(description);
-    FontPlatformData* platformData = gFontPlatformDataCache-&gt;get(key);
-    if (!platformData) {
-        platformData = new FontPlatformData(description);
-        gFontPlatformDataCache-&gt;add(key, platformData);
-    }
-    return platformData;
-}
-
-typedef HashMap&lt;FontPlatformDataCacheKey, std::pair&lt;SimpleFontData*, unsigned&gt;, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyTraits&gt; FontDataCache;
-
-static FontDataCache* gFontDataCache = 0;
-
-static const int cMaxInactiveFontData = 40;
-static const int cTargetInactiveFontData = 32;
-
-static ListHashSet&lt;const SimpleFontData*&gt;* gInactiveFontDataSet = 0;
-
-SimpleFontData* FontCache::getCachedFontData(const FontPlatformData* fontPlatformData)
-{
-    if (!gFontDataCache) {
-        gFontDataCache = new FontDataCache;
-        gInactiveFontDataSet = new ListHashSet&lt;const SimpleFontData*&gt;;
-    }
-
-    FontPlatformDataCacheKey key(*fontPlatformData);
-    FontDataCache::iterator it = gFontDataCache-&gt;find(key);
-    if (it == gFontDataCache-&gt;end()) {
-        SimpleFontData* fontData = new SimpleFontData(*fontPlatformData);
-        gFontDataCache-&gt;add(key, std::pair&lt;SimpleFontData*, unsigned&gt;(fontData, 1));
-        return fontData;
-    }
-    if (!it-&gt;second.second++) {
-        ASSERT(gInactiveFontDataSet-&gt;contains(it-&gt;second.first));
-        gInactiveFontDataSet-&gt;remove(it-&gt;second.first);
-    }
-    return it-&gt;second.first;
-}
-
-FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription&amp;)
-{
</del><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FontCache::releaseFontData(const WebCore::SimpleFontData* fontData)
</del><ins>+FontPlatformData* FontCache::getSimilarFontPlatformData(const Font&amp; font)
</ins><span class="cx"> {
</span><del>-    ASSERT(gFontDataCache);
-    ASSERT(!fontData-&gt;isCustomFont());
-
-    FontPlatformDataCacheKey key(fontData-&gt;platformData());
-    FontDataCache::iterator it = gFontDataCache-&gt;find(key);
-    ASSERT(it != gFontDataCache-&gt;end());
-    if (!--it-&gt;second.second) {
-        gInactiveFontDataSet-&gt;add(it-&gt;second.first);
-        if (gInactiveFontDataSet-&gt;size() &gt; cMaxInactiveFontData)
-            purgeInactiveFontData(gInactiveFontDataSet-&gt;size() - cTargetInactiveFontData);
-    }
</del><ins>+    return new FontPlatformData(font.fontDescription());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FontCache::purgeInactiveFontData(int count)
</del><ins>+FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription&amp; fontDescription)
</ins><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;
-
-    ListHashSet&lt;const SimpleFontData*&gt;::iterator it = gInactiveFontDataSet-&gt;begin();
-    ListHashSet&lt;const SimpleFontData*&gt;::iterator end = gInactiveFontDataSet-&gt;end();
-    for (int i = 0; i &lt; count &amp;&amp; it != end; ++i, ++it) {
-        FontPlatformDataCacheKey key = (*it)-&gt;platformData();
-        pair&lt;SimpleFontData*, unsigned&gt; fontDataPair = gFontDataCache-&gt;take(key);
-        ASSERT(fontDataPair.first != 0);
-        ASSERT(!fontDataPair.second);
-        delete fontDataPair.first;
-
-        FontPlatformData* platformData = gFontPlatformDataCache-&gt;take(key);
-        if (platformData)
-            delete platformData;
-    }
-
-    if (it == end) {
-        // Removed everything
-        gInactiveFontDataSet-&gt;clear();
-    } else {
-        for (int i = 0; i &lt; count; ++i)
-            gInactiveFontDataSet-&gt;remove(gInactiveFontDataSet-&gt;begin());
-    }
-
-    isPurging = false;
</del><ins>+    return new FontPlatformData(fontDescription);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FontCache::addClient(FontSelector*)
</del><ins>+void FontCache::getTraitsInFamily(const AtomicString&amp;, Vector&lt;unsigned&gt;&amp;)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FontCache::removeClient(FontSelector*)
</del><ins>+FontPlatformData* FontCache::createFontPlatformData(const FontDescription&amp; fontDescription, const AtomicString&amp;)
</ins><span class="cx"> {
</span><ins>+    // FIXME : we must take into account the familly name (second argument)
+    return new FontPlatformData(fontDescription);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FontCache::invalidate()
-{
-    if (!gFontPlatformDataCache || !gFontDataCache)
-        return;
-
-    purgeInactiveFontData();
-}
-
</del><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsqtFontCustomPlatformDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/qt/FontCustomPlatformData.cpp (51698 => 51699)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/qt/FontCustomPlatformData.cpp        2009-12-04 17:43:29 UTC (rev 51698)
+++ trunk/WebCore/platform/graphics/qt/FontCustomPlatformData.cpp        2009-12-04 17:50:42 UTC (rev 51699)
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx">         font.setWeight(QFont::Bold);
</span><span class="cx">     font.setItalic(italic);
</span><span class="cx"> 
</span><del>-    return FontPlatformData(font, bold);
</del><ins>+    return FontPlatformData(font);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsqtFontFallbackListQtcpp"></a>
<div class="delfile"><h4>Deleted: trunk/WebCore/platform/graphics/qt/FontFallbackListQt.cpp (51698 => 51699)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/qt/FontFallbackListQt.cpp        2009-12-04 17:43:29 UTC (rev 51698)
+++ trunk/WebCore/platform/graphics/qt/FontFallbackListQt.cpp        2009-12-04 17:50:42 UTC (rev 51699)
</span><span class="lines">@@ -1,138 +0,0 @@
</span><del>-/*
-    Copyright (C) 2008 Holger Hans Peter Freyther
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-
-    Replacement of the stock FontFallbackList as Qt is going to find us a
-    replacement font, will do caching and the other stuff we implement in
-    WebKit.
-*/
-
-#include &quot;config.h&quot;
-#include &quot;FontFallbackList.h&quot;
-
-#include &quot;Font.h&quot;
-#include &quot;FontCache.h&quot;
-#include &quot;SegmentedFontData.h&quot;
-
-#include &lt;QDebug&gt;
-
-namespace WebCore {
-
-FontFallbackList::FontFallbackList()
-    : m_pageZero(0)
-    , m_cachedPrimarySimpleFontData(0)
-    , m_fontSelector(0)
-    , m_familyIndex(0)
-    , m_pitch(UnknownPitch)
-    , m_loadingCustomFonts(false)
-    , m_generation(0)
-{
-}
-
-void FontFallbackList::invalidate(WTF::PassRefPtr&lt;WebCore::FontSelector&gt; fontSelector)
-{
-    releaseFontData();
-    m_fontList.clear();
-    m_pageZero = 0;
-    m_pages.clear();
-    m_cachedPrimarySimpleFontData = 0;
-    m_familyIndex = 0;
-    m_pitch = UnknownPitch;
-    m_loadingCustomFonts = false;
-    m_fontSelector = fontSelector;
-    m_generation = 0;
-}
-
-void FontFallbackList::releaseFontData()
-{
-    unsigned numFonts = m_fontList.size();
-    for (unsigned i = 0; i &lt; numFonts; ++i) {
-        if (m_fontList[i].second)
-            delete m_fontList[i].first;
-        else {
-            ASSERT(!m_fontList[i].first-&gt;isSegmented());
-            fontCache()-&gt;releaseFontData(static_cast&lt;const SimpleFontData*&gt;(m_fontList[i].first));
-        }
-    }
-}
-
-void FontFallbackList::determinePitch(const WebCore::Font* font) const
-{
-    const FontData* fontData = primaryFontData(font);
-    if (!fontData-&gt;isSegmented())
-        m_pitch = static_cast&lt;const SimpleFontData*&gt;(fontData)-&gt;pitch();
-    else {
-        const SegmentedFontData* segmentedFontData = static_cast&lt;const SegmentedFontData*&gt;(fontData);
-        unsigned numRanges = segmentedFontData-&gt;numRanges();
-        if (numRanges == 1)
-            m_pitch = segmentedFontData-&gt;rangeAt(0).fontData()-&gt;pitch();
-        else
-            m_pitch = VariablePitch;
-    }
-}
-
-const FontData* FontFallbackList::fontDataAt(const WebCore::Font* _font, unsigned index) const
-{
-    if (index != 0)
-        return 0;
-
-    // Search for the WebCore font that is already in the list
-    for (int i = m_fontList.size() - 1; i &gt;= 0; --i) {
-        pair&lt;const FontData*, bool&gt; item = m_fontList[i];
-        // item.second means that the item was created locally or not
-        if (!item.second)
-            return item.first;
-    }
-
-    // Use the FontSelector to get a WebCore font and then fallback to Qt
-    const FontDescription&amp; description = _font-&gt;fontDescription();
-    const FontFamily* family = &amp;description.family();
-    while (family) {
-        if (family-&gt;family().length() &amp;&amp; m_fontSelector) {
-            FontData* data = m_fontSelector-&gt;getFontData(description, family-&gt;family());
-            if (data) {
-                if (data-&gt;isLoading())
-                    m_loadingCustomFonts = true;
-                if (!data-&gt;isCustomFont()) {
-                    // Custom fonts can be freed anytime so we must not hold them
-                    m_fontList.append(pair&lt;const FontData*, bool&gt;(data, false));
-                }
-                return data;
-            }
-        }
-        family = family-&gt;next();
-    }
-
-    if (m_fontList.size())
-        return m_fontList[0].first;
-
-    const FontData* result = new SimpleFontData(FontPlatformData(description, _font-&gt;wordSpacing(), _font-&gt;letterSpacing()), true);
-    m_fontList.append(pair&lt;const FontData*, bool&gt;(result, true));
-    return result;
-}
-
-const FontData* FontFallbackList::fontDataForCharacters(const WebCore::Font* font, const UChar*, int) const
-{
-    return primaryFontData(font);
-}
-
-void FontFallbackList::setPlatformFont(const WebCore::FontPlatformData&amp;)
-{
-    m_familyIndex = cAllFamiliesScanned;
-}
-
-}
</del></span></pre></div>
<a id="trunkWebCoreplatformgraphicsqtFontPlatformDatah"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/qt/FontPlatformData.h (51698 => 51699)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/qt/FontPlatformData.h        2009-12-04 17:43:29 UTC (rev 51698)
+++ trunk/WebCore/platform/graphics/qt/FontPlatformData.h        2009-12-04 17:50:42 UTC (rev 51699)
</span><span class="lines">@@ -26,21 +26,63 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;FontDescription.h&quot;
</span><span class="cx"> #include &lt;QFont&gt;
</span><ins>+#include &lt;QHash&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class String;
</span><ins>+class FontPlatformDataPrivate {
+public:
+    FontPlatformDataPrivate()
+        : refCount(1)
+        , size(font.pointSizeF())
+        , bold(font.bold())
+        , oblique(false)
+    {}
+    FontPlatformDataPrivate(const float size, const bool bold, const bool oblique)
+        : refCount(1)
+        , size(size)
+        , bold(bold)
+        , oblique(oblique)
+    {}
+    FontPlatformDataPrivate(const QFont&amp; font)
+        : refCount(1)
+        , font(font)
+        , size(font.pointSizeF())
+        , bold(font.bold())
+        , oblique(false)
+    {}
+    unsigned refCount;
+    QFont font;
+    float size;
+    bool bold : 1;
+    bool oblique : 1;
+};
</ins><span class="cx"> 
</span><del>-class FontPlatformData : public FastAllocBase
-{
</del><ins>+
+
+class FontPlatformData : public FastAllocBase {
</ins><span class="cx"> public:
</span><del>-#if ENABLE(SVG_FONTS)
</del><span class="cx">     FontPlatformData(float size, bool bold, bool oblique);
</span><del>-#endif
-    FontPlatformData();
</del><ins>+    FontPlatformData(const FontPlatformData &amp;);
</ins><span class="cx">     FontPlatformData(const FontDescription&amp;, int wordSpacing = 0, int letterSpacing = 0);
</span><del>-    FontPlatformData(const QFont&amp;, bool bold);
</del><ins>+    FontPlatformData(const QFont&amp; font)
+        : m_data(new FontPlatformDataPrivate(font))
+    {}
+    FontPlatformData(WTF::HashTableDeletedValueType)
+        : m_data(reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1))
+    {}
</ins><span class="cx"> 
</span><ins>+    ~FontPlatformData();
+
+    FontPlatformData&amp; operator=(const FontPlatformData&amp;);
+    bool operator==(const FontPlatformData&amp;) const;
+
+    bool isHashTableDeletedValue() const
+    {
+        return m_data == reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1);
+    }
+
</ins><span class="cx">     static inline QFont::Weight toQFontWeight(FontWeight fontWeight)
</span><span class="cx">     {
</span><span class="cx">         switch (fontWeight) {
</span><span class="lines">@@ -62,22 +104,62 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    QFont font() const { return m_font; }
-    float size() const { return m_size; }
-    QString family() const { return m_font.family(); }
-    bool bold() const { return m_bold; }
-    bool italic() const { return m_font.italic(); }
-    bool smallCaps() const { return m_font.capitalization() == QFont::SmallCaps; }
-    int pixelSize() const { return m_font.pixelSize(); }
</del><ins>+    QFont font() const
+    {
+        Q_ASSERT(m_data != reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1));
+        if (m_data)
+            return m_data-&gt;font;
+        return QFont();
+    }
+    float size() const
+    {
+        Q_ASSERT(m_data != reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1));
+        if (m_data)
+            return m_data-&gt;size;
+        return 0.0f;
+    }
+    QString family() const
+    {
+        Q_ASSERT(m_data != reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1));
+        if (m_data)
+            return m_data-&gt;font.family();
+        return QString();
+    }
+    bool bold() const
+    {
+        Q_ASSERT(m_data != reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1));
+        if (m_data)
+            return m_data-&gt;bold;
+        return false;
+    }
+    bool italic() const
+    {
+        Q_ASSERT(m_data != reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1));
+        if (m_data)
+            return m_data-&gt;font.italic();
+        return false;
+    }
+    bool smallCaps() const
+    {
+        Q_ASSERT(m_data != reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1));
+        if (m_data)
+            return m_data-&gt;font.capitalization() == QFont::SmallCaps;
+        return false;
+    }
+    int pixelSize() const
+    {
+        Q_ASSERT(m_data != reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1));
+        if (m_data)
+            return m_data-&gt;font.pixelSize();
+        return 0;
+    }
+    unsigned hash() const;
</ins><span class="cx"> 
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     String description() const;
</span><span class="cx"> #endif
</span><del>-
-    float m_size;
-    bool m_bold;
-    bool m_oblique;
-    QFont m_font;
</del><ins>+private:
+    FontPlatformDataPrivate* m_data;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsqtFontPlatformDataQtcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp (51698 => 51699)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp        2009-12-04 17:43:29 UTC (rev 51698)
+++ trunk/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp        2009-12-04 17:50:42 UTC (rev 51699)
</span><span class="lines">@@ -26,10 +26,28 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static inline bool isEmtpyValue(const float size, const bool bold, const bool oblique)
+{
+     // this is the empty value by definition of the trait FontDataCacheKeyTraits
+    return !bold &amp;&amp; !oblique &amp;&amp; size == 0.f;
+}
+
+FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
+{
+    if (isEmtpyValue(size, bold, oblique))
+        m_data = 0;
+    else
+        m_data = new FontPlatformDataPrivate(size, bold, oblique);
+}
+
+FontPlatformData::FontPlatformData(const FontPlatformData &amp;other) : m_data(other.m_data)
+{
+    if (m_data &amp;&amp; m_data != reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1))
+        ++m_data-&gt;refCount;
+}
+
</ins><span class="cx"> FontPlatformData::FontPlatformData(const FontDescription&amp; description, int wordSpacing, int letterSpacing)
</span><del>-    : m_size(0.0f)
-    , m_bold(false)
-    , m_oblique(false)
</del><ins>+    : m_data(new FontPlatformDataPrivate())
</ins><span class="cx"> {
</span><span class="cx">     QString familyName;
</span><span class="cx">     const FontFamily* family = &amp;description.family();
</span><span class="lines">@@ -39,43 +57,70 @@
</span><span class="cx">         if (family)
</span><span class="cx">             familyName += QLatin1Char(',');
</span><span class="cx">     }
</span><ins>+    QFont&amp; font = m_data-&gt;font;
+    font.setFamily(familyName);
+    font.setPixelSize(qRound(description.computedSize()));
+    font.setItalic(description.italic());
+    font.setWeight(toQFontWeight(description.weight()));
+    font.setWordSpacing(wordSpacing);
+    font.setLetterSpacing(QFont::AbsoluteSpacing, letterSpacing);
+    const bool smallCaps = description.smallCaps();
+    font.setCapitalization(smallCaps ? QFont::SmallCaps : QFont::MixedCase);
</ins><span class="cx"> 
</span><del>-    m_font.setFamily(familyName);
-    m_font.setPixelSize(qRound(description.computedSize()));
-    m_font.setItalic(description.italic());
</del><ins>+    m_data-&gt;bold = font.bold();
+    m_data-&gt;size = font.pointSizeF();
+}
</ins><span class="cx"> 
</span><del>-    m_font.setWeight(toQFontWeight(description.weight()));
-    m_bold = m_font.bold();
-
-    bool smallCaps = description.smallCaps();
-    m_font.setCapitalization(smallCaps ? QFont::SmallCaps : QFont::MixedCase);
-    m_font.setWordSpacing(wordSpacing);
-    m_font.setLetterSpacing(QFont::AbsoluteSpacing, letterSpacing);
-    m_size = m_font.pointSize();
</del><ins>+FontPlatformData::~FontPlatformData()
+{
+    if (!m_data || m_data == reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1))
+        return;
+    --m_data-&gt;refCount;
+    if (!m_data-&gt;refCount)
+        delete m_data;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-FontPlatformData::FontPlatformData(const QFont&amp; font, bool bold)
-    : m_size(font.pointSize())
-    , m_bold(bold)
-    , m_oblique(false)
-    , m_font(font)
</del><ins>+FontPlatformData&amp; FontPlatformData::operator=(const FontPlatformData&amp; other)
</ins><span class="cx"> {
</span><ins>+    if (m_data == other.m_data)
+        return *this;
+    if (m_data &amp;&amp; m_data != reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1)) {
+        --m_data-&gt;refCount;
+        if (!m_data-&gt;refCount)
+            delete m_data;
+    }
+    m_data = other.m_data;
+    if (m_data &amp;&amp; m_data != reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1))
+        ++m_data-&gt;refCount;
+    return *this;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if ENABLE(SVG_FONTS)
-FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
-    : m_size(size)
-    , m_bold(bold)
-    , m_oblique(oblique)
</del><ins>+bool FontPlatformData::operator==(const FontPlatformData&amp; other) const
</ins><span class="cx"> {
</span><ins>+    if (m_data == other.m_data)
+        return true;
+
+    if (!m_data || !other.m_data
+        || m_data == reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1) || other.m_data == reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1))
+        return  false;
+
+    const bool equals = (m_data-&gt;size == other.m_data-&gt;size
+                         &amp;&amp; m_data-&gt;bold == other.m_data-&gt;bold
+                         &amp;&amp; m_data-&gt;oblique == other.m_data-&gt;oblique
+                         &amp;&amp; m_data-&gt;font == other.m_data-&gt;font);
+    return equals;
</ins><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><del>-FontPlatformData::FontPlatformData()
-    : m_size(0.0f)
-    , m_bold(false)
-    , m_oblique(false)
</del><ins>+unsigned FontPlatformData::hash() const
</ins><span class="cx"> {
</span><ins>+    if (!m_data)
+        return 0;
+    if (m_data == reinterpret_cast&lt;FontPlatformDataPrivate*&gt;(-1))
+        return 1;
+    return qHash(m_data-&gt;font.toString())
+           ^ qHash(*reinterpret_cast&lt;quint32*&gt;(&amp;m_data-&gt;size))
+           ^ qHash(m_data-&gt;bold)
+           ^ qHash(m_data-&gt;oblique);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #ifndef NDEBUG
</span></span></pre>
</div>
</div>

</body>
</html>