Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 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 21 matching lines...) Expand all Loading... | |
| 32 | 32 |
| 33 #import <AppKit/AppKit.h> | 33 #import <AppKit/AppKit.h> |
| 34 #import "core/platform/graphics/Font.h" | 34 #import "core/platform/graphics/Font.h" |
| 35 #import "core/platform/graphics/FontPlatformData.h" | 35 #import "core/platform/graphics/FontPlatformData.h" |
| 36 #import "core/platform/graphics/SimpleFontData.h" | 36 #import "core/platform/graphics/SimpleFontData.h" |
| 37 #import "core/platform/mac/WebCoreSystemInterface.h" | 37 #import "core/platform/mac/WebCoreSystemInterface.h" |
| 38 #import "core/platform/mac/WebFontCache.h" | 38 #import "core/platform/mac/WebFontCache.h" |
| 39 #import <wtf/MainThread.h> | 39 #import <wtf/MainThread.h> |
| 40 #import <wtf/StdLibExtras.h> | 40 #import <wtf/StdLibExtras.h> |
| 41 | 41 |
| 42 // Forward declare Mac SPIs. | |
| 43 extern "C" { | |
| 44 void CGFontSetShouldUseMulticache(bool enable); | |
| 45 } | |
| 42 | 46 |
| 43 namespace WebCore { | 47 namespace WebCore { |
| 44 | 48 |
| 45 // The "void*" parameter makes the function match the prototype for callbacks fr om callOnMainThread. | 49 // The "void*" parameter makes the function match the prototype for callbacks fr om callOnMainThread. |
| 46 static void invalidateFontCache(void*) | 50 static void invalidateFontCache(void*) |
| 47 { | 51 { |
| 48 if (!isMainThread()) { | 52 if (!isMainThread()) { |
| 49 callOnMainThread(&invalidateFontCache, 0); | 53 callOnMainThread(&invalidateFontCache, 0); |
| 50 return; | 54 return; |
| 51 } | 55 } |
| 52 fontCache()->invalidate(); | 56 fontCache()->invalidate(); |
| 53 } | 57 } |
| 54 | 58 |
| 55 static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCe nterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef) | 59 static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCe nterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef) |
| 56 { | 60 { |
| 57 ASSERT_UNUSED(observer, observer == fontCache()); | 61 ASSERT_UNUSED(observer, observer == fontCache()); |
| 58 ASSERT_UNUSED(name, CFEqual(name, kCTFontManagerRegisteredFontsChangedNotifi cation)); | 62 ASSERT_UNUSED(name, CFEqual(name, kCTFontManagerRegisteredFontsChangedNotifi cation)); |
| 59 invalidateFontCache(0); | 63 invalidateFontCache(0); |
| 60 } | 64 } |
| 61 | 65 |
| 62 void FontCache::platformInit() | 66 void FontCache::platformInit() |
| 63 { | 67 { |
| 64 WKSetUpFontCache(); | 68 // Note: This may break on future OS releases, per https://bugs.webkit.org/s how_bug.cgi?id=102405#c8. |
|
Nico
2013/05/01 01:02:18
Is there a rdar for getting a public api for this?
Robert Sesek
2013/05/01 23:58:43
Done.
| |
| 69 CGFontSetShouldUseMulticache(true); | |
| 65 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFon tsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately); | 70 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFon tsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately); |
| 66 } | 71 } |
| 67 | 72 |
| 68 static int toAppKitFontWeight(FontWeight fontWeight) | 73 static int toAppKitFontWeight(FontWeight fontWeight) |
| 69 { | 74 { |
| 70 static int appKitFontWeights[] = { | 75 static int appKitFontWeights[] = { |
| 71 2, // FontWeight100 | 76 2, // FontWeight100 |
| 72 3, // FontWeight200 | 77 3, // FontWeight200 |
| 73 4, // FontWeight300 | 78 4, // FontWeight300 |
| 74 5, // FontWeight400 | 79 5, // FontWeight400 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 | 228 |
| 224 // FontPlatformData::font() can be null for the case of Chromium out-of-proc ess font loading. | 229 // FontPlatformData::font() can be null for the case of Chromium out-of-proc ess font loading. |
| 225 // In that case, we don't want to use the platformData. | 230 // In that case, we don't want to use the platformData. |
| 226 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant())); | 231 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant())); |
| 227 if (!platformData->font()) | 232 if (!platformData->font()) |
| 228 return 0; | 233 return 0; |
| 229 return platformData.leakPtr(); | 234 return platformData.leakPtr(); |
| 230 } | 235 } |
| 231 | 236 |
| 232 } // namespace WebCore | 237 } // namespace WebCore |
| OLD | NEW |