Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: Source/core/platform/graphics/mac/FontCacheMac.mm

Issue 18140002: Do not call CGFontSetShouldUseMulticache. Apple says to not. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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/WebFontCache.h" 37 #import "core/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://13787490
43 extern "C" {
44 void CGFontSetShouldUseMulticache(bool enable);
45 }
46
47 // Request for public API: rdar://13803570 42 // Request for public API: rdar://13803570
48 @interface NSFont (WebKitSPI) 43 @interface NSFont (WebKitSPI)
49 + (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;
50 + (NSFont*)findFontLike:(NSFont*)font forCharacter:(UniChar)uc inLanguage:(id)us eNil; 45 + (NSFont*)findFontLike:(NSFont*)font forCharacter:(UniChar)uc inLanguage:(id)us eNil;
51 @end 46 @end
52 47
53 namespace WebCore { 48 namespace WebCore {
54 49
55 // 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.
56 static void invalidateFontCache(void*) 51 static void invalidateFontCache(void*)
57 { 52 {
58 if (!isMainThread()) { 53 if (!isMainThread()) {
59 callOnMainThread(&invalidateFontCache, 0); 54 callOnMainThread(&invalidateFontCache, 0);
60 return; 55 return;
61 } 56 }
62 fontCache()->invalidate(); 57 fontCache()->invalidate();
63 } 58 }
64 59
65 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)
66 { 61 {
67 ASSERT_UNUSED(observer, observer == fontCache()); 62 ASSERT_UNUSED(observer, observer == fontCache());
68 ASSERT_UNUSED(name, CFEqual(name, kCTFontManagerRegisteredFontsChangedNotifi cation)); 63 ASSERT_UNUSED(name, CFEqual(name, kCTFontManagerRegisteredFontsChangedNotifi cation));
69 invalidateFontCache(0); 64 invalidateFontCache(0);
70 } 65 }
71 66
72 void FontCache::platformInit() 67 void FontCache::platformInit()
73 { 68 {
74 // Note: This may break on future OS releases, per https://bugs.webkit.org/s how_bug.cgi?id=102405#c8.
75 CGFontSetShouldUseMulticache(true);
76 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFon tsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately); 69 CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFon tsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately);
77 } 70 }
78 71
79 static int toAppKitFontWeight(FontWeight fontWeight) 72 static int toAppKitFontWeight(FontWeight fontWeight)
80 { 73 {
81 static int appKitFontWeights[] = { 74 static int appKitFontWeights[] = {
82 2, // FontWeight100 75 2, // FontWeight100
83 3, // FontWeight200 76 3, // FontWeight200
84 4, // FontWeight300 77 4, // FontWeight300
85 5, // FontWeight400 78 5, // FontWeight400
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 227
235 // FontPlatformData::font() can be null for the case of Chromium out-of-proc ess font loading. 228 // FontPlatformData::font() can be null for the case of Chromium out-of-proc ess font loading.
236 // In that case, we don't want to use the platformData. 229 // In that case, we don't want to use the platformData.
237 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant())); 230 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant()));
238 if (!platformData->font()) 231 if (!platformData->font())
239 return 0; 232 return 0;
240 return platformData.leakPtr(); 233 return platformData.leakPtr();
241 } 234 }
242 235
243 } // namespace WebCore 236 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698