| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 if (!alternateName.isEmpty()) | 221 if (!alternateName.isEmpty()) |
| 222 result = getCachedFontPlatformData(fontDescription, alternateName, t
rue); | 222 result = getCachedFontPlatformData(fontDescription, alternateName, t
rue); |
| 223 if (result) | 223 if (result) |
| 224 gFontPlatformDataCache->set(key, new FontPlatformData(*result)); //
Cache the result under the old name. | 224 gFontPlatformDataCache->set(key, new FontPlatformData(*result)); //
Cache the result under the old name. |
| 225 } | 225 } |
| 226 | 226 |
| 227 return result; | 227 return result; |
| 228 } | 228 } |
| 229 | 229 |
| 230 #if ENABLE(OPENTYPE_VERTICAL) | 230 #if ENABLE(OPENTYPE_VERTICAL) |
| 231 typedef HashMap<FontCache::FontFileKey, OwnPtr<OpenTypeVerticalData>, WTF::IntHa
sh<FontCache::FontFileKey>, WTF::UnsignedWithZeroKeyHashTraits<FontCache::FontFi
leKey> > FontVerticalDataCache; | 231 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, WTF::IntHa
sh<FontCache::FontFileKey>, WTF::UnsignedWithZeroKeyHashTraits<FontCache::FontFi
leKey> > FontVerticalDataCache; |
| 232 | 232 |
| 233 FontVerticalDataCache& fontVerticalDataCacheInstance() | 233 FontVerticalDataCache& fontVerticalDataCacheInstance() |
| 234 { | 234 { |
| 235 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); | 235 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); |
| 236 return fontVerticalDataCache; | 236 return fontVerticalDataCache; |
| 237 } | 237 } |
| 238 | 238 |
| 239 OpenTypeVerticalData* FontCache::getVerticalData(const FontFileKey& key, const F
ontPlatformData& platformData) | 239 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k
ey, const FontPlatformData& platformData) |
| 240 { | 240 { |
| 241 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance
(); | 241 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance
(); |
| 242 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); | 242 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); |
| 243 if (result != fontVerticalDataCache.end()) | 243 if (result != fontVerticalDataCache.end()) |
| 244 return result.get()->value.get(); | 244 return result.get()->value; |
| 245 | 245 |
| 246 OpenTypeVerticalData* verticalData = new OpenTypeVerticalData(platformData); | 246 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla
tformData); |
| 247 if (!verticalData->isOpenType()) { | 247 if (!verticalData->isOpenType()) |
| 248 delete verticalData; | 248 verticalData.clear(); |
| 249 verticalData = 0; // Put 0 in cache to mark that this isn't an OpenType
font. | 249 fontVerticalDataCache.set(key, verticalData); |
| 250 } | |
| 251 fontVerticalDataCache.set(key, adoptPtr(verticalData)); | |
| 252 return verticalData; | 250 return verticalData; |
| 253 } | 251 } |
| 254 #endif | 252 #endif |
| 255 | 253 |
| 256 struct FontDataCacheKeyHash { | 254 struct FontDataCacheKeyHash { |
| 257 static unsigned hash(const FontPlatformData& platformData) | 255 static unsigned hash(const FontPlatformData& platformData) |
| 258 { | 256 { |
| 259 return platformData.hash(); | 257 return platformData.hash(); |
| 260 } | 258 } |
| 261 | 259 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 clients.append(*it); | 552 clients.append(*it); |
| 555 | 553 |
| 556 ASSERT(numClients == clients.size()); | 554 ASSERT(numClients == clients.size()); |
| 557 for (size_t i = 0; i < numClients; ++i) | 555 for (size_t i = 0; i < numClients; ++i) |
| 558 clients[i]->fontCacheInvalidated(); | 556 clients[i]->fontCacheInvalidated(); |
| 559 | 557 |
| 560 purgeInactiveFontData(); | 558 purgeInactiveFontData(); |
| 561 } | 559 } |
| 562 | 560 |
| 563 } // namespace WebCore | 561 } // namespace WebCore |
| OLD | NEW |