Changeset 54601 in webkit
- Timestamp:
- Feb 10, 2010 8:28:27 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r54599 r54601 1 2010-02-10 Julien Chaffraix <jchaffraix@pleyo.com> 2 3 Reviewed by Eric Seidel. 4 5 Bug 23287 - Avoid using FontPlatformData outside the FontCache 6 7 No functional change, only refactored the code using FontPlatformData to use SimpleFontData. 8 9 This change leaves the class FontCached as it needs some thoughts and more refactoring. 10 11 * css/CSSFontFaceSource.cpp: 12 (WebCore::CSSFontFaceSource::getFontData): Call getCachedFontData with the 2 parameters directly. 13 * css/CSSFontSelector.cpp: 14 (WebCore::fontDataForGenericFamily): Ditto. 15 * platform/graphics/FontCache.cpp: 16 (WebCore::FontCache::getCachedFontData): This method is meant to replace getCachedFontPlatformData 17 that was moved in the private section of the class. It calls getCachedFontPlatformData and cache 18 the returned FontPlatformData if it is not null. 19 (WebCore::FontCache::getFontData): Updated to use the new getCachedFontData. 20 * platform/graphics/FontCache.h: Updated several methods to return a SimpleFontData in lieu of a 21 FontPlatformData. Moved some method in the private sections. 22 23 * platform/graphics/chromium/FontCacheChromiumWin.cpp: 24 (WebCore::FontCache::getSimilarFontPlatformData): 25 (WebCore::FontCache::getLastResortFallbackFont): 26 * platform/graphics/chromium/FontCacheLinux.cpp: 27 (WebCore::FontCache::getSimilarFontPlatformData): 28 (WebCore::FontCache::getLastResortFallbackFont): 29 * platform/graphics/gtk/FontCacheGtk.cpp: 30 (WebCore::FontCache::getSimilarFontPlatformData): 31 (WebCore::FontCache::getLastResortFallbackFont): 32 * platform/graphics/haiku/FontCacheHaiku.cpp: 33 (WebCore::FontCache::getSimilarFontPlatformData): 34 (WebCore::FontCache::getLastResortFallbackFont): 35 * platform/graphics/qt/FontCacheQt.cpp: 36 (WebCore::FontCache::getLastResortFallbackFont): 37 * platform/graphics/win/FontCacheWin.cpp: 38 (WebCore::FontCache::getSimilarFontPlatformData): 39 (WebCore::FontCache::getLastResortFallbackFont): 40 * platform/graphics/wince/FontCacheWince.cpp: 41 * platform/graphics/wx/FontCacheWx.cpp: 42 (WebCore::FontCache::getSimilarFontPlatformData): 43 (WebCore::FontCache::getLastResortFallbackFont): 44 Updated all the previous platform methods to return a SimpleFontData. 45 46 * platform/graphics/mac/FontCacheMac.mm: 47 (WebCore::FontCache::getSimilarFontPlatformData): Updated to return a SimpleFontData. 48 (WebCore::FontCache::getLastResortFallbackFont): Ditto. Also refactored the code 49 and moved a DEFINE_STATIC_LOCAL where it is needed. 50 1 51 2010-02-10 Alexander Pavlov <apavlov@chromium.org> 2 52 -
trunk/WebCore/css/CSSFontFaceSource.cpp
r39823 r54601 108 108 if (!m_font) { 109 109 #endif 110 FontPlatformData* data = fontCache()->getCachedFontPlatformData(fontDescription, m_string); 111 SimpleFontData* fontData = fontCache()->getCachedFontData(data); 110 SimpleFontData* fontData = fontCache()->getCachedFontData(fontDescription, m_string); 112 111 113 112 // We're local. Just return a SimpleFontData from the normal cache. … … 180 179 m_font->beginLoadIfNeeded(docLoader); 181 180 // FIXME: m_string is a URL so it makes no sense to pass it as a family name. 182 FontPlatformData* tempData = fontCache()->getCachedFontPlatformData(fontDescription, m_string);181 SimpleFontData* tempData = fontCache()->getCachedFontData(fontDescription, m_string); 183 182 if (!tempData) 184 183 tempData = fontCache()->getLastResortFallbackFont(fontDescription); 185 fontData.set(new SimpleFontData(*tempData, true, true)); 184 185 fontData.set(new SimpleFontData(tempData->platformData(), true, true)); 186 186 } 187 187 -
trunk/WebCore/css/CSSFontSelector.cpp
r51473 r54601 395 395 396 396 if (!genericFamily.isEmpty()) 397 return fontCache()->getCachedFontData(font Cache()->getCachedFontPlatformData(fontDescription, genericFamily));397 return fontCache()->getCachedFontData(fontDescription, genericFamily); 398 398 399 399 return 0; -
trunk/WebCore/platform/graphics/FontCache.cpp
r52791 r54601 258 258 static ListHashSet<const SimpleFontData*>* gInactiveFontData = 0; 259 259 260 SimpleFontData* FontCache::getCachedFontData(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName) 261 { 262 FontPlatformData* platformData = getCachedFontPlatformData(fontDescription, family, checkingAlternateName); 263 if (!platformData) 264 return 0; 265 266 return getCachedFontData(platformData); 267 } 268 260 269 SimpleFontData* FontCache::getCachedFontData(const FontPlatformData* platformData) 261 270 { … … 362 371 const FontData* FontCache::getFontData(const Font& font, int& familyIndex, FontSelector* fontSelector) 363 372 { 364 FontPlatformData* result = 0;373 SimpleFontData* result = 0; 365 374 366 375 int startIndex = familyIndex; … … 377 386 return data; 378 387 } 379 result = getCachedFont PlatformData(font.fontDescription(), currFamily->family());388 result = getCachedFontData(font.fontDescription(), currFamily->family()); 380 389 } 381 390 currFamily = currFamily->next(); … … 404 413 result = getLastResortFallbackFont(font.fontDescription()); 405 414 } 406 407 // Now that we have a result, we need to go from FontPlatformData -> FontData. 408 return getCachedFontData(result); 415 return result; 409 416 } 410 417 -
trunk/WebCore/platform/graphics/FontCache.h
r52791 r54601 79 79 void getTraitsInFamily(const AtomicString&, Vector<unsigned>&); 80 80 81 FontPlatformData* getCachedFontPlatformData(const FontDescription&, const AtomicString& family, bool checkingAlternateName = false); 82 SimpleFontData* getCachedFontData(const FontPlatformData*); 83 FontPlatformData* getLastResortFallbackFont(const FontDescription&); 81 SimpleFontData* getCachedFontData(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName = false); 82 SimpleFontData* getLastResortFallbackFont(const FontDescription&); 84 83 85 84 void addClient(FontSelector*); … … 97 96 ~FontCache(); 98 97 98 // FIXME: This method should eventually be removed. 99 FontPlatformData* getCachedFontPlatformData(const FontDescription&, const AtomicString& family, bool checkingAlternateName = false); 100 99 101 // These methods are implemented by each platform. 100 FontPlatformData* getSimilarFontPlatformData(const Font&);102 SimpleFontData* getSimilarFontPlatformData(const Font&); 101 103 FontPlatformData* createFontPlatformData(const FontDescription&, const AtomicString& family); 102 104 103 friend class SimpleFontData; 105 SimpleFontData* getCachedFontData(const FontPlatformData*); 106 107 friend class SimpleFontData; // For getCachedFontData(const FontPlatformData*) 104 108 friend class FontFallbackList; 105 109 }; … … 107 111 // Get the global fontCache. 108 112 FontCache* fontCache(); 113 109 114 } 110 115 -
trunk/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp
r47506 r54601 407 407 } 408 408 409 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)409 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font) 410 410 { 411 411 return 0; 412 412 } 413 413 414 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& description)414 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& description) 415 415 { 416 416 FontDescription::GenericFamilyType generic = description.genericFamily(); … … 429 429 fontStr = courierStr; 430 430 431 return getCachedFont PlatformData(description, fontStr);431 return getCachedFontData(description, fontStr); 432 432 } 433 433 -
trunk/WebCore/platform/graphics/chromium/FontCacheLinux.cpp
r45191 r54601 67 67 } 68 68 69 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)69 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font) 70 70 { 71 71 return 0; 72 72 } 73 73 74 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& description)74 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& description) 75 75 { 76 76 static const AtomicString sansStr("Sans"); … … 93 93 94 94 ASSERT(fontPlatformData); 95 return fontPlatformData;95 return getCachedFontData(fontPlatformData); 96 96 } 97 97 -
trunk/WebCore/platform/graphics/gtk/FontCacheGtk.cpp
r44456 r54601 60 60 } 61 61 62 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)62 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font) 63 63 { 64 64 return 0; 65 65 } 66 66 67 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)67 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription) 68 68 { 69 69 // FIXME: Would be even better to somehow get the user's default font here. 70 70 // For now we'll pick the default that the user would get without changing any prefs. 71 71 static AtomicString timesStr("Times New Roman"); 72 return getCachedFont PlatformData(fontDescription, timesStr);72 return getCachedFontData(fontDescription, timesStr); 73 73 } 74 74 -
trunk/WebCore/platform/graphics/haiku/FontCacheHaiku.cpp
r47637 r54601 52 52 } 53 53 54 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)54 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font) 55 55 { 56 56 notImplemented(); … … 58 58 } 59 59 60 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)60 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription) 61 61 { 62 62 // FIXME: Would be even better to somehow get the user's default font here. 63 63 // For now we'll pick the default that the user would get without changing any prefs. 64 64 static AtomicString defaultString("DejaVu Serif"); 65 return getCachedFont PlatformData(fontDescription, defaultString);65 return getCachedFontData(fontDescription, defaultString); 66 66 } 67 67 -
trunk/WebCore/platform/graphics/mac/FontCacheMac.mm
r44389 r54601 147 147 } 148 148 149 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)149 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font) 150 150 { 151 151 // Attempt to find an appropriate font using a match based on 152 152 // the presence of keywords in the the requested names. For example, we'll 153 153 // match any name that contains "Arabic" to Geeza Pro. 154 FontPlatformData* platformData = 0;154 SimpleFontData* simpleFontData = 0; 155 155 const FontFamily* currFamily = &font.fontDescription().family(); 156 while (currFamily && ! platformData) {156 while (currFamily && !simpleFontData) { 157 157 if (currFamily->family().length()) { 158 158 static String* matchWords[3] = { new String("Arabic"), new String("Pashto"), new String("Urdu") }; 159 159 DEFINE_STATIC_LOCAL(AtomicString, geezaStr, ("Geeza Pro")); 160 for (int j = 0; j < 3 && ! platformData; ++j)160 for (int j = 0; j < 3 && !simpleFontData; ++j) 161 161 if (currFamily->family().contains(*matchWords[j], false)) 162 platformData = getCachedFontPlatformData(font.fontDescription(), geezaStr);162 simpleFontData = getCachedFontData(font.fontDescription(), geezaStr); 163 163 } 164 164 currFamily = currFamily->next(); 165 165 } 166 166 167 return platformData;168 } 169 170 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)167 return simpleFontData; 168 } 169 170 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription) 171 171 { 172 172 DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times")); 173 DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande"));174 173 175 174 // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick 176 175 // the default that the user would get without changing any prefs. 177 FontPlatformData* platformFont = getCachedFontPlatformData(fontDescription, timesStr); 178 if (!platformFont) 179 // The Times fallback will almost always work, but in the highly unusual case where 180 // the user doesn't have it, we fall back on Lucida Grande because that's 181 // guaranteed to be there, according to Nathan Taylor. This is good enough 182 // to avoid a crash at least. 183 platformFont = getCachedFontPlatformData(fontDescription, lucidaGrandeStr); 184 185 return platformFont; 176 SimpleFontData* simpleFontData = getCachedFontData(fontDescription, timesStr); 177 if (simpleFontData) 178 return simpleFontData; 179 180 // The Times fallback will almost always work, but in the highly unusual case where 181 // the user doesn't have it, we fall back on Lucida Grande because that's 182 // guaranteed to be there, according to Nathan Taylor. This is good enough 183 // to avoid a crash at least. 184 DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande")); 185 return getCachedFontData(fontDescription, lucidaGrandeStr); 186 186 } 187 187 -
trunk/WebCore/platform/graphics/qt/FontCacheQt.cpp
r52310 r54601 50 50 } 51 51 52 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)52 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font) 53 53 { 54 54 return 0; 55 55 } 56 56 57 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)57 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription) 58 58 { 59 59 const AtomicString fallbackFamily = QFont(fontDescription.family().family()).lastResortFamily(); 60 return new FontPlatformData(fontDescription, fallbackFamily);60 return getCachedFontData(new FontPlatformData(fontDescription, fallbackFamily)); 61 61 } 62 62 -
trunk/WebCore/platform/graphics/win/FontCacheWin.cpp
r52371 r54601 297 297 } 298 298 299 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)299 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font) 300 300 { 301 301 return 0; 302 302 } 303 303 304 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)304 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription) 305 305 { 306 306 // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick … … 317 317 defaultGUIFontFamily = String(logFont.lfFaceName, wcsnlen(logFont.lfFaceName, LF_FACESIZE)); 318 318 } 319 return getCachedFont PlatformData(fontDescription, defaultGUIFontFamily);319 return getCachedFontData(fontDescription, defaultGUIFontFamily); 320 320 } 321 321 -
trunk/WebCore/platform/graphics/wince/FontCacheWince.cpp
r46196 r54601 317 317 } 318 318 319 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)319 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font) 320 320 { 321 321 return 0; 322 322 } 323 323 324 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDesc)324 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDesc) 325 325 { 326 326 // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick 327 327 // the default that the user would get without changing any prefs. 328 return getCachedFont PlatformData(fontDesc, FontPlatformData::defaultFontFamily());328 return getCachedFontData(fontDesc, FontPlatformData::defaultFontFamily()); 329 329 } 330 330 -
trunk/WebCore/platform/graphics/wx/FontCacheWx.cpp
r37118 r54601 47 47 } 48 48 49 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)49 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font) 50 50 { 51 return new FontPlatformData(font.fontDescription(), font.family().family());51 return getCachedFontData(font.fontDescription(), font.family().family()); 52 52 } 53 53 54 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)54 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription) 55 55 { 56 56 // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick 57 57 // the default that the user would get without changing any prefs. 58 58 static AtomicString timesStr("systemfont"); 59 return getCachedFont PlatformData(fontDescription, timesStr);59 return getCachedFontData(fontDescription, timesStr); 60 60 } 61 61
Note: See TracChangeset
for help on using the changeset viewer.