のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

SimpleFontData::create

 303 PassRefPtr<SimpleFontData> FontCache::getFontResourceData(const FontPlatformData* platformData, ShouldRetain shouldRetain)
    304 {
    305     if (!platformData)
    306         return 0;
    307 
    308 #if !ASSERT_DISABLED
    309     if (shouldRetain == DoNotRetain)
    310         ASSERT(m_purgePreventCount);
    311 #endif
    312 
    313     if (!gFontDataCache) {
    314         gFontDataCache = new FontDataCache;
    315         gInactiveFontData = new ListHashSet<RefPtr<SimpleFontData> >;
    316     }
    317 
    318     FontDataCache::iterator result = gFontDataCache->find(*platformData);
    319     if (result == gFontDataCache->end()) { <=== endまで行った=platformDataがない
    320         pair<RefPtr<SimpleFontData>, unsigned> newValue(SimpleFontData::create(*platformData), shouldRetain == Retain ? 1 : 0);
    321         gFontDataCache->set(*platformData, newValue);
    322         if (shouldRetain == DoNotRetain)
    323             gInactiveFontData->add(newValue.first);
    324         return newValue.first.release();
    325     }
    326 
    327     if (!result.get()->value.second) {
    328         ASSERT(gInactiveFontData->contains(result.get()->value.first));
    329         gInactiveFontData->remove(result.get()->value.first);
    330     }
    331 
    332     if (shouldRetain == Retain)
    333         result.get()->value.second++;
    334     else if (!result.get()->value.second) {
    335         // If shouldRetain is DoNotRetain and count is 0, we want to remove the fontData from
    336         // gInactiveFontData (above) and re-add here to update LRU position.
    337         gInactiveFontData->add(result.get()->value.first);
    338     }
    339 
    340     return result.get()->value.first;
    341 }