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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 if (m_purgePreventCount) | 236 if (m_purgePreventCount) |
237 return; | 237 return; |
238 | 238 |
239 if (!gFontDataCache || !gFontDataCache->purge(PurgeSeverity)) | 239 if (!gFontDataCache || !gFontDataCache->purge(PurgeSeverity)) |
240 return; | 240 return; |
241 | 241 |
242 purgePlatformFontDataCache(); | 242 purgePlatformFontDataCache(); |
243 purgeFontVerticalDataCache(); | 243 purgeFontVerticalDataCache(); |
244 } | 244 } |
245 | 245 |
246 static HashSet<FontCacheClient*>* gClients; | 246 static bool invalidateFontCache = false; |
| 247 |
| 248 WillBeHeapHashSet<RawPtrWillBeWeakMember<FontCacheClient> >& fontCacheClients() |
| 249 { |
| 250 #if ENABLE(OILPAN) |
| 251 DEFINE_STATIC_LOCAL(Persistent<HeapHashSet<WeakMember<FontCacheClient> > >,
clients, (new HeapHashSet<WeakMember<FontCacheClient> >())); |
| 252 #else |
| 253 DEFINE_STATIC_LOCAL(HashSet<RawPtr<FontCacheClient> >*, clients, (new HashSe
t<RawPtr<FontCacheClient> >())); |
| 254 #endif |
| 255 invalidateFontCache = true; |
| 256 return *clients; |
| 257 } |
247 | 258 |
248 void FontCache::addClient(FontCacheClient* client) | 259 void FontCache::addClient(FontCacheClient* client) |
249 { | 260 { |
250 if (!gClients) | 261 ASSERT(!fontCacheClients().contains(client)); |
251 gClients = new HashSet<FontCacheClient*>; | 262 fontCacheClients().add(client); |
252 | |
253 ASSERT(!gClients->contains(client)); | |
254 gClients->add(client); | |
255 } | 263 } |
256 | 264 |
| 265 #if !ENABLE(OILPAN) |
257 void FontCache::removeClient(FontCacheClient* client) | 266 void FontCache::removeClient(FontCacheClient* client) |
258 { | 267 { |
259 ASSERT(gClients); | 268 ASSERT(fontCacheClients().contains(client)); |
260 ASSERT(gClients->contains(client)); | 269 fontCacheClients().remove(client); |
261 | |
262 gClients->remove(client); | |
263 } | 270 } |
| 271 #endif |
264 | 272 |
265 static unsigned short gGeneration = 0; | 273 static unsigned short gGeneration = 0; |
266 | 274 |
267 unsigned short FontCache::generation() | 275 unsigned short FontCache::generation() |
268 { | 276 { |
269 return gGeneration; | 277 return gGeneration; |
270 } | 278 } |
271 | 279 |
272 void FontCache::invalidate() | 280 void FontCache::invalidate() |
273 { | 281 { |
274 if (!gClients) { | 282 if (!invalidateFontCache) { |
275 ASSERT(!gFontPlatformDataCache); | 283 ASSERT(!gFontPlatformDataCache); |
276 return; | 284 return; |
277 } | 285 } |
278 | 286 |
279 if (gFontPlatformDataCache) { | 287 if (gFontPlatformDataCache) { |
280 delete gFontPlatformDataCache; | 288 delete gFontPlatformDataCache; |
281 gFontPlatformDataCache = new FontPlatformDataCache; | 289 gFontPlatformDataCache = new FontPlatformDataCache; |
282 } | 290 } |
283 | 291 |
284 gGeneration++; | 292 gGeneration++; |
285 | 293 |
286 Vector<RefPtr<FontCacheClient> > clients; | 294 WillBeHeapVector<RefPtrWillBeMember<FontCacheClient> > clients; |
287 size_t numClients = gClients->size(); | 295 size_t numClients = fontCacheClients().size(); |
288 clients.reserveInitialCapacity(numClients); | 296 clients.reserveInitialCapacity(numClients); |
289 HashSet<FontCacheClient*>::iterator end = gClients->end(); | 297 WillBeHeapHashSet<RawPtrWillBeWeakMember<FontCacheClient> >::iterator end =
fontCacheClients().end(); |
290 for (HashSet<FontCacheClient*>::iterator it = gClients->begin(); it != end;
++it) | 298 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<FontCacheClient> >::iterator i
t = fontCacheClients().begin(); it != end; ++it) |
291 clients.append(*it); | 299 clients.append(*it); |
292 | 300 |
293 ASSERT(numClients == clients.size()); | 301 ASSERT(numClients == clients.size()); |
294 for (size_t i = 0; i < numClients; ++i) | 302 for (size_t i = 0; i < numClients; ++i) |
295 clients[i]->fontCacheInvalidated(); | 303 clients[i]->fontCacheInvalidated(); |
296 | 304 |
297 purge(ForcePurge); | 305 purge(ForcePurge); |
298 } | 306 } |
299 | 307 |
300 } // namespace WebCore | 308 } // namespace WebCore |
OLD | NEW |