| Index: third_party/WebKit/Source/platform/fonts/FontDataCache.cpp
|
| diff --git a/third_party/WebKit/Source/platform/fonts/FontDataCache.cpp b/third_party/WebKit/Source/platform/fonts/FontDataCache.cpp
|
| index 4bf5a2c28fc4bb51710f122a8309305dc81fc557..27a18526f0e478cdbdd879ea296dc966a7e2cfec 100644
|
| --- a/third_party/WebKit/Source/platform/fonts/FontDataCache.cpp
|
| +++ b/third_party/WebKit/Source/platform/fonts/FontDataCache.cpp
|
| @@ -57,10 +57,13 @@ PassRefPtr<SimpleFontData> FontDataCache::get(const FontPlatformData* platformDa
|
| return nullptr;
|
| }
|
|
|
| - Cache::iterator result = m_cache.find(*platformData);
|
| + Cache::iterator result = m_cache.find(platformData);
|
| if (result == m_cache.end()) {
|
| std::pair<RefPtr<SimpleFontData>, unsigned> newValue(SimpleFontData::create(*platformData), shouldRetain == Retain ? 1 : 0);
|
| - m_cache.set(*platformData, newValue);
|
| + // The new SimpleFontData takes a copy of the incoming FontPlatformData object. The incoming key may be
|
| + // temporary. So, for cache storage, take the address of the newly created FontPlatformData that is copied an
|
| + // owned by SimpleFontData.
|
| + m_cache.set(&newValue.first->platformData(), newValue);
|
| if (shouldRetain == DoNotRetain)
|
| m_inactiveFontData.add(newValue.first);
|
| return newValue.first.release();
|
| @@ -84,14 +87,14 @@ PassRefPtr<SimpleFontData> FontDataCache::get(const FontPlatformData* platformDa
|
|
|
| bool FontDataCache::contains(const FontPlatformData* fontPlatformData) const
|
| {
|
| - return m_cache.contains(*fontPlatformData);
|
| + return m_cache.contains(fontPlatformData);
|
| }
|
|
|
| void FontDataCache::release(const SimpleFontData* fontData)
|
| {
|
| ASSERT(!fontData->isCustomFont());
|
|
|
| - Cache::iterator it = m_cache.find(fontData->platformData());
|
| + Cache::iterator it = m_cache.find(&(fontData->platformData()));
|
| ASSERT(it != m_cache.end());
|
| if (it == m_cache.end())
|
| return;
|
| @@ -135,7 +138,7 @@ bool FontDataCache::purgeLeastRecentlyUsed(int count)
|
| ListHashSet<RefPtr<SimpleFontData>>::iterator it = m_inactiveFontData.begin();
|
| for (int i = 0; i < count && it != end; ++it, ++i) {
|
| RefPtr<SimpleFontData>& fontData = *it.get();
|
| - m_cache.remove(fontData->platformData());
|
| + m_cache.remove(&(fontData->platformData()));
|
| // We should not delete SimpleFontData here because deletion can modify m_inactiveFontData. See http://trac.webkit.org/changeset/44011
|
| fontDataToDelete.append(fontData);
|
| }
|
|
|