Changeset 178133 in webkit
- Timestamp:
- Jan 8, 2015 2:30:06 PM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r178132 r178133 1 2015-01-08 Antti Koivisto <antti@apple.com> 2 3 Remove the concept of "retained" font 4 https://bugs.webkit.org/show_bug.cgi?id=140246 5 6 Reviewed by Darin Adler. 7 8 FontCache currently maintains a secondary refcount for SimpleFontDatas. This is used to decide whether 9 a font is considered inactive and is eligible for purging. This is confusing and complex. 10 11 The new scheme in this patch considers fonts in font cache inactive if their refcount is 1 (they are 12 owned by the cache only). This simplifies the code and gives similar behavior. Types that "retained" the 13 font this way always also ref it. 14 15 We also avoid unnecessarily removing fonts that wouldn't get deleted from the cache. 16 17 Also modernized some names and code. 18 19 * WebCore.exp.in: 20 * css/CSSFontFaceSource.cpp: 21 (WebCore::CSSFontFaceSource::getFontData): 22 * css/CSSFontSelector.cpp: 23 (WebCore::CSSFontSelector::getFontData): 24 (WebCore::CSSFontSelector::getFallbackFontData): 25 * platform/graphics/FontCache.cpp: 26 (WebCore::fontPlatformDataCache): 27 (WebCore::FontCache::getCachedFontPlatformData): 28 (WebCore::cachedFonts): 29 (WebCore::FontCache::fontForFamily): 30 (WebCore::FontCache::fontDataForPlatformData): 31 (WebCore::FontCache::purgeInactiveFontDataIfNeeded): 32 (WebCore::FontCache::purgeInactiveFontData): 33 (WebCore::FontCache::fontDataCount): 34 (WebCore::FontCache::inactiveFontDataCount): 35 (WebCore::FontCache::fontForFamilyAtIndex): 36 (WebCore::FontCache::invalidate): 37 (WebCore::FontCache::getCachedFontData): Deleted. 38 (WebCore::FontCache::getNonRetainedLastResortFallbackFont): Deleted. 39 (WebCore::FontCache::releaseFontData): Deleted. 40 (WebCore::FontCache::getFontData): Deleted. 41 * platform/graphics/FontCache.h: 42 * platform/graphics/FontGlyphs.cpp: 43 (WebCore::FontGlyphs::FontGlyphs): 44 (WebCore::FontGlyphs::~FontGlyphs): 45 (WebCore::FontGlyphs::realizeFontDataAt): 46 (WebCore::FontGlyphs::releaseFontData): Deleted. 47 * platform/graphics/FontGlyphs.h: 48 (WebCore::FontGlyphs::~FontGlyphs): Deleted. 49 * platform/graphics/SimpleFontData.cpp: 50 (WebCore::SimpleFontData::~SimpleFontData): 51 * platform/graphics/SimpleFontData.h: 52 * platform/graphics/freetype/SimpleFontDataFreeType.cpp: 53 (WebCore::SimpleFontData::platformDestroy): Deleted. 54 * platform/graphics/mac/ComplexTextControllerCoreText.mm: 55 (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): 56 * platform/graphics/mac/FontCacheMac.mm: 57 (WebCore::FontCache::systemFallbackForCharacters): 58 (WebCore::FontCache::similarFontPlatformData): 59 (WebCore::FontCache::lastResortFallbackFont): 60 (WebCore::FontCache::getLastResortFallbackFont): Deleted. 61 * platform/graphics/mac/SimpleFontDataMac.mm: 62 (WebCore::SimpleFontData::platformCreateScaledFontData): 63 (WebCore::SimpleFontData::platformDestroy): Deleted. 64 1 65 2015-01-08 Anders Carlsson <andersca@apple.com> 2 66 -
trunk/Source/WebCore/WebCore.exp.in
r178029 r178133 76 76 __ZN7WebCore10FloatPointC1ERK7CGPoint 77 77 __ZN7WebCore10FloatPointC1ERKNS_8IntPointE 78 __ZN7WebCore10FontGlyphs15releaseFontDataEv79 78 __ZN7WebCore10FontGlyphs17realizeFontDataAtERKNS_15FontDescriptionEj 79 __ZN7WebCore10FontGlyphsD1Ev 80 80 __ZN7WebCore10JSDocument6s_infoE 81 81 __ZN7WebCore10JSDocument9toWrappedEN3JSC7JSValueE … … 1445 1445 __ZN7WebCore9FontCache10invalidateEv 1446 1446 __ZN7WebCore9FontCache13fontDataCountEv 1447 __ZN7WebCore9FontCache1 7getCachedFontDataERKNS_15FontDescriptionERKN3WTF12AtomicStringEbNS0_12ShouldRetainE1447 __ZN7WebCore9FontCache13fontForFamilyERKNS_15FontDescriptionERKN3WTF12AtomicStringEb 1448 1448 __ZN7WebCore9FontCache21inactiveFontDataCountEv 1449 1449 __ZN7WebCore9FontCache21purgeInactiveFontDataEi … … 2796 2796 __ZN7WebCore8Settings34setNetworkDataUsageTrackingEnabledEb 2797 2797 __ZN7WebCore8Settings38gShouldOptOutOfNetworkStateObservationE 2798 __ZN7WebCore9FontCache25getLastResortFallbackFontERKNS_15FontDescriptionENS0_12ShouldRetainE2799 2798 __ZN7WebCore9FrameView17setScrollVelocityEdddd 2800 2799 __ZN7WebCore9FrameView20setWasScrolledByUserEb -
trunk/Source/WebCore/css/CSSFontFaceSource.cpp
r176410 r178133 110 110 // We're local. Just return a SimpleFontData from the normal cache. 111 111 // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter. 112 return fontCache(). getCachedFontData(fontDescription, m_string, true);112 return fontCache().fontForFamily(fontDescription, m_string, true); 113 113 } 114 114 … … 145 145 fontSelector->beginLoadingFontSoon(m_font.get()); 146 146 147 // This temporary font is not retained and should not be returned. 148 FontCachePurgePreventer fontCachePurgePreventer; 149 SimpleFontData* temporaryFont = fontCache().getNonRetainedLastResortFallbackFont(fontDescription); 150 fontData = SimpleFontData::create(temporaryFont->platformData(), true, true); 147 Ref<SimpleFontData> placeholderFont = fontCache().lastResortFallbackFont(fontDescription); 148 Ref<SimpleFontData> placeholderFontCopyInLoadingState = SimpleFontData::create(placeholderFont->platformData(), true, true); 149 return WTF::move(placeholderFontCopyInLoadingState); 151 150 } 152 151 -
trunk/Source/WebCore/css/CSSFontSelector.cpp
r176751 r178133 479 479 if (!resolveGenericFamilyFirst) 480 480 familyForLookup = resolveGenericFamily(m_document, fontDescription, familyName); 481 return fontCache(). getCachedFontData(fontDescription, familyForLookup);481 return fontCache().fontForFamily(fontDescription, familyForLookup); 482 482 } 483 483 … … 635 635 return 0; 636 636 637 return fontCache(). getCachedFontData(fontDescription, settings->pictographFontFamily());638 } 639 640 } 637 return fontCache().fontForFamily(fontDescription, settings->pictographFontFamily()); 638 } 639 640 } -
trunk/Source/WebCore/platform/graphics/FontCache.cpp
r175013 r178133 41 41 #include <wtf/NeverDestroyed.h> 42 42 #include <wtf/StdLibExtras.h> 43 #include <wtf/TemporaryChange.h> 43 44 #include <wtf/text/AtomicStringHash.h> 44 45 #include <wtf/text/StringHash.h> … … 89 90 { 90 91 static NeverDestroyed<FontCache> globalFontCache; 91 return globalFontCache .get();92 return globalFontCache; 92 93 } 93 94 … … 144 145 typedef HashMap<FontPlatformDataCacheKey, std::unique_ptr<FontPlatformData>, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyTraits> FontPlatformDataCache; 145 146 146 static FontPlatformDataCache* gFontPlatformDataCache = 0; 147 static FontPlatformDataCache& fontPlatformDataCache() 148 { 149 static NeverDestroyed<FontPlatformDataCache> cache; 150 return cache; 151 } 147 152 148 153 static bool familyNameEqualIgnoringCase(const AtomicString& familyName, const char* reference, unsigned length) … … 235 240 #endif 236 241 237 if (!gFontPlatformDataCache) {238 gFontPlatformDataCache = new FontPlatformDataCache;242 static bool initialized; 243 if (!initialized) { 239 244 platformInit(); 245 initialized = true; 240 246 } 241 247 242 248 FontPlatformDataCacheKey key(familyName, fontDescription); 243 249 244 FontPlatformDataCache::AddResult result = gFontPlatformDataCache->add(key, nullptr);245 FontPlatformDataCache::iterator it = result.iterator;246 if ( result.isNewEntry) {250 auto addResult = fontPlatformDataCache().add(key, nullptr); 251 FontPlatformDataCache::iterator it = addResult.iterator; 252 if (addResult.isNewEntry) { 247 253 it->value = createFontPlatformData(fontDescription, familyName); 248 254 … … 255 261 // Lookup the key in the hash table again as the previous iterator may have 256 262 // been invalidated by the recursive call to getCachedFontPlatformData(). 257 it = gFontPlatformDataCache->find(key);258 ASSERT(it != gFontPlatformDataCache->end());263 it = fontPlatformDataCache().find(key); 264 ASSERT(it != fontPlatformDataCache().end()); 259 265 if (fontPlatformDataForAlternateName) 260 266 it->value = std::make_unique<FontPlatformData>(*fontPlatformDataForAlternateName); … … 354 360 }; 355 361 356 typedef HashMap<FontPlatformData, std::pair<RefPtr<SimpleFontData>, unsigned>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache; 357 358 static FontDataCache* gFontDataCache = 0; 362 typedef HashMap<FontPlatformData, RefPtr<SimpleFontData>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache; 363 364 static FontDataCache& cachedFonts() 365 { 366 static NeverDestroyed<FontDataCache> cache; 367 return cache; 368 } 369 359 370 360 371 #if PLATFORM(IOS) … … 369 380 const int cTargetUnderMemoryPressureInactiveFontData = 30; 370 381 371 static ListHashSet<RefPtr<SimpleFontData>>* gInactiveFontData = 0; 372 373 PassRefPtr<SimpleFontData> FontCache::getCachedFontData(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName, ShouldRetain shouldRetain) 382 RefPtr<SimpleFontData> FontCache::fontForFamily(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName) 374 383 { 375 384 FontPlatformData* platformData = getCachedFontPlatformData(fontDescription, family, checkingAlternateName); 376 385 if (!platformData) 377 return 0; 378 379 return getCachedFontData(platformData, shouldRetain); 380 } 381 382 PassRefPtr<SimpleFontData> FontCache::getCachedFontData(const FontPlatformData* platformData, ShouldRetain shouldRetain) 383 { 384 if (!platformData) 385 return 0; 386 387 #if !ASSERT_DISABLED 388 if (shouldRetain == DoNotRetain) 389 ASSERT(m_purgePreventCount); 390 #endif 391 386 return nullptr; 387 388 return fontForPlatformData(*platformData); 389 } 390 391 Ref<SimpleFontData> FontCache::fontForPlatformData(const FontPlatformData& platformData) 392 { 392 393 #if PLATFORM(IOS) 393 394 FontLocker fontLocker; 394 395 #endif 395 396 396 if (!gFontDataCache) { 397 gFontDataCache = new FontDataCache; 398 gInactiveFontData = new ListHashSet<RefPtr<SimpleFontData>>; 399 } 400 401 FontDataCache::iterator result = gFontDataCache->find(*platformData); 402 if (result == gFontDataCache->end()) { 403 std::pair<RefPtr<SimpleFontData>, unsigned> newValue(SimpleFontData::create(*platformData), shouldRetain == Retain ? 1 : 0); 404 gFontDataCache->set(*platformData, newValue); 405 if (shouldRetain == DoNotRetain) 406 gInactiveFontData->add(newValue.first); 407 return newValue.first.release(); 408 } 409 410 if (!result.get()->value.second) { 411 ASSERT(gInactiveFontData->contains(result.get()->value.first)); 412 gInactiveFontData->remove(result.get()->value.first); 413 } 414 415 if (shouldRetain == Retain) 416 result.get()->value.second++; 417 else if (!result.get()->value.second) { 418 // If shouldRetain is DoNotRetain and count is 0, we want to remove the fontData from 419 // gInactiveFontData (above) and re-add here to update LRU position. 420 gInactiveFontData->add(result.get()->value.first); 421 } 422 423 return result.get()->value.first; 424 } 425 426 SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont(const FontDescription& fontDescription) 427 { 428 return getLastResortFallbackFont(fontDescription, DoNotRetain).leakRef(); 429 } 430 431 void FontCache::releaseFontData(const SimpleFontData* fontData) 432 { 433 ASSERT(gFontDataCache); 434 ASSERT(!fontData->isCustomFont()); 397 auto addResult = cachedFonts().add(platformData, nullptr); 398 if (addResult.isNewEntry) 399 addResult.iterator->value = SimpleFontData::create(platformData); 400 401 return *addResult.iterator->value; 402 } 403 404 void FontCache::purgeInactiveFontDataIfNeeded() 405 { 406 bool underMemoryPressure = memoryPressureHandler().isUnderMemoryPressure(); 407 int inactiveFontDataLimit = underMemoryPressure ? cMaxUnderMemoryPressureInactiveFontData : cMaxInactiveFontData; 408 409 if (cachedFonts().size() < inactiveFontDataLimit) 410 return; 411 int inactiveCount = inactiveFontDataCount(); 412 if (inactiveCount <= inactiveFontDataLimit) 413 return; 414 415 int targetFontDataLimit = underMemoryPressure ? cTargetUnderMemoryPressureInactiveFontData : cTargetInactiveFontData; 416 purgeInactiveFontData(inactiveCount - targetFontDataLimit); 417 } 418 419 void FontCache::purgeInactiveFontData(int purgeCount) 420 { 421 pruneUnreferencedEntriesFromFontGlyphsCache(); 422 423 if (m_purgePreventCount) 424 return; 435 425 436 426 #if PLATFORM(IOS) 437 427 FontLocker fontLocker; 438 428 #endif 439 440 FontDataCache::iterator it = gFontDataCache->find(fontData->platformData()); 441 ASSERT(it != gFontDataCache->end()); 442 if (it == gFontDataCache->end()) 443 return; 444 445 ASSERT(it->value.second); 446 if (!--it->value.second) 447 gInactiveFontData->add(it->value.first); 448 } 449 450 void FontCache::purgeInactiveFontDataIfNeeded() 451 { 452 bool underMemoryPressure = memoryPressureHandler().isUnderMemoryPressure(); 453 int inactiveFontDataLimit = underMemoryPressure ? cMaxUnderMemoryPressureInactiveFontData : cMaxInactiveFontData; 454 int targetFontDataLimit = underMemoryPressure ? cTargetUnderMemoryPressureInactiveFontData : cTargetInactiveFontData; 455 456 if (gInactiveFontData && !m_purgePreventCount && gInactiveFontData->size() > inactiveFontDataLimit) 457 purgeInactiveFontData(gInactiveFontData->size() - targetFontDataLimit); 458 } 459 460 void FontCache::purgeInactiveFontData(int count) 461 { 462 pruneUnreferencedEntriesFromFontGlyphsCache(); 463 464 if (!gInactiveFontData || m_purgePreventCount) 465 return; 466 467 static bool isPurging; // Guard against reentry when e.g. a deleted FontData releases its small caps FontData. 468 if (isPurging) 469 return; 470 471 isPurging = true; 472 473 #if PLATFORM(IOS) 474 FontLocker fontLocker; 475 #endif 476 477 Vector<RefPtr<SimpleFontData>, 20> fontDataToDelete; 478 ListHashSet<RefPtr<SimpleFontData>>::iterator end = gInactiveFontData->end(); 479 ListHashSet<RefPtr<SimpleFontData>>::iterator it = gInactiveFontData->begin(); 480 for (int i = 0; i < count && it != end; ++it, ++i) { 481 RefPtr<SimpleFontData>& fontData = *it.get(); 482 gFontDataCache->remove(fontData->platformData()); 483 // We should not delete SimpleFontData here because deletion can modify gInactiveFontData. See http://trac.webkit.org/changeset/44011 484 fontDataToDelete.append(fontData); 485 } 486 487 if (it == end) { 488 // Removed everything 489 gInactiveFontData->clear(); 490 } else { 491 for (int i = 0; i < count; ++i) 492 gInactiveFontData->remove(gInactiveFontData->begin()); 493 } 494 495 fontDataToDelete.clear(); 496 497 if (gFontPlatformDataCache) { 498 Vector<FontPlatformDataCacheKey> keysToRemove; 499 keysToRemove.reserveInitialCapacity(gFontPlatformDataCache->size()); 500 FontPlatformDataCache::iterator platformDataEnd = gFontPlatformDataCache->end(); 501 for (FontPlatformDataCache::iterator platformData = gFontPlatformDataCache->begin(); platformData != platformDataEnd; ++platformData) { 502 if (platformData->value && !gFontDataCache->contains(*platformData->value)) 503 keysToRemove.append(platformData->key); 504 } 505 506 size_t keysToRemoveCount = keysToRemove.size(); 507 for (size_t i = 0; i < keysToRemoveCount; ++i) 508 gFontPlatformDataCache->remove(keysToRemove[i]); 509 } 429 430 Vector<RefPtr<SimpleFontData>, 20> fontsToDelete; 431 for (auto& font : cachedFonts().values()) { 432 if (!font->hasOneRef()) 433 continue; 434 fontsToDelete.append(WTF::move(font)); 435 if (!--purgeCount) 436 break; 437 } 438 for (auto& font : fontsToDelete) 439 cachedFonts().remove(font->platformData()); 440 441 Vector<FontPlatformDataCacheKey> keysToRemove; 442 keysToRemove.reserveInitialCapacity(fontPlatformDataCache().size()); 443 for (auto& entry : fontPlatformDataCache()) { 444 if (entry.value && !cachedFonts().contains(*entry.value)) 445 keysToRemove.append(entry.key); 446 } 447 for (auto key : keysToRemove) 448 fontPlatformDataCache().remove(key); 510 449 511 450 #if ENABLE(OPENTYPE_VERTICAL) … … 513 452 if (!fontVerticalDataCache.isEmpty()) { 514 453 // Mark & sweep unused verticalData 515 FontVerticalDataCache::iterator verticalDataEnd = fontVerticalDataCache.end(); 516 for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCache.begin(); verticalData != verticalDataEnd; ++verticalData) { 517 if (verticalData->value) 518 verticalData->value->m_inFontCache = false; 454 for (auto& verticalData : fontVerticalDataCache.values()) { 455 if (verticalData) 456 verticalData->m_inFontCache = false; 519 457 } 520 FontDataCache::iterator fontDataEnd = gFontDataCache->end(); 521 for (FontDataCache::iterator fontData = gFontDataCache->begin(); fontData != fontDataEnd; ++fontData) { 522 OpenTypeVerticalData* verticalData = const_cast<OpenTypeVerticalData*>(fontData->value.first->verticalData()); 458 for (auto& fontData : cachedFonts().values()) { 459 auto* verticalData = const_cast<OpenTypeVerticalData*>(fontData->verticalData()); 523 460 if (verticalData) 524 461 verticalData->m_inFontCache = true; … … 526 463 Vector<FontFileKey> keysToRemove; 527 464 keysToRemove.reserveInitialCapacity(fontVerticalDataCache.size()); 528 for ( FontVerticalDataCache::iterator verticalData = fontVerticalDataCache.begin(); verticalData != verticalDataEnd; ++verticalData) {529 if (! verticalData->value || !verticalData->value->m_inFontCache)530 keysToRemove.append( verticalData->key);465 for (auto& it : fontVerticalDataCache) { 466 if (!it.value || !it.value->m_inFontCache) 467 keysToRemove.append(it.key); 531 468 } 532 for (size_t i = 0, count = keysToRemove.size(); i < count; ++i) 533 fontVerticalDataCache.take(keysToRemove[i]); 534 } 535 #endif 536 537 isPurging = false; 469 for (auto& key : keysToRemove) 470 fontVerticalDataCache.remove(key); 471 } 472 #endif 538 473 } 539 474 540 475 size_t FontCache::fontDataCount() 541 476 { 542 if (gFontDataCache) 543 return gFontDataCache->size(); 544 return 0; 477 return cachedFonts().size(); 545 478 } 546 479 547 480 size_t FontCache::inactiveFontDataCount() 548 481 { 549 if (gInactiveFontData) 550 return gInactiveFontData->size(); 551 return 0; 552 } 553 554 PassRefPtr<FontData> FontCache::getFontData(const FontDescription& description, int& familyIndex, FontSelector* fontSelector) 482 #if PLATFORM(IOS) 483 FontLocker fontLocker; 484 #endif 485 unsigned count = 0; 486 for (auto& font : cachedFonts().values()) { 487 if (font->hasOneRef()) 488 ++count; 489 } 490 return count; 491 } 492 493 RefPtr<FontData> FontCache::fontForFamilyAtIndex(const FontDescription& description, int& familyIndex, FontSelector* fontSelector) 555 494 { 556 495 ASSERT(familyIndex != cAllFamiliesScanned); … … 566 505 result = fontSelector->getFontData(description, family); 567 506 if (!result) 568 result = getCachedFontData(description, family);507 result = fontForFamily(description, family); 569 508 } 570 509 if (familyIndex == familyCount) … … 589 528 } 590 529 // Still no result. Hand back our last resort fallback font. 591 result = getLastResortFallbackFont(description);530 result = lastResortFallbackFont(description); 592 531 } 593 532 return result.release(); … … 623 562 { 624 563 if (!gClients) { 625 ASSERT( !gFontPlatformDataCache);564 ASSERT(fontPlatformDataCache().isEmpty()); 626 565 return; 627 566 } 628 567 629 if (gFontPlatformDataCache) 630 gFontPlatformDataCache->clear(); 568 fontPlatformDataCache().clear(); 631 569 invalidateFontGlyphsCache(); 632 570 -
trunk/Source/WebCore/platform/graphics/FontCache.h
r177876 r178133 112 112 friend FontCache& fontCache(); 113 113 114 enum ShouldRetain { Retain, DoNotRetain }; 115 116 PassRefPtr<FontData> getFontData(const FontDescription&, int& familyIndex, FontSelector*); 117 void releaseFontData(const SimpleFontData*); 114 RefPtr<FontData> fontForFamilyAtIndex(const FontDescription&, int& familyIndex, FontSelector*); 118 115 119 116 // This method is implemented by the platform. 120 PassRefPtr<SimpleFontData> systemFallbackForCharacters(const FontDescription&, const SimpleFontData* originalFontData, bool isPlatformFont, const UChar* characters, int length);117 RefPtr<SimpleFontData> systemFallbackForCharacters(const FontDescription&, const SimpleFontData* originalFontData, bool isPlatformFont, const UChar* characters, int length); 121 118 122 119 // Also implemented by the platform. … … 135 132 void getTraitsInFamily(const AtomicString&, Vector<unsigned>&); 136 133 137 WEBCORE_EXPORT PassRefPtr<SimpleFontData> getCachedFontData(const FontDescription&, const AtomicString&, bool checkingAlternateName = false, ShouldRetain = Retain); 138 WEBCORE_EXPORT PassRefPtr<SimpleFontData> getLastResortFallbackFont(const FontDescription&, ShouldRetain = Retain); 139 SimpleFontData* getNonRetainedLastResortFallbackFont(const FontDescription&); 134 WEBCORE_EXPORT RefPtr<SimpleFontData> fontForFamily(const FontDescription&, const AtomicString&, bool checkingAlternateName = false); 135 WEBCORE_EXPORT Ref<SimpleFontData> lastResortFallbackFont(const FontDescription&); 140 136 141 137 void addClient(FontSelector*); … … 150 146 151 147 #if PLATFORM(WIN) 152 PassRef Ptr<SimpleFontData> fontDataFromDescriptionAndLogFont(const FontDescription&, ShouldRetain, const LOGFONT&, AtomicString& outFontFamilyName);148 PassRef<SimpleFontData> fontDataFromDescriptionAndLogFont(const FontDescription&, const LOGFONT&, AtomicString& outFontFamilyName); 153 149 #endif 154 150 … … 192 188 #endif 193 189 194 WEBCORE_EXPORT PassRefPtr<SimpleFontData> getCachedFontData(const FontPlatformData*, ShouldRetain = Retain);190 WEBCORE_EXPORT Ref<SimpleFontData> fontForPlatformData(const FontPlatformData&); 195 191 196 192 // Don't purge if this count is > 0; … … 200 196 friend class ComplexTextController; 201 197 #endif 202 friend class SimpleFontData; // For getCachedFontData(const FontPlatformData*)198 friend class SimpleFontData; 203 199 friend class FontGlyphs; 204 200 }; -
trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp
r177975 r178133 60 60 , m_isForPlatformFont(true) 61 61 { 62 RefPtr<FontData> fontData = fontCache().getCachedFontData(&platformData); 63 m_realizedFontData.append(fontData.release()); 64 } 65 66 void FontGlyphs::releaseFontData() 67 { 68 unsigned numFonts = m_realizedFontData.size(); 69 for (unsigned i = 0; i < numFonts; ++i) { 70 if (m_realizedFontData[i]->isCustomFont()) 71 continue; 72 fontCache().releaseFontData(downcast<SimpleFontData>(m_realizedFontData[i].get())); 73 } 62 m_realizedFontData.append(fontCache().fontForPlatformData(platformData)); 63 } 64 65 FontGlyphs::~FontGlyphs() 66 { 74 67 } 75 68 … … 114 107 // Ask the font cache for the font data. 115 108 // We are obtaining this font for the first time. We keep track of the families we've looked at before 116 // in |m_familyIndex|, so that we never scan the same spot in the list twice. getFontDatawill adjust our109 // in |m_familyIndex|, so that we never scan the same spot in the list twice. fontForFamilyAtIndex will adjust our 117 110 // |m_familyIndex| as it scans for the right font to make. 118 111 ASSERT(fontCache().generation() == m_generation); 119 RefPtr<FontData> result = fontCache(). getFontData(description, m_familyIndex, m_fontSelector.get());112 RefPtr<FontData> result = fontCache().fontForFamilyAtIndex(description, m_familyIndex, m_fontSelector.get()); 120 113 if (result) { 121 114 m_realizedFontData.append(result); -
trunk/Source/WebCore/platform/graphics/FontGlyphs.h
r177957 r178133 49 49 static Ref<FontGlyphs> createForPlatformFont(const FontPlatformData& platformData) { return adoptRef(*new FontGlyphs(platformData)); } 50 50 51 ~FontGlyphs() { releaseFontData(); }51 ~FontGlyphs(); 52 52 53 53 bool isForPlatformFont() const { return m_isForPlatformFont; } … … 78 78 GlyphData glyphDataForNormalVariant(UChar32, const FontDescription&); 79 79 GlyphData glyphDataForVariant(UChar32, const FontDescription&, FontDataVariant, unsigned fallbackLevel); 80 81 WEBCORE_EXPORT void releaseFontData();82 80 83 81 Vector<RefPtr<FontData>, 1> m_realizedFontData; -
trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp
r178028 r178133 155 155 SimpleFontData::~SimpleFontData() 156 156 { 157 if (!isSVGFont())158 platformDestroy();159 160 157 removeFromSystemFallbackCache(); 161 158 } -
trunk/Source/WebCore/platform/graphics/SimpleFontData.h
r178028 r178133 82 82 83 83 // Used to create platform fonts. 84 static PassRefPtr<SimpleFontData> create(const FontPlatformData& platformData, bool isCustomFont = false, bool isLoading = false, bool isTextOrientationFallback = false)84 static Ref<SimpleFontData> create(const FontPlatformData& platformData, bool isCustomFont = false, bool isLoading = false, bool isTextOrientationFallback = false) 85 85 { 86 return adoptRef( new SimpleFontData(platformData, isCustomFont, isLoading, isTextOrientationFallback));86 return adoptRef(*new SimpleFontData(platformData, isCustomFont, isLoading, isTextOrientationFallback)); 87 87 } 88 88 89 89 // Used to create SVG Fonts. 90 static PassRefPtr<SimpleFontData> create(std::unique_ptr<SVGData> svgData, float fontSize, bool syntheticBold, bool syntheticItalic)90 static Ref<SimpleFontData> create(std::unique_ptr<SVGData> svgData, float fontSize, bool syntheticBold, bool syntheticItalic) 91 91 { 92 return adoptRef( new SimpleFontData(WTF::move(svgData), fontSize, syntheticBold, syntheticItalic));92 return adoptRef(*new SimpleFontData(WTF::move(svgData), fontSize, syntheticBold, syntheticItalic)); 93 93 } 94 94 … … 223 223 void platformGlyphInit(); 224 224 void platformCharWidthInit(); 225 void platformDestroy();226 225 227 226 void initCharWidths(); -
trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
r176840 r178133 82 82 } 83 83 84 PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)84 RefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length) 85 85 { 86 86 RefPtr<FcPattern> pattern = adoptRef(createFontConfigPatternForCharacters(characters, length)); … … 90 90 if (fallbackPattern) { 91 91 FontPlatformData alternateFontData(fallbackPattern.get(), description); 92 return getCachedFontData(&alternateFontData, DoNotRetain);92 return fontForPlatformData(alternateFontData); 93 93 } 94 94 … … 98 98 return 0; 99 99 FontPlatformData alternateFontData(resultPattern.get(), description); 100 return getCachedFontData(&alternateFontData, DoNotRetain);101 } 102 103 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)100 return fontForPlatformData(alternateFontData); 101 } 102 103 Ref<SimpleFontData> FontCache::lastResortFallbackFont(const FontDescription& fontDescription) 104 104 { 105 105 // We want to return a fallback font here, otherwise the logic preventing FontConfig 106 106 // matches for non-fallback fonts might return 0. See isFallbackFontAllowed. 107 107 static AtomicString timesStr("serif"); 108 return getCachedFontData(fontDescription, timesStr, false, shouldRetain);108 return *fontForFamily(fontDescription, timesStr, false); 109 109 } 110 110 -
trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
r177847 r178133 102 102 } 103 103 104 void SimpleFontData::platformDestroy()105 {106 }107 108 104 PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const 109 105 { -
trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm
r177404 r178133 95 95 alternateFont.m_isEmoji = CTFontIsAppleColorEmoji(substituteFont.get()); 96 96 97 return getCachedFontData(&alternateFont, DoNotRetain);97 return fontForPlatformData(alternateFont); 98 98 } 99 99 … … 195 195 } 196 196 197 PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)197 RefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length) 198 198 { 199 199 // Unlike OS X, our fallback font on iPhone is Arial Unicode, which doesn't have some apple-specific glyphs like F8FF. 200 200 // Fall back to the Apple Fallback font in this case. 201 if (length > 0 && requiresCustomFallbackFont(*characters)) 202 return getCachedFontData(getCustomFallbackFont(*characters, description), DoNotRetain); 201 if (length > 0 && requiresCustomFallbackFont(*characters)) { 202 auto* fallback = getCustomFallbackFont(*characters, description); 203 if (!fallback) 204 return nullptr; 205 return fontForPlatformData(*fallback); 206 } 203 207 204 208 UChar32 c = *characters; … … 295 299 } 296 300 297 simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? *cjkBold[preferredCJKFont] : *cjkPlain[preferredCJKFont], false, DoNotRetain);301 simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? *cjkBold[preferredCJKFont] : *cjkPlain[preferredCJKFont], false); 298 302 bool useSecondaryFont = true; 299 303 if (simpleFontData) { … … 307 311 308 312 if (useSecondaryFont) 309 simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? *cjkBold[secondaryCJKFont] : *cjkPlain[secondaryCJKFont], false, DoNotRetain);313 simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? *cjkBold[secondaryCJKFont] : *cjkPlain[secondaryCJKFont], false); 310 314 break; 311 315 } … … 313 317 static NeverDestroyed<AtomicString> koreanPlain("AppleSDGothicNeo-Medium", AtomicString::ConstructFromLiteral); 314 318 static NeverDestroyed<AtomicString> koreanBold("AppleSDGothicNeo-Bold", AtomicString::ConstructFromLiteral); 315 simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? koreanBold : koreanPlain, false, DoNotRetain);319 simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? koreanBold : koreanPlain, false); 316 320 break; 317 321 } … … 319 323 static NeverDestroyed<AtomicString> cyrillicPlain("HelveticaNeue", AtomicString::ConstructFromLiteral); 320 324 static NeverDestroyed<AtomicString> cyrillicBold("HelveticaNeue-Bold", AtomicString::ConstructFromLiteral); 321 simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? cyrillicBold : cyrillicPlain, false, DoNotRetain);325 simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? cyrillicBold : cyrillicPlain, false); 322 326 break; 323 327 } … … 325 329 static NeverDestroyed<AtomicString> arabicPlain("GeezaPro", AtomicString::ConstructFromLiteral); 326 330 static NeverDestroyed<AtomicString> arabicBold("GeezaPro-Bold", AtomicString::ConstructFromLiteral); 327 simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? arabicBold : arabicPlain, false, DoNotRetain);331 simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? arabicBold : arabicPlain, false); 328 332 break; 329 333 } … … 331 335 static NeverDestroyed<AtomicString> hebrewPlain("ArialHebrew", AtomicString::ConstructFromLiteral); 332 336 static NeverDestroyed<AtomicString> hebrewBold("ArialHebrew-Bold", AtomicString::ConstructFromLiteral); 333 simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? hebrewBold : hebrewPlain, false, DoNotRetain);337 simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? hebrewBold : hebrewPlain, false); 334 338 break; 335 339 } … … 387 391 AtomicString* indicFontString = isFontWeightBold(description.weight()) ? indicUnicodePageFontsBold[indicPageOrderIndex] : indicUnicodePageFonts[indicPageOrderIndex]; 388 392 if (indicFontString) 389 simpleFontData = getCachedFontData(description, *indicFontString, false, DoNotRetain);393 simpleFontData = fontForFamily(description, *indicFontString, false); 390 394 } 391 395 break; … … 394 398 static NeverDestroyed<AtomicString> thaiPlain("Thonburi", AtomicString::ConstructFromLiteral); 395 399 static NeverDestroyed<AtomicString> thaiBold("Thonburi-Bold", AtomicString::ConstructFromLiteral); 396 simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? thaiBold : thaiPlain, false, DoNotRetain);400 simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? thaiBold : thaiPlain, false); 397 401 break; 398 402 } … … 400 404 static NeverDestroyed<AtomicString> tibetanPlain("Kailasa", AtomicString::ConstructFromLiteral); 401 405 static NeverDestroyed<AtomicString> tibetanBold("Kailasa-Bold", AtomicString::ConstructFromLiteral); 402 simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? tibetanBold : tibetanPlain, false, DoNotRetain);406 simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? tibetanBold : tibetanPlain, false); 403 407 break; 404 408 } … … 406 410 static NeverDestroyed<AtomicString> casPlain("EuphemiaUCAS", AtomicString::ConstructFromLiteral); 407 411 static NeverDestroyed<AtomicString> casBold("EuphemiaUCAS-Bold", AtomicString::ConstructFromLiteral); 408 simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? casBold : casPlain, false, DoNotRetain);412 simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? casBold : casPlain, false); 409 413 break; 410 414 } 411 415 case LanguageSpecificFont::Khmer: { 412 416 static NeverDestroyed<AtomicString> khmer("KhmerSangamMN", AtomicString::ConstructFromLiteral); 413 simpleFontData = getCachedFontData(description, khmer, false, DoNotRetain);417 simpleFontData = fontForFamily(description, khmer, false); 414 418 break; 415 419 } 416 420 case LanguageSpecificFont::Lao: { 417 421 static NeverDestroyed<AtomicString> lao("LaoSangamMN", AtomicString::ConstructFromLiteral); 418 simpleFontData = getCachedFontData(description, lao, false, DoNotRetain);422 simpleFontData = fontForFamily(description, lao, false); 419 423 break; 420 424 } … … 427 431 } 428 432 if (useEmojiFont) 429 simpleFontData = getCachedFontData(description, appleColorEmoji, false, DoNotRetain);433 simpleFontData = fontForFamily(description, appleColorEmoji, false); 430 434 else { 431 435 RetainPtr<CTFontRef> fallbackFont = adoptCF(CTFontCreateForCharacters(originalFontData->getCTFont(), characters, length, nullptr)); 432 436 if (RetainPtr<CFStringRef> foundFontName = adoptCF(CTFontCopyPostScriptName(fallbackFont.get()))) 433 simpleFontData = getCachedFontData(description, foundFontName.get(), false, DoNotRetain);437 simpleFontData = fontForFamily(description, foundFontName.get(), false); 434 438 } 435 439 break; … … 440 444 return simpleFontData.release(); 441 445 442 return getNonRetainedLastResortFallbackFont(description);446 return lastResortFallbackFont(description); 443 447 } 444 448 … … 458 462 static NeverDestroyed<AtomicString> courier("courier", AtomicString::ConstructFromLiteral); 459 463 if (equalIgnoringCase(family, monaco) || equalIgnoringCase(family, menlo)) { 460 simpleFontData = getCachedFontData(description, courier);464 simpleFontData = fontForFamily(description, courier); 461 465 continue; 462 466 } … … 466 470 static NeverDestroyed<AtomicString> verdana("verdana", AtomicString::ConstructFromLiteral); 467 471 if (equalIgnoringCase(family, lucidaGrande)) { 468 simpleFontData = getCachedFontData(description, verdana);472 simpleFontData = fontForFamily(description, verdana); 469 473 continue; 470 474 } … … 478 482 for (int j = 0; j < 3 && !simpleFontData; ++j) 479 483 if (family.contains(*matchWords[j], false)) 480 simpleFontData = getCachedFontData(description, isFontWeightBold(description.weight()) ? geezaBold : geezaPlain);484 simpleFontData = fontForFamily(description, isFontWeightBold(description.weight()) ? geezaBold : geezaPlain); 481 485 } 482 486 … … 484 488 } 485 489 486 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)490 Ref<SimpleFontData> FontCache::lastResortFallbackFont(const FontDescription& fontDescription) 487 491 { 488 492 static NeverDestroyed<AtomicString> fallbackFontFamily(".PhoneFallback", AtomicString::ConstructFromLiteral); 489 return getCachedFontData(fontDescription, fallbackFontFamily, false, shouldRetain);493 return *fontForFamily(fontDescription, fallbackFontFamily, false); 490 494 } 491 495 -
trunk/Source/WebCore/platform/graphics/ios/SimpleFontDataIOS.mm
r177847 r178133 162 162 scaledFontData.m_syntheticOblique = (fontTraits & kCTFontItalicTrait) && !(scaledFontTraits & kCTFontTraitItalic); 163 163 164 return fontCache(). getCachedFontData(&scaledFontData);164 return fontCache().fontForPlatformData(scaledFontData); 165 165 } 166 166 -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
r177955 r178133 277 277 continue; 278 278 } 279 runFontData = fontCache(). getCachedFontData(m_font.fontDescription(), fontName.get(), false, FontCache::DoNotRetain).get();279 runFontData = fontCache().fontForFamily(m_font.fontDescription(), fontName.get(), false).get(); 280 280 #if !PLATFORM(IOS) 281 281 // Core Text may have used a font that is not known to NSFontManager. In that case, fall back on … … 283 283 if (!runFontData) { 284 284 FontPlatformData runFontPlatformData((NSFont *)runFont, CTFontGetSize(runFont), m_font.fontDescription().usePrinterFont()); 285 runFontData = fontCache().getCachedFontData(&runFontPlatformData, FontCache::DoNotRetain).get();285 runFontData = &fontCache().fontForPlatformData(runFontPlatformData).get(); 286 286 } 287 287 #else -
trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm
r177527 r178133 338 338 } 339 339 340 PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool isPlatformFont, const UChar* characters, int length)340 RefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool isPlatformFont, const UChar* characters, int length) 341 341 { 342 342 UChar32 character; … … 403 403 platformData.m_orientation); 404 404 405 return getCachedFontData(&alternateFont, DoNotRetain);405 return fontForPlatformData(alternateFont); 406 406 } 407 407 … … 420 420 for (int j = 0; j < 3 && !simpleFontData; ++j) 421 421 if (family.contains(*matchWords[j], false)) 422 simpleFontData = getCachedFontData(description, geezaStr);422 simpleFontData = fontForFamily(description, geezaStr); 423 423 } 424 424 return simpleFontData.release(); 425 425 } 426 426 427 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)427 Ref<SimpleFontData> FontCache::lastResortFallbackFont(const FontDescription& fontDescription) 428 428 { 429 429 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times", AtomicString::ConstructFromLiteral)); … … 431 431 // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick 432 432 // the default that the user would get without changing any prefs. 433 RefPtr<SimpleFontData> simpleFontData = getCachedFontData(fontDescription, timesStr, false, shouldRetain);433 RefPtr<SimpleFontData> simpleFontData = fontForFamily(fontDescription, timesStr, false); 434 434 if (simpleFontData) 435 return simpleFontData.release();435 return *simpleFontData; 436 436 437 437 // The Times fallback will almost always work, but in the highly unusual case where … … 440 440 // to avoid a crash at least. 441 441 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande", AtomicString::ConstructFromLiteral)); 442 return getCachedFontData(fontDescription, lucidaGrandeStr, false, shouldRetain);442 return *fontForFamily(fontDescription, lucidaGrandeStr, false); 443 443 } 444 444 -
trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
r178028 r178133 263 263 #endif // USE(APPKIT) 264 264 265 void SimpleFontData::platformDestroy()266 {267 if (!isCustomFont() && m_derivedFontData) {268 // These come from the cache.269 if (m_derivedFontData->smallCaps)270 fontCache().releaseFontData(m_derivedFontData->smallCaps.get());271 272 if (m_derivedFontData->emphasisMark)273 fontCache().releaseFontData(m_derivedFontData->emphasisMark.get());274 }275 }276 277 265 #if !PLATFORM(IOS) 278 266 PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const … … 305 293 scaledFontData.m_syntheticOblique = (fontTraits & NSItalicFontMask) && !(scaledFontTraits & NSItalicFontMask); 306 294 307 // SimpleFontData::platformDestroy() takes care of not deleting the cached font data twice. 308 return fontCache().getCachedFontData(&scaledFontData); 295 return fontCache().fontForPlatformData(scaledFontData); 309 296 } 310 297 END_BLOCK_OBJC_EXCEPTIONS; -
trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
r176210 r178133 200 200 } 201 201 202 PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)202 RefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length) 203 203 { 204 204 UChar character = characters[0]; … … 300 300 FontPlatformData* result = getCachedFontPlatformData(description, familyName); 301 301 if (result) 302 fontData = getCachedFontData(result, DoNotRetain);302 fontData = fontForPlatformData(*result); 303 303 } 304 304 … … 310 310 } 311 311 312 PassRef Ptr<SimpleFontData> FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, ShouldRetain shouldRetain, const LOGFONT& font, AtomicString& outFontFamilyName)312 PassRef<SimpleFontData> FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, const LOGFONT& font, AtomicString& outFontFamilyName) 313 313 { 314 314 AtomicString familyName = String(font.lfFaceName, wcsnlen(font.lfFaceName, LF_FACESIZE)); 315 RefPtr<SimpleFontData> fontData = getCachedFontData(fontDescription, familyName, false, shouldRetain);315 RefPtr<SimpleFontData> fontData = fontForFamily(fontDescription, familyName); 316 316 if (fontData) 317 317 outFontFamilyName = familyName; 318 return fontData .release();319 } 320 321 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)318 return fontData; 319 } 320 321 Ref<SimpleFontData> FontCache:lastResortFallbackFont(const FontDescription& fontDescription) 322 322 { 323 323 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, fallbackFontName, ()); 324 324 if (!fallbackFontName.isEmpty()) 325 return getCachedFontData(fontDescription, fallbackFontName, false, shouldRetain);325 return *fontForFamily(fontDescription, fallbackFontName); 326 326 327 327 // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick … … 340 340 RefPtr<SimpleFontData> simpleFont; 341 341 for (size_t i = 0; i < WTF_ARRAY_LENGTH(fallbackFonts); ++i) { 342 if (simpleFont = getCachedFontData(fontDescription, fallbackFonts[i], false, shouldRetain)) {342 if (simpleFont = fontForFamily(fontDescription, fallbackFonts[i])) { 343 343 fallbackFontName = fallbackFonts[i]; 344 return simpleFont.release();344 return *simpleFont; 345 345 } 346 346 } … … 350 350 LOGFONT defaultGUILogFont; 351 351 GetObject(defaultGUIFont, sizeof(defaultGUILogFont), &defaultGUILogFont); 352 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain,defaultGUILogFont, fallbackFontName))353 return simpleFont.release();352 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, defaultGUILogFont, fallbackFontName)) 353 return *simpleFont; 354 354 } 355 355 … … 358 358 nonClientMetrics.cbSize = sizeof(nonClientMetrics); 359 359 if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nonClientMetrics), &nonClientMetrics, 0)) { 360 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain,nonClientMetrics.lfMessageFont, fallbackFontName))361 return simpleFont.release();362 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain,nonClientMetrics.lfMenuFont, fallbackFontName))363 return simpleFont.release();364 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain,nonClientMetrics.lfStatusFont, fallbackFontName))365 return simpleFont.release();366 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain,nonClientMetrics.lfCaptionFont, fallbackFontName))367 return simpleFont.release();368 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain,nonClientMetrics.lfSmCaptionFont, fallbackFontName))369 return simpleFont.release();360 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, nonClientMetrics.lfMessageFont, fallbackFontName)) 361 return *simpleFont; 362 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, nonClientMetrics.lfMenuFont, fallbackFontName)) 363 return *simpleFont; 364 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, nonClientMetrics.lfStatusFont, fallbackFontName)) 365 return *simpleFont; 366 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, nonClientMetrics.lfCaptionFont, fallbackFontName)) 367 return *simpleFont; 368 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, nonClientMetrics.lfSmCaptionFont, fallbackFontName)) 369 return *simpleFont; 370 370 } 371 371 372 372 ASSERT_NOT_REACHED(); 373 return 0;373 return *simpleFont; 374 374 } 375 375 -
trunk/Source/WebKit/ios/Misc/EmojiFallbackFontSelector.cpp
r167768 r178133 38 38 { 39 39 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, appleColorEmoji, ("Apple Color Emoji")); 40 RefPtr<FontData> fontData = fontCache(). getCachedFontData(fontDescription, appleColorEmoji);40 RefPtr<FontData> fontData = fontCache().fontForFamily(fontDescription, appleColorEmoji); 41 41 if (!fontData) { 42 42 LOG_ERROR("Failed to get \"Apple Color Emoji\" from the font cache. Using the last resort fallback font instead."); 43 fontData = fontCache(). getLastResortFallbackFont(fontDescription);43 fontData = fontCache().lastResortFallbackFont(fontDescription); 44 44 } 45 45 -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r177527 r178133 4880 4880 fontDescription.setSpecifiedSize(pointSize); 4881 4881 FontCachePurgePreventer purgePreventer; 4882 RefPtr<SimpleFontData> simpleFontData = fontCache(). getCachedFontData(fontDescription, familyName, false, WebCore::FontCache::DoNotRetain);4882 RefPtr<SimpleFontData> simpleFontData = fontCache().fontForFamily(fontDescription, familyName); 4883 4883 return [simpleFontData->platformData().nsFont() fontName]; 4884 4884 }
Note: See TracChangeset
for help on using the changeset viewer.