Title: [236383] trunk/Source/WebCore
- Revision
- 236383
- Author
- [email protected]
- Date
- 2018-09-22 00:56:20 -0700 (Sat, 22 Sep 2018)
Log Message
FontDataCache should use Ref<Font> instead of a RefPtr<Font>
https://bugs.webkit.org/show_bug.cgi?id=189861
Reviewed by Antti Koivisto.
* platform/graphics/FontCache.cpp:
(WebCore::FontCache::fontForPlatformData):
(WebCore::FontCache::purgeInactiveFontData):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (236382 => 236383)
--- trunk/Source/WebCore/ChangeLog 2018-09-22 07:28:39 UTC (rev 236382)
+++ trunk/Source/WebCore/ChangeLog 2018-09-22 07:56:20 UTC (rev 236383)
@@ -1,3 +1,14 @@
+2018-09-22 Chris Dumez <[email protected]>
+
+ FontDataCache should use Ref<Font> instead of a RefPtr<Font>
+ https://bugs.webkit.org/show_bug.cgi?id=189861
+
+ Reviewed by Antti Koivisto.
+
+ * platform/graphics/FontCache.cpp:
+ (WebCore::FontCache::fontForPlatformData):
+ (WebCore::FontCache::purgeInactiveFontData):
+
2018-09-21 Justin Michaud <[email protected]>
Implement initialValue support for CSS Custom Properties and Values API
Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (236382 => 236383)
--- trunk/Source/WebCore/platform/graphics/FontCache.cpp 2018-09-22 07:28:39 UTC (rev 236382)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp 2018-09-22 07:56:20 UTC (rev 236383)
@@ -283,7 +283,7 @@
}
};
-typedef HashMap<FontPlatformData, RefPtr<Font>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache;
+typedef HashMap<FontPlatformData, Ref<Font>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache;
static FontDataCache& cachedFonts()
{
@@ -337,13 +337,13 @@
auto locker = holdLock(fontLock);
#endif
- auto addResult = cachedFonts().add(platformData, nullptr);
- if (addResult.isNewEntry)
- addResult.iterator->value = Font::create(platformData);
+ auto addResult = cachedFonts().ensure(platformData, [&] {
+ return Font::create(platformData);
+ });
ASSERT(addResult.iterator->value->platformData() == platformData);
- return *addResult.iterator->value;
+ return addResult.iterator->value.copyRef();
}
void FontCache::purgeInactiveFontDataIfNeeded()
@@ -375,12 +375,12 @@
#endif
while (purgeCount) {
- Vector<RefPtr<Font>, 20> fontsToDelete;
- for (auto font : cachedFonts().values()) {
+ Vector<Ref<Font>, 20> fontsToDelete;
+ for (auto& font : cachedFonts().values()) {
LOG(Fonts, " trying to purge font %s (has one ref %d)", font->platformData().description().utf8().data(), font->hasOneRef());
if (!font->hasOneRef())
continue;
- fontsToDelete.append(WTFMove(font));
+ fontsToDelete.append(font.copyRef());
if (!--purgeCount)
break;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes