Changeset 178028 in webkit
- Timestamp:
- Jan 7, 2015, 1:51:48 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r178025 r178028 1 2015-01-06 Antti Koivisto <antti@apple.com> 2 3 Use HashMap instead of CFDictionary for composite font reference map 4 https://bugs.webkit.org/show_bug.cgi?id=140150 5 6 Reviewed by Geoff Garen. 7 8 Use WebKit types. Also use USE(APPKIT) consistently for this feature. 9 10 * platform/graphics/SimpleFontData.cpp: 11 (WebCore::SimpleFontData::DerivedFontData::~DerivedFontData): 12 13 The whole desctructor gets handled implicitly. 14 15 * platform/graphics/SimpleFontData.h: 16 * platform/graphics/mac/GlyphPageMac.cpp: 17 (WebCore::GlyphPage::mayUseMixedFontDataWhenFilling): 18 (WebCore::GlyphPage::fill): 19 * platform/graphics/mac/SimpleFontDataMac.mm: 20 (WebCore::SimpleFontData::compositeFontReferenceFontData): 21 (WebCore::SimpleFontData::getCompositeFontReferenceFontData): Deleted. 22 1 23 2015-01-07 Mihnea Ovidenie <mihnea@adobe.com> 2 24 -
trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp
r177984 r178028 389 389 SimpleFontData::DerivedFontData::~DerivedFontData() 390 390 { 391 #if PLATFORM(COCOA)392 if (compositeFontReferences) {393 // FIXME: Why don't we use WebKit types here?394 CFDictionaryRef dictionary = CFDictionaryRef(compositeFontReferences.get());395 CFIndex count = CFDictionaryGetCount(dictionary);396 if (count > 0) {397 Vector<SimpleFontData*, 2> stash(count);398 SimpleFontData** fonts = stash.data();399 CFDictionaryGetKeysAndValues(dictionary, 0, (const void **)fonts);400 // This deletes the fonts.401 while (count-- > 0 && *fonts)402 adoptRef(*fonts++);403 }404 }405 #endif406 391 } 407 392 -
trunk/Source/WebCore/platform/graphics/SimpleFontData.h
r177979 r178028 188 188 189 189 #if USE(APPKIT) 190 const SimpleFontData* getCompositeFontReferenceFontData(NSFont *key) const;190 const SimpleFontData* compositeFontReferenceFontData(NSFont *key) const; 191 191 NSFont* getNSFont() const { return m_platformData.nsFont(); } 192 192 #endif … … 296 296 RefPtr<SimpleFontData> uprightOrientation; 297 297 RefPtr<SimpleFontData> nonSyntheticItalic; 298 #if PLATFORM(COCOA)299 mutable RetainPtr<CFMutableDictionaryRef> compositeFontReferences;298 #if USE(APPKIT) 299 HashMap<NSFont*, RefPtr<SimpleFontData>> compositeFontReferences; 300 300 #endif 301 301 }; -
trunk/Source/WebCore/platform/graphics/mac/GlyphPageMac.cpp
r177876 r178028 58 58 bool GlyphPage::mayUseMixedFontDataWhenFilling(const UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData) 59 59 { 60 // FIXME: This could be smarter if the logic currently in GlyphPage::fill() got to make the decision about what kind of GlyphPage to construct. 60 #if USE(APPKIT) 61 // FIXME: This is only really needed for composite font references. 61 62 return shouldUseCoreText(buffer, bufferLength, fontData); 63 #else 64 return false; 65 #endif 62 66 } 63 67 … … 155 159 } 156 160 } 157 #if !PLATFORM(IOS)161 #if USE(APPKIT) 158 162 } else { 159 const SimpleFontData* runSimple = fontData-> getCompositeFontReferenceFontData((NSFont *)runFont);163 const SimpleFontData* runSimple = fontData->compositeFontReferenceFontData((NSFont *)runFont); 160 164 if (runSimple) { 161 165 for (CFIndex i = 0; i < glyphCount; ++i) { … … 170 174 } 171 175 } 172 #endif // !PLATFORM(IOS)176 #endif 173 177 } 174 178 } -
trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
r177876 r178028 86 86 } 87 87 88 const SimpleFontData* SimpleFontData::getCompositeFontReferenceFontData(NSFont *key) const 89 { 90 if (key && !CFEqual(adoptCF(CTFontCopyPostScriptName(CTFontRef(key))).get(), CFSTR("LastResort"))) { 91 if (!m_derivedFontData) 92 m_derivedFontData = std::make_unique<DerivedFontData>(isCustomFont()); 93 if (!m_derivedFontData->compositeFontReferences) 94 m_derivedFontData->compositeFontReferences = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, NULL)); 95 else { 96 const SimpleFontData* found = static_cast<const SimpleFontData*>(CFDictionaryGetValue(m_derivedFontData->compositeFontReferences.get(), static_cast<const void *>(key))); 97 if (found) 98 return found; 99 } 100 if (CFMutableDictionaryRef dictionary = m_derivedFontData->compositeFontReferences.get()) { 101 bool isUsingPrinterFont = platformData().isPrinterFont(); 102 NSFont *substituteFont = isUsingPrinterFont ? [key printerFont] : [key screenFont]; 103 104 CTFontSymbolicTraits traits = CTFontGetSymbolicTraits((CTFontRef)substituteFont); 105 bool syntheticBold = platformData().syntheticBold() && !(traits & kCTFontBoldTrait); 106 bool syntheticOblique = platformData().syntheticOblique() && !(traits & kCTFontItalicTrait); 107 108 FontPlatformData substitutePlatform(substituteFont, platformData().size(), isUsingPrinterFont, syntheticBold, syntheticOblique, platformData().orientation(), platformData().widthVariant()); 109 if (RefPtr<SimpleFontData> value = adoptRef(new SimpleFontData(substitutePlatform, isCustomFont()))) { 110 SimpleFontData* valuePtr = value.get(); 111 CFDictionaryAddValue(dictionary, key, value.release().leakRef()); 112 return valuePtr; 113 } 114 } 115 } 116 return 0; 88 const SimpleFontData* SimpleFontData::compositeFontReferenceFontData(NSFont *key) const 89 { 90 if (!key || CFEqual(adoptCF(CTFontCopyPostScriptName(CTFontRef(key))).get(), CFSTR("LastResort"))) 91 return nullptr; 92 93 if (!m_derivedFontData) 94 m_derivedFontData = std::make_unique<DerivedFontData>(isCustomFont()); 95 96 auto addResult = m_derivedFontData->compositeFontReferences.add(key, nullptr); 97 if (addResult.isNewEntry) { 98 bool isUsingPrinterFont = platformData().isPrinterFont(); 99 NSFont *substituteFont = isUsingPrinterFont ? [key printerFont] : [key screenFont]; 100 101 CTFontSymbolicTraits traits = CTFontGetSymbolicTraits((CTFontRef)substituteFont); 102 bool syntheticBold = platformData().syntheticBold() && !(traits & kCTFontBoldTrait); 103 bool syntheticOblique = platformData().syntheticOblique() && !(traits & kCTFontItalicTrait); 104 105 FontPlatformData substitutePlatform(substituteFont, platformData().size(), isUsingPrinterFont, syntheticBold, syntheticOblique, platformData().orientation(), platformData().widthVariant()); 106 addResult.iterator->value = SimpleFontData::create(substitutePlatform, isCustomFont()); 107 } 108 return addResult.iterator->value.get(); 117 109 } 118 110
Note:
See TracChangeset
for help on using the changeset viewer.