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

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

Issue 14856004: Finish removing WebKitSystemInterface from Blink. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Simplify Created 7 years, 7 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
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 16 matching lines...) Expand all
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 "core/platform/graphics/FontCache.h"
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"
38 #import "core/platform/mac/WebFontCache.h" 37 #import "core/platform/mac/WebFontCache.h"
39 #import <wtf/MainThread.h> 38 #import <wtf/MainThread.h>
40 #import <wtf/StdLibExtras.h> 39 #import <wtf/StdLibExtras.h>
41 40
42 // Forward declare Mac SPIs. 41 // Forward declare Mac SPIs.
43 // Request for public API: rdar://13787490 42 // Request for public API: rdar://13787490
44 extern "C" { 43 extern "C" {
45 void CGFontSetShouldUseMulticache(bool enable); 44 void CGFontSetShouldUseMulticache(bool enable);
46 } 45 }
47 46
47 // Request for public API: rdar://13803570
48 @interface NSFont (WebKitSPI)
49 + (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;
51 @end
52
48 namespace WebCore { 53 namespace WebCore {
49 54
50 // The "void*" parameter makes the function match the prototype for callbacks fr om callOnMainThread. 55 // The "void*" parameter makes the function match the prototype for callbacks fr om callOnMainThread.
51 static void invalidateFontCache(void*) 56 static void invalidateFontCache(void*)
52 { 57 {
53 if (!isMainThread()) { 58 if (!isMainThread()) {
54 callOnMainThread(&invalidateFontCache, 0); 59 callOnMainThread(&invalidateFontCache, 0);
55 return; 60 return;
56 } 61 }
57 fontCache()->invalidate(); 62 fontCache()->invalidate();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 98 }
94 99
95 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) 100 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
96 { 101 {
97 UChar32 character; 102 UChar32 character;
98 U16_GET(characters, 0, 0, length, character); 103 U16_GET(characters, 0, 0, length, character);
99 const FontPlatformData& platformData = font.fontDataAt(0)->fontDataForCharac ter(character)->platformData(); 104 const FontPlatformData& platformData = font.fontDataAt(0)->fontDataForCharac ter(character)->platformData();
100 NSFont *nsFont = platformData.font(); 105 NSFont *nsFont = platformData.font();
101 106
102 NSString *string = [[NSString alloc] initWithCharactersNoCopy:const_cast<UCh ar*>(characters) length:length freeWhenDone:NO]; 107 NSString *string = [[NSString alloc] initWithCharactersNoCopy:const_cast<UCh ar*>(characters) length:length freeWhenDone:NO];
103 NSFont *substituteFont = WKGetFontInLanguageForRange(nsFont, string, NSMakeR ange(0, length)); 108 NSFont *substituteFont = [NSFont findFontLike:nsFont forString:string withRa nge:NSMakeRange(0, length) inLanguage:nil];
104 [string release]; 109 [string release];
105 110
106 if (!substituteFont && length == 1) 111 if (!substituteFont && length == 1)
107 substituteFont = WKGetFontInLanguageForCharacter(nsFont, characters[0]); 112 substituteFont = [NSFont findFontLike:nsFont forCharacter:characters[0] inLanguage:nil];
108 if (!substituteFont) 113 if (!substituteFont)
109 return 0; 114 return 0;
110 115
111 // Chromium can't render AppleColorEmoji. 116 // Chromium can't render AppleColorEmoji.
112 if ([[substituteFont familyName] isEqual:@"Apple Color Emoji"]) 117 if ([[substituteFont familyName] isEqual:@"Apple Color Emoji"])
113 return 0; 118 return 0;
114 119
115 // Use the family name from the AppKit-supplied substitute font, requesting the 120 // Use the family name from the AppKit-supplied substitute font, requesting the
116 // traits, weight, and size we want. One way this does better than the origi nal 121 // traits, weight, and size we want. One way this does better than the origi nal
117 // AppKit request is that it takes synthetic bold and oblique into account. 122 // AppKit request is that it takes synthetic bold and oblique into account.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 234
230 // FontPlatformData::font() can be null for the case of Chromium out-of-proc ess font loading. 235 // FontPlatformData::font() can be null for the case of Chromium out-of-proc ess font loading.
231 // In that case, we don't want to use the platformData. 236 // In that case, we don't want to use the platformData.
232 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant())); 237 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant()));
233 if (!platformData->font()) 238 if (!platformData->font())
234 return 0; 239 return 0;
235 return platformData.leakPtr(); 240 return platformData.leakPtr();
236 } 241 }
237 242
238 } // namespace WebCore 243 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698