update
Searched font.update
アップデートでフォントデータのキャッシュから無効リストへ追加する
165 void Font::update(PassRefPtr<FontSelector> fontSelector) const 166 { 167 // FIXME: It is pretty crazy that we are willing to just poke into a RefPtr, but it ends up 168 // being reasonably safe (because inherited fonts in the render tree pick up the new 169 // style anyway. Other copies are transient, e.g., the state in the GraphicsContext, and 170 // won't stick around long enough to get you in trouble). Still, this is pretty disgusting, 171 // and could eventually be rectified by using RefPtrs for Fonts themselves. 172 if (!m_fontFallbackList) 173 m_fontFallbackList = FontFallbackList::create(); 174 m_fontFallbackList->invalidate(fontSelector); <======== 175 m_typesettingFeatures = computeTypesettingFeatures(); 176 }
49 void FontFallbackList::invalidate(PassRefPtr<FontSelector> fontSelector) 50 { 51 releaseFontData(); <========== 52 m_fontList.clear(); 53 m_pageZero = 0; 54 m_pages.clear(); 55 m_cachedPrimarySimpleFontData = 0; 56 m_familyIndex = 0; 57 m_pitch = UnknownPitch; 58 m_loadingCustomFonts = false; 59 m_fontSelector = fontSelector; 60 m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0; 61 m_generation = fontCache()->generation(); 62 m_widthCache.clear(); 63 }
65 void FontFallbackList::releaseFontData() 66 { 67 unsigned numFonts = m_fontList.size(); 68 for (unsigned i = 0; i < numFonts; ++i) { 69 if (!m_fontList[i]->isCustomFont()) { 70 ASSERT(!m_fontList[i]->isSegmented()); 71 fontCache()->releaseFontData(static_cast<const SimpleFontData*>(m_fontList[i].get())); <===== 72 } 73 } 74 }
348 void FontCache::releaseFontData(const SimpleFontData* fontData) 349 { 350 ASSERT(gFontDataCache); 351 ASSERT(!fontData->isCustomFont()); 352 353 FontDataCache::iterator it = gFontDataCache->find(fontData->platformData()); fontDataからfontDataCacheを見つける。 354 ASSERT(it != gFontDataCache->end()); 355 if (it == gFontDataCache->end()) fontDataCacheにない。 356 return; 357 358 ASSERT(it->value.second); 359 if (!--it->value.second) プレデクリメントして、2番めの値が0でない場合、 360 gInactiveFontData->add(it->value.first); gInactiveFontDataへ追加する。あとで処理するのかな? 361 }
281 typedef HashMap< FontPlatformData, 1番目 pair<RefPtr<SimpleFontData>, unsigned>, 2番目 FontDataCacheKeyHash, 3番目 FontDataCacheKeyTraits> FontDataCache; 4番目
369 void FontCache::purgeInactiveFontData(int count) 370 { 371 if (!gInactiveFontData || m_purgePreventCount) 372 return; 373 374 static bool isPurging; // Guard against reentry when e.g. a deleted FontData releases its small caps FontData. 375 if (isPurging) 376 return; 377 378 isPurging = true; 379 380 Vector<RefPtr<SimpleFontData>, 20> fontDataToDelete; 381 ListHashSet<RefPtr<SimpleFontData> >::iterator end = gInactiveFontData->end(); 382 ListHashSet<RefPtr<SimpleFontData> >::iterator it = gInactiveFontData->begin(); 383 for (int i = 0; i < count && it != end; ++it, ++i) { 384 RefPtr<SimpleFontData>& fontData = *it.get(); 385 gFontDataCache->remove(fontData->platformData()); <============リムーブしてるとこ 386 // We should not delete SimpleFontData here because deletion can modify gInactiveFontData. See http://trac.webkit.org/changeset/44011 387 fontDataToDelete.append(fontData); 388 } 389 390 if (it == end) { 391 // Removed everything 392 gInactiveFontData->clear(); 393 } else { 394 for (int i = 0; i < count; ++i) 395 gInactiveFontData->remove(gInactiveFontData->begin()); 396 } 397 398 fontDataToDelete.clear(); 399 400 if (gFontPlatformDataCache) { 401 Vector<FontPlatformDataCacheKey> keysToRemove; 402 keysToRemove.reserveInitialCapacity(gFontPlatformDataCache->size()); 403 FontPlatformDataCache::iterator platformDataEnd = gFontPlatformDataCache->end(); 404 for (FontPlatformDataCache::iterator platformData = gFontPlatformDataCache->begin(); platformData != platformDataEnd; ++platformData) { 405 if (platformData->value && !gFontDataCache->contains(*platformData->value)) 406 keysToRemove.append(platformData->key); 407 } 408 409 size_t keysToRemoveCount = keysToRemove.size(); 410 for (size_t i = 0; i < keysToRemoveCount; ++i) 411 delete gFontPlatformDataCache->take(keysToRemove[i]); 412 } 413 414 #if ENABLE(OPENTYPE_VERTICAL) 415 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance(); 416 if (!fontVerticalDataCache.isEmpty()) { 417 // Mark & sweep unused verticalData 418 FontVerticalDataCache::iterator verticalDataEnd = fontVerticalDataCache.end(); 419 for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCache.begin(); verticalData != verticalDataEnd; ++verticalData) { 420 if (verticalData->value) 421 verticalData->value->m_inFontCache = false; 422 } 423 FontDataCache::iterator fontDataEnd = gFontDataCache->end(); 424 for (FontDataCache::iterator fontData = gFontDataCache->begin(); fontData != fontDataEnd; ++fontData) { 425 OpenTypeVerticalData* verticalData = const_cast<OpenTypeVerticalData*>(fontData->value.first->verticalData()); 426 if (verticalData) 427 verticalData->m_inFontCache = true; 428 } 429 Vector<FontFileKey> keysToRemove; 430 keysToRemove.reserveInitialCapacity(fontVerticalDataCache.size()); 431 for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCache.begin(); verticalData != verticalDataEnd; ++verticalData) { 432 if (!verticalData->value || !verticalData->value->m_inFontCache) 433 keysToRemove.append(verticalData->key); 434 } 435 for (size_t i = 0, count = keysToRemove.size(); i < count; ++i) 436 fontVerticalDataCache.take(keysToRemove[i]); 437 } 438 #endif 439 440 isPurging = false; 441 }