| 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 10 matching lines...) Expand all Loading... |
| 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #import "config.h" | 30 #import "config.h" |
| 31 #import "core/platform/graphics/FontCache.h" | 31 #import "platform/fonts/FontCache.h" |
| 32 | 32 |
| 33 #import <AppKit/AppKit.h> | 33 #import <AppKit/AppKit.h> |
| 34 #import "core/platform/graphics/FontPlatformData.h" | |
| 35 #import "core/platform/graphics/SimpleFontData.h" | |
| 36 #import "platform/fonts/FontDescription.h" | 34 #import "platform/fonts/FontDescription.h" |
| 35 #import "platform/fonts/FontPlatformData.h" |
| 36 #import "platform/fonts/SimpleFontData.h" |
| 37 #import "platform/mac/WebFontCache.h" | 37 #import "platform/mac/WebFontCache.h" |
| 38 #import <wtf/MainThread.h> | 38 #import <wtf/MainThread.h> |
| 39 #import <wtf/StdLibExtras.h> | 39 #import <wtf/StdLibExtras.h> |
| 40 | 40 |
| 41 // Forward declare Mac SPIs. | 41 // Forward declare Mac SPIs. |
| 42 // Request for public API: rdar://13803570 | 42 // Request for public API: rdar://13803570 |
| 43 @interface NSFont (WebKitSPI) | 43 @interface NSFont (WebKitSPI) |
| 44 + (NSFont*)findFontLike:(NSFont*)font forString:(NSString*)string withRange:(NSR
ange)range inLanguage:(id)useNil; | 44 + (NSFont*)findFontLike:(NSFont*)font forString:(NSString*)string withRange:(NSR
ange)range inLanguage:(id)useNil; |
| 45 + (NSFont*)findFontLike:(NSFont*)font forCharacter:(UniChar)uc inLanguage:(id)us
eNil; | 45 + (NSFont*)findFontLike:(NSFont*)font forCharacter:(UniChar)uc inLanguage:(id)us
eNil; |
| 46 @end | 46 @end |
| 47 | 47 |
| 48 namespace WebCore { | 48 namespace WebCore { |
| 49 | 49 |
| 50 // The "void*" parameter makes the function match the prototype for callbacks fr
om callOnMainThread. | 50 // The "void*" parameter makes the function match the prototype for callbacks fr
om callOnMainThread. |
| 51 static void invalidateFontCache(void*) | 51 static void invalidateFontCache(void*) |
| 52 { | 52 { |
| 53 if (!isMainThread()) { | 53 if (!isMainThread()) { |
| 54 callOnMainThread(&invalidateFontCache, 0); | 54 callOnMainThread(&invalidateFontCache, 0); |
| 55 return; | 55 return; |
| 56 } | 56 } |
| 57 fontCache()->invalidate(); | 57 FontCache::fontCache()->invalidate(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCe
nterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef) | 60 static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCe
nterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef) |
| 61 { | 61 { |
| 62 ASSERT_UNUSED(observer, observer == fontCache()); | 62 ASSERT_UNUSED(observer, observer == FontCache::fontCache()); |
| 63 ASSERT_UNUSED(name, CFEqual(name, kCTFontManagerRegisteredFontsChangedNotifi
cation)); | 63 ASSERT_UNUSED(name, CFEqual(name, kCTFontManagerRegisteredFontsChangedNotifi
cation)); |
| 64 invalidateFontCache(0); | 64 invalidateFontCache(0); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void FontCache::platformInit() | 67 void FontCache::platformInit() |
| 68 { | 68 { |
| 69 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this,
fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFon
tsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately); | 69 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this,
fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFon
tsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately); |
| 70 } | 70 } |
| 71 | 71 |
| 72 static int toAppKitFontWeight(FontWeight fontWeight) | 72 static int toAppKitFontWeight(FontWeight fontWeight) |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 // FontPlatformData::font() can be null for the case of Chromium out-of-proc
ess font loading. | 214 // FontPlatformData::font() can be null for the case of Chromium out-of-proc
ess font loading. |
| 215 // In that case, we don't want to use the platformData. | 215 // In that case, we don't want to use the platformData. |
| 216 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique,
fontDescription.orientation(), fontDescription.widthVariant())); | 216 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo
rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique,
fontDescription.orientation(), fontDescription.widthVariant())); |
| 217 if (!platformData->font()) | 217 if (!platformData->font()) |
| 218 return 0; | 218 return 0; |
| 219 return platformData.leakPtr(); | 219 return platformData.leakPtr(); |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // namespace WebCore | 222 } // namespace WebCore |
| OLD | NEW |