Changeset 130160 in webkit
- Timestamp:
- Oct 2, 2012, 6:03:18 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 45 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r130158 r130160 1 2012-10-02 Stephen Chenney <schenney@chromium.org> 2 3 Refactor WebCore::FontData handling to clarify pointer ownership 4 https://bugs.webkit.org/show_bug.cgi?id=95866 5 6 Reviewed by Eric Seidel. 7 8 Re-commit for a rolled-out original, now with Chromium Windows build fix. 9 10 This patch makes all FontData and derived classes ref-counted in all 11 code paths that lead to caching or other retention of a 12 pointer. The goal is to avert crashes and memory leaks, and to bring 13 the code more in line with current WebKit practices. 14 15 Specifically, this patch allows us to use ref pointers for all the 16 FontData stored in FontFallbackList objects. The FontFallbackList can 17 then own custom font data and manage its lifetime (forthcoming patch). 18 Currently Document owns custom font data and does an end run around 19 FontFallbackList in deleting glyph pages and custom font data, leaving 20 FontFallbackList with invalid pointers. 21 22 All FontData derived classes have been switched to use static create 23 methods with private constructors. 24 25 All caches that hold FontData now use RefPtrs. 26 27 All methods that construct new font data now return PassRefPtr, with the 28 exception of code only used to generate temporary data for text run layout. 29 30 All methods that handle FontData in a call stack that passes through 31 FontFallbackList::fontDataAt return PassRefPtr. 32 33 Performance tested with both WebKit Perf-o-matic, which showed 34 performance changes in the noise, and Chrome's page cycling tests with 35 the acid3 benchmark set, which showed no performance difference at all. 36 37 No new tests as this is refactoring code only and has no impact on functionality. 38 39 * css/CSSFontFace.cpp: 40 (WebCore::CSSFontFace::getFontData): 41 * css/CSSFontFace.h: 42 (CSSFontFace): 43 * css/CSSFontFaceSource.cpp: 44 (WebCore::CSSFontFaceSource::getFontData): 45 * css/CSSFontFaceSource.h: 46 (CSSFontFaceSource): 47 * css/CSSFontSelector.cpp: 48 (WebCore::fontDataForGenericFamily): 49 (WebCore::CSSFontSelector::getFontData): 50 * css/CSSFontSelector.h: 51 * css/CSSSegmentedFontFace.cpp: 52 (WebCore::appendFontDataWithInvalidUnicodeRangeIfLoading): 53 (WebCore::CSSSegmentedFontFace::getFontData): 54 * css/CSSSegmentedFontFace.h: 55 (CSSSegmentedFontFace): 56 * dom/Document.cpp: 57 (WebCore::Document::registerCustomFont): 58 * dom/Document.h: 59 (Document): 60 * platform/graphics/Font.h: 61 (WebCore): 62 * platform/graphics/FontCache.cpp: 63 (WebCore): 64 (WebCore::FontCache::getCachedFontData): 65 (WebCore::FontCache::getNonRetainedLastResortFallbackFont): 66 (WebCore::FontCache::releaseFontData): 67 (WebCore::FontCache::purgeInactiveFontData): 68 (WebCore::FontCache::getFontData): 69 * platform/graphics/FontCache.h: 70 (FontCache): 71 * platform/graphics/FontData.h: 72 * platform/graphics/FontFallbackList.cpp: 73 (WebCore::FontFallbackList::releaseFontData): 74 (WebCore::FontFallbackList::fontDataAt): 75 (WebCore::FontFallbackList::setPlatformFont): 76 * platform/graphics/FontFallbackList.h: 77 (FontFallbackList): 78 * platform/graphics/FontFastPath.cpp: 79 (WebCore::Font::glyphDataAndPageForCharacter): 80 * platform/graphics/FontSelector.h: 81 (FontSelector): 82 * platform/graphics/GlyphPageTreeNode.cpp: 83 (WebCore::GlyphPageTreeNode::initializePage): 84 * platform/graphics/SegmentedFontData.cpp: 85 (WebCore::SegmentedFontData::fontDataForCharacter): 86 * platform/graphics/SegmentedFontData.h: 87 (WebCore::FontDataRange::FontDataRange): 88 (WebCore::FontDataRange::fontData): 89 (FontDataRange): 90 (WebCore::SegmentedFontData::create): 91 (SegmentedFontData): 92 (WebCore::SegmentedFontData::SegmentedFontData): 93 * platform/graphics/SimpleFontData.cpp: 94 (WebCore::SimpleFontData::verticalRightOrientationFontData): 95 (WebCore::SimpleFontData::uprightOrientationFontData): 96 (WebCore::SimpleFontData::brokenIdeographFontData): 97 * platform/graphics/SimpleFontData.h: 98 (WebCore::SimpleFontData::create): 99 (SimpleFontData): 100 (WebCore::SimpleFontData::variantFontData): 101 (DerivedFontData): 102 * platform/graphics/chromium/FontCacheAndroid.cpp: 103 (WebCore::FontCache::getFontDataForCharacters): 104 (WebCore::FontCache::getSimilarFontPlatformData): 105 (WebCore::FontCache::getLastResortFallbackFont): 106 * platform/graphics/chromium/FontCacheChromiumWin.cpp: 107 (WebCore::FontCache::fontDataFromDescriptionAndLogFont): 108 (GetLastResortFallbackFontProcData): 109 (WebCore::FontCache::getFontDataForCharacters): 110 (WebCore::FontCache::getSimilarFontPlatformData): 111 (WebCore::FontCache::getLastResortFallbackFont): 112 * platform/graphics/chromium/SimpleFontDataChromiumWin.cpp: 113 (WebCore::SimpleFontData::createScaledFontData): 114 (WebCore::SimpleFontData::smallCapsFontData): 115 (WebCore::SimpleFontData::emphasisMarkFontData): 116 * platform/graphics/freetype/FontCacheFreeType.cpp: 117 (WebCore::FontCache::getFontDataForCharacters): 118 (WebCore::FontCache::getSimilarFontPlatformData): 119 (WebCore::FontCache::getLastResortFallbackFont): 120 * platform/graphics/freetype/SimpleFontDataFreeType.cpp: 121 (WebCore::SimpleFontData::createScaledFontData): 122 (WebCore::SimpleFontData::smallCapsFontData): 123 (WebCore::SimpleFontData::emphasisMarkFontData): 124 * platform/graphics/mac/ComplexTextControllerCoreText.mm: 125 (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): 126 * platform/graphics/mac/FontCacheMac.mm: 127 (WebCore::FontCache::getFontDataForCharacters): 128 (WebCore::FontCache::getSimilarFontPlatformData): 129 (WebCore::FontCache::getLastResortFallbackFont): 130 * platform/graphics/mac/FontComplexTextMac.cpp: 131 (WebCore::Font::fontDataForCombiningCharacterSequence): 132 * platform/graphics/mac/SimpleFontDataMac.mm: 133 (WebCore::SimpleFontData::platformDestroy): 134 (WebCore::SimpleFontData::createScaledFontData): 135 (WebCore::SimpleFontData::smallCapsFontData): 136 (WebCore::SimpleFontData::emphasisMarkFontData): 137 * platform/graphics/pango/FontCachePango.cpp: 138 (WebCore::FontCache::getFontDataForCharacters): 139 (WebCore::FontCache::getSimilarFontPlatformData): 140 (WebCore::FontCache::getLastResortFallbackFont): 141 * platform/graphics/pango/SimpleFontDataPango.cpp: 142 (WebCore::SimpleFontData::createScaledFontData): 143 (WebCore::SimpleFontData::smallCapsFontData): 144 (WebCore::SimpleFontData::emphasisMarkFontData): 145 * platform/graphics/qt/FontCacheQt.cpp: 146 (WebCore::FontCache::getFontDataForCharacters): 147 (WebCore::FontCache::getSimilarFontPlatformData): 148 (WebCore::FontCache::getLastResortFallbackFont): 149 * platform/graphics/qt/SimpleFontDataQt.cpp: 150 (WebCore::SimpleFontData::createScaledFontData): 151 (WebCore::SimpleFontData::smallCapsFontData): 152 (WebCore::SimpleFontData::emphasisMarkFontData): 153 * platform/graphics/skia/FontCacheSkia.cpp: 154 (WebCore::FontCache::getFontDataForCharacters): 155 (WebCore::FontCache::getSimilarFontPlatformData): 156 (WebCore::FontCache::getLastResortFallbackFont): 157 * platform/graphics/skia/SimpleFontDataSkia.cpp: 158 (WebCore::SimpleFontData::createScaledFontData): 159 (WebCore::SimpleFontData::smallCapsFontData): 160 (WebCore::SimpleFontData::emphasisMarkFontData): 161 * platform/graphics/win/FontCacheWin.cpp: 162 (WebCore::FontCache::getFontDataForCharacters): 163 (WebCore::FontCache::getSimilarFontPlatformData): 164 (WebCore::FontCache::fontDataFromDescriptionAndLogFont): 165 (WebCore::FontCache::getLastResortFallbackFont): 166 * platform/graphics/win/SimpleFontDataWin.cpp: 167 (WebCore::SimpleFontData::createScaledFontData): 168 (WebCore::SimpleFontData::smallCapsFontData): 169 (WebCore::SimpleFontData::emphasisMarkFontData): 170 * platform/graphics/wince/FontCacheWinCE.cpp: 171 (WebCore::FontCache::getFontDataForCharacters): 172 (WebCore::FontCache::getSimilarFontPlatformData): 173 (WebCore::FontCache::getLastResortFallbackFont): 174 * platform/graphics/wince/SimpleFontDataWinCE.cpp: 175 (WebCore::SimpleFontData::createScaledFontData): 176 (WebCore::SimpleFontData::smallCapsFontData): 177 (WebCore::SimpleFontData::emphasisMarkFontData): 178 * platform/graphics/wx/FontCacheWx.cpp: 179 (WebCore::FontCache::getFontDataForCharacters): 180 (WebCore::FontCache::getSimilarFontPlatformData): 181 (WebCore::FontCache::getLastResortFallbackFont): 182 * platform/graphics/wx/SimpleFontDataWx.cpp: 183 (WebCore::SimpleFontData::createScaledFontData): 184 (WebCore::SimpleFontData::smallCapsFontData): 185 (WebCore::SimpleFontData::emphasisMarkFontData): 186 1 187 2012-10-02 Christophe Dumez <christophe.dumez@intel.com> 2 188 -
trunk/Source/WebCore/css/CSSFontFace.cpp
r130105 r130160 92 92 } 93 93 94 SimpleFontData*CSSFontFace::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic)94 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic) 95 95 { 96 96 m_activeSource = 0; … … 103 103 size_t size = m_sources.size(); 104 104 for (size_t i = 0; i < size; ++i) { 105 if ( SimpleFontData*result = m_sources[i]->getFontData(fontDescription, syntheticBold, syntheticItalic, fontSelector)) {105 if (RefPtr<SimpleFontData> result = m_sources[i]->getFontData(fontDescription, syntheticBold, syntheticItalic, fontSelector)) { 106 106 m_activeSource = m_sources[i].get(); 107 return result ;107 return result.release(); 108 108 } 109 109 } -
trunk/Source/WebCore/css/CSSFontFace.h
r130105 r130160 65 65 void fontLoaded(CSSFontFaceSource*); 66 66 67 SimpleFontData*getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic);67 PassRefPtr<SimpleFontData> getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic); 68 68 69 69 struct UnicodeRange { -
trunk/Source/WebCore/css/CSSFontFaceSource.cpp
r130105 r130160 34 34 #include "FontCache.h" 35 35 #include "FontDescription.h" 36 #include "GlyphPageTreeNode.h"37 36 #include "SimpleFontData.h" 38 37 … … 96 95 } 97 96 98 SimpleFontData*CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector)97 PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector) 99 98 { 100 99 // If the font hasn't loaded or an error occurred, then we've got nothing. … … 115 114 | (fontDescription.textOrientation() == TextOrientationUpright ? 8 : 0) | (fontDescription.orientation() == Vertical ? 4 : 0) | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0); 116 115 117 SimpleFontData*& cachedData = m_fontDataTable.add(hashKey, 0).iterator->second; 118 if (cachedData) 119 return cachedData; 120 121 OwnPtr<SimpleFontData> fontData; 116 RefPtr<SimpleFontData>& fontData = m_fontDataTable.add(hashKey, 0).iterator->second; 117 if (fontData) 118 return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable. 122 119 123 120 // If we are still loading, then we let the system pick a font. … … 158 155 } 159 156 160 fontData = adoptPtr(new SimpleFontData(SVGFontData::create(fontFaceElement), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));157 fontData = SimpleFontData::create(SVGFontData::create(fontFaceElement), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic); 161 158 } 162 159 } else … … 167 164 return 0; 168 165 169 fontData = adoptPtr(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.orientation(),170 fontDescription.textOrientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false));166 fontData = SimpleFontData::create(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, 167 fontDescription.orientation(), fontDescription.textOrientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false); 171 168 } 172 169 } else { … … 174 171 // In-Document SVG Fonts 175 172 if (m_svgFontFaceElement) 176 fontData = adoptPtr(new SimpleFontData(SVGFontData::create(m_svgFontFaceElement.get()), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));173 fontData = SimpleFontData::create(SVGFontData::create(m_svgFontFaceElement.get()), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic); 177 174 #endif 178 175 } … … 185 182 FontCachePurgePreventer fontCachePurgePreventer; 186 183 SimpleFontData* temporaryFont = fontCache()->getNonRetainedLastResortFallbackFont(fontDescription); 187 fontData = adoptPtr(new SimpleFontData(temporaryFont->platformData(), true, true));184 fontData = SimpleFontData::create(temporaryFont->platformData(), true, true); 188 185 } 189 186 190 if (Document* document = fontSelector->document()) {191 cachedData = fontData.get();192 document->registerCustomFont(fontData.release());193 }194 195 return cachedData;187 if (Document* document = fontSelector->document()) 188 document->registerCustomFont(fontData); 189 else 190 fontData.clear(); 191 192 return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable. 196 193 } 197 194 -
trunk/Source/WebCore/css/CSSFontFaceSource.h
r130105 r130160 60 60 virtual void fontLoaded(CachedFont*); 61 61 62 SimpleFontData*getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic, CSSFontSelector*);62 PassRefPtr<SimpleFontData> getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic, CSSFontSelector*); 63 63 64 64 void pruneTable(); … … 77 77 CachedResourceHandle<CachedFont> m_font; // For remote fonts, a pointer to our cached resource. 78 78 CSSFontFace* m_face; // Our owning font face. 79 HashMap<unsigned, SimpleFontData*> m_fontDataTable; // The hash key is composed of size synthetic styles.79 HashMap<unsigned, RefPtr<SimpleFontData> > m_fontDataTable; // The hash key is composed of size synthetic styles. 80 80 81 81 #if ENABLE(SVG_FONTS) -
trunk/Source/WebCore/css/CSSFontSelector.cpp
r130105 r130160 351 351 } 352 352 353 static FontData*fontDataForGenericFamily(Document* document, const FontDescription& fontDescription, const AtomicString& familyName)353 static PassRefPtr<FontData> fontDataForGenericFamily(Document* document, const FontDescription& fontDescription, const AtomicString& familyName) 354 354 { 355 355 if (!document || !document->frame()) … … 466 466 } 467 467 468 FontData*CSSFontSelector::getFontData(const FontDescription& fontDescription, const AtomicString& familyName)468 PassRefPtr<FontData> CSSFontSelector::getFontData(const FontDescription& fontDescription, const AtomicString& familyName) 469 469 { 470 470 if (m_fontFaces.isEmpty()) { -
trunk/Source/WebCore/css/CSSFontSelector.h
r130105 r130160 56 56 virtual unsigned version() const OVERRIDE { return m_version; } 57 57 58 virtual FontData* getFontData(const FontDescription& fontDescription, const AtomicString& familyName);58 virtual PassRefPtr<FontData> getFontData(const FontDescription&, const AtomicString&); 59 59 60 60 void clearDocument(); -
trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp
r130105 r130160 82 82 } 83 83 84 static void appendFontDataWithInvalidUnicodeRangeIfLoading(SegmentedFontData* newFontData, const SimpleFontData* faceFontData, const Vector<CSSFontFace::UnicodeRange>& ranges)84 static void appendFontDataWithInvalidUnicodeRangeIfLoading(SegmentedFontData* newFontData, PassRefPtr<SimpleFontData> prpFaceFontData, const Vector<CSSFontFace::UnicodeRange>& ranges) 85 85 { 86 RefPtr<SimpleFontData> faceFontData = prpFaceFontData; 86 87 if (faceFontData->isLoading()) { 87 88 newFontData->appendRange(FontDataRange(0, 0, faceFontData)); … … 99 100 } 100 101 101 FontData*CSSSegmentedFontFace::getFontData(const FontDescription& fontDescription)102 PassRefPtr<FontData> CSSSegmentedFontFace::getFontData(const FontDescription& fontDescription) 102 103 { 103 104 if (!isValid()) … … 107 108 unsigned hashKey = ((fontDescription.computedPixelSize() + 1) << (FontTraitsMaskWidth + 1)) | ((fontDescription.orientation() == Vertical ? 1 : 0) << FontTraitsMaskWidth) | desiredTraitsMask; 108 109 109 SegmentedFontData*& fontData = m_fontDataTable.add(hashKey, 0).iterator->second;110 RefPtr<SegmentedFontData>& fontData = m_fontDataTable.add(hashKey, 0).iterator->second; 110 111 if (fontData) 111 112 return fontData; 112 113 113 OwnPtr<SegmentedFontData> newFontData = adoptPtr(new SegmentedFontData);114 fontData = SegmentedFontData::create(); 114 115 115 116 unsigned size = m_fontFaces.size(); … … 120 121 bool syntheticBold = !(traitsMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask)) && (desiredTraitsMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask)); 121 122 bool syntheticItalic = !(traitsMask & FontStyleItalicMask) && (desiredTraitsMask & FontStyleItalicMask); 122 if ( const SimpleFontData*faceFontData = m_fontFaces[i]->getFontData(fontDescription, syntheticBold, syntheticItalic)) {123 if (RefPtr<SimpleFontData> faceFontData = m_fontFaces[i]->getFontData(fontDescription, syntheticBold, syntheticItalic)) { 123 124 ASSERT(!faceFontData->isSegmented()); 124 appendFontDataWithInvalidUnicodeRangeIfLoading( newFontData.get(), faceFontData, m_fontFaces[i]->ranges());125 appendFontDataWithInvalidUnicodeRangeIfLoading(fontData.get(), faceFontData.release(), m_fontFaces[i]->ranges()); 125 126 } 126 127 } 127 if ( newFontData->numRanges()) {128 if (fontData->numRanges()) { 128 129 if (Document* document = m_fontSelector->document()) { 129 fontData = newFontData.get();130 document->registerCustomFont(newFontData.release());130 document->registerCustomFont(fontData); 131 return fontData; 131 132 } 132 133 } 133 134 134 return fontData;135 return 0; 135 136 } 136 137 -
trunk/Source/WebCore/css/CSSSegmentedFontFace.h
r130105 r130160 52 52 void appendFontFace(PassRefPtr<CSSFontFace>); 53 53 54 FontData*getFontData(const FontDescription&);54 PassRefPtr<FontData> getFontData(const FontDescription&); 55 55 56 56 private: … … 61 61 62 62 CSSFontSelector* m_fontSelector; 63 HashMap<unsigned, SegmentedFontData*> m_fontDataTable;63 HashMap<unsigned, RefPtr<SegmentedFontData> > m_fontDataTable; 64 64 Vector<RefPtr<CSSFontFace>, 1> m_fontFaces; 65 65 }; -
trunk/Source/WebCore/dom/Document.cpp
r130105 r130160 1975 1975 } 1976 1976 1977 void Document::registerCustomFont(Pass OwnPtr<FontData> fontData)1977 void Document::registerCustomFont(PassRefPtr<FontData> fontData) 1978 1978 { 1979 1979 m_customFonts.append(fontData); -
trunk/Source/WebCore/dom/Document.h
r130105 r130160 541 541 PassRefPtr<RenderStyle> styleForPage(int pageIndex); 542 542 543 void registerCustomFont(Pass OwnPtr<FontData>);543 void registerCustomFont(PassRefPtr<FontData>); 544 544 545 545 // Returns true if page box (margin boxes and page borders) is visible. … … 1257 1257 PendingSheetLayout m_pendingSheetLayout; 1258 1258 1259 Vector< OwnPtr<FontData> > m_customFonts;1259 Vector<RefPtr<FontData> > m_customFonts; 1260 1260 1261 1261 Frame* m_frame; -
trunk/Source/WebCore/platform/graphics/Font.h
r130105 r130160 52 52 class FontSelector; 53 53 class GlyphBuffer; 54 class GlyphPageTreeNode;55 54 class GraphicsContext; 56 55 class RenderText; -
trunk/Source/WebCore/platform/graphics/FontCache.cpp
r130105 r130160 35 35 #include "FontPlatformData.h" 36 36 #include "FontSelector.h" 37 #include "GlyphPageTreeNode.h"38 37 #include "OpenTypeVerticalData.h" 39 38 #include "WebKitFontFamilyNames.h" … … 287 286 }; 288 287 289 typedef HashMap<FontPlatformData, pair< SimpleFontData*, unsigned>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache;288 typedef HashMap<FontPlatformData, pair<RefPtr<SimpleFontData>, unsigned>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache; 290 289 291 290 static FontDataCache* gFontDataCache = 0; … … 298 297 const int cTargetInactiveFontData = 30; 299 298 #endif 300 static ListHashSet< const SimpleFontData*>* gInactiveFontData = 0;301 302 SimpleFontData*FontCache::getCachedFontData(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName, ShouldRetain shouldRetain)299 static ListHashSet<RefPtr<SimpleFontData> >* gInactiveFontData = 0; 300 301 PassRefPtr<SimpleFontData> FontCache::getCachedFontData(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName, ShouldRetain shouldRetain) 303 302 { 304 303 FontPlatformData* platformData = getCachedFontPlatformData(fontDescription, family, checkingAlternateName); … … 309 308 } 310 309 311 SimpleFontData*FontCache::getCachedFontData(const FontPlatformData* platformData, ShouldRetain shouldRetain)310 PassRefPtr<SimpleFontData> FontCache::getCachedFontData(const FontPlatformData* platformData, ShouldRetain shouldRetain) 312 311 { 313 312 if (!platformData) … … 321 320 if (!gFontDataCache) { 322 321 gFontDataCache = new FontDataCache; 323 gInactiveFontData = new ListHashSet< const SimpleFontData*>;322 gInactiveFontData = new ListHashSet<RefPtr<SimpleFontData> >; 324 323 } 325 324 326 325 FontDataCache::iterator result = gFontDataCache->find(*platformData); 327 326 if (result == gFontDataCache->end()) { 328 pair< SimpleFontData*, unsigned> newValue(new SimpleFontData(*platformData), shouldRetain == Retain ? 1 : 0);327 pair<RefPtr<SimpleFontData>, unsigned> newValue(SimpleFontData::create(*platformData), shouldRetain == Retain ? 1 : 0); 329 328 gFontDataCache->set(*platformData, newValue); 330 329 if (shouldRetain == DoNotRetain) 331 330 gInactiveFontData->add(newValue.first); 332 return newValue.first ;331 return newValue.first.release(); 333 332 } 334 333 … … 351 350 SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont(const FontDescription& fontDescription) 352 351 { 353 return getLastResortFallbackFont(fontDescription, DoNotRetain) ;352 return getLastResortFallbackFont(fontDescription, DoNotRetain).leakRef(); 354 353 } 355 354 … … 364 363 ASSERT(it->second.second); 365 364 if (!--it->second.second) 366 gInactiveFontData->add( fontData);365 gInactiveFontData->add(it->second.first); 367 366 } 368 367 … … 384 383 isPurging = true; 385 384 386 Vector< const SimpleFontData*, 20> fontDataToDelete;387 ListHashSet< const SimpleFontData*>::iterator end = gInactiveFontData->end();388 ListHashSet< const SimpleFontData*>::iterator it = gInactiveFontData->begin();385 Vector<RefPtr<SimpleFontData>, 20> fontDataToDelete; 386 ListHashSet<RefPtr<SimpleFontData> >::iterator end = gInactiveFontData->end(); 387 ListHashSet<RefPtr<SimpleFontData> >::iterator it = gInactiveFontData->begin(); 389 388 for (int i = 0; i < count && it != end; ++it, ++i) { 390 const SimpleFontData*fontData = *it.get();389 RefPtr<SimpleFontData>& fontData = *it.get(); 391 390 gFontDataCache->remove(fontData->platformData()); 392 391 // We should not delete SimpleFontData here because deletion can modify gInactiveFontData. See http://trac.webkit.org/changeset/44011 … … 402 401 } 403 402 404 size_t fontDataToDeleteCount = fontDataToDelete.size(); 405 for (size_t i = 0; i < fontDataToDeleteCount; ++i) 406 delete fontDataToDelete[i]; 403 fontDataToDelete.clear(); 407 404 408 405 if (gFontPlatformDataCache) { … … 463 460 } 464 461 465 const FontData*FontCache::getFontData(const Font& font, int& familyIndex, FontSelector* fontSelector)466 { 467 FontData* result = 0;462 PassRefPtr<FontData> FontCache::getFontData(const Font& font, int& familyIndex, FontSelector* fontSelector) 463 { 464 RefPtr<FontData> result; 468 465 469 466 int startIndex = familyIndex; … … 499 496 if (fontSelector) { 500 497 // Try the user's preferred standard font. 501 if ( FontData*data = fontSelector->getFontData(font.fontDescription(), standardFamily))502 return data ;498 if (RefPtr<FontData> data = fontSelector->getFontData(font.fontDescription(), standardFamily)) 499 return data.release(); 503 500 } 504 501 … … 506 503 result = getLastResortFallbackFont(font.fontDescription()); 507 504 } 508 return result ;505 return result.release(); 509 506 } 510 507 -
trunk/Source/WebCore/platform/graphics/FontCache.h
r130105 r130160 33 33 #include <limits.h> 34 34 #include <wtf/Forward.h> 35 #include <wtf/PassRefPtr.h> 36 #include <wtf/RefPtr.h> 35 37 #include <wtf/Vector.h> 36 38 #include <wtf/text/WTFString.h> … … 62 64 enum ShouldRetain { Retain, DoNotRetain }; 63 65 64 const FontData*getFontData(const Font&, int& familyIndex, FontSelector*);66 PassRefPtr<FontData> getFontData(const Font&, int& familyIndex, FontSelector*); 65 67 void releaseFontData(const SimpleFontData*); 66 68 67 69 // This method is implemented by the platform. 68 const SimpleFontData*getFontDataForCharacters(const Font&, const UChar* characters, int length);70 PassRefPtr<SimpleFontData> getFontDataForCharacters(const Font&, const UChar* characters, int length); 69 71 70 72 // Also implemented by the platform. … … 86 88 void getTraitsInFamily(const AtomicString&, Vector<unsigned>&); 87 89 88 SimpleFontData*getCachedFontData(const FontDescription&, const AtomicString&, bool checkingAlternateName = false, ShouldRetain = Retain);89 SimpleFontData*getLastResortFallbackFont(const FontDescription&, ShouldRetain = Retain);90 PassRefPtr<SimpleFontData> getCachedFontData(const FontDescription&, const AtomicString&, bool checkingAlternateName = false, ShouldRetain = Retain); 91 PassRefPtr<SimpleFontData> getLastResortFallbackFont(const FontDescription&, ShouldRetain = Retain); 90 92 SimpleFontData* getNonRetainedLastResortFallbackFont(const FontDescription&); 91 93 … … 101 103 102 104 #if PLATFORM(WIN) 103 SimpleFontData* fontDataFromDescriptionAndLogFont(const FontDescription&, ShouldRetain, const LOGFONT& font, AtomicString& outFontFamilyName);105 PassRefPtr<SimpleFontData> fontDataFromDescriptionAndLogFont(const FontDescription&, ShouldRetain, const LOGFONT&, AtomicString& outFontFamilyName); 104 106 #elif PLATFORM(CHROMIUM) && OS(WINDOWS) 105 SimpleFontData* fontDataFromDescriptionAndLogFont(const FontDescription&, ShouldRetain, const LOGFONT& font, wchar_t* outFontFamilyName);107 PassRefPtr<SimpleFontData> fontDataFromDescriptionAndLogFont(const FontDescription&, ShouldRetain, const LOGFONT&, wchar_t* outFontFamilyName); 106 108 #endif 107 109 … … 140 142 141 143 // These methods are implemented by each platform. 142 SimpleFontData*getSimilarFontPlatformData(const Font&);144 PassRefPtr<SimpleFontData> getSimilarFontPlatformData(const Font&); 143 145 FontPlatformData* createFontPlatformData(const FontDescription&, const AtomicString& family); 144 146 145 SimpleFontData*getCachedFontData(const FontPlatformData*, ShouldRetain = Retain);147 PassRefPtr<SimpleFontData> getCachedFontData(const FontPlatformData*, ShouldRetain = Retain); 146 148 147 149 // Don't purge if this count is > 0; -
trunk/Source/WebCore/platform/graphics/FontData.h
r130105 r130160 30 30 #include <wtf/Forward.h> 31 31 #include <wtf/Noncopyable.h> 32 #include <wtf/PassRefPtr.h> 33 #include <wtf/RefCounted.h> 32 34 #include <wtf/unicode/Unicode.h> 33 35 … … 36 38 class SimpleFontData; 37 39 38 class FontData {40 class FontData : public RefCounted<FontData> { 39 41 WTF_MAKE_NONCOPYABLE(FontData); WTF_MAKE_FAST_ALLOCATED; 40 42 public: -
trunk/Source/WebCore/platform/graphics/FontFallbackList.cpp
r130105 r130160 67 67 unsigned numFonts = m_fontList.size(); 68 68 for (unsigned i = 0; i < numFonts; ++i) { 69 if (!m_fontList[i] .second) {70 ASSERT(!m_fontList[i] .first->isSegmented());71 fontCache()->releaseFontData(static_cast<const SimpleFontData*>(m_fontList[i]. first));69 if (!m_fontList[i]->isCustomFont()) { 70 ASSERT(!m_fontList[i]->isSegmented()); 71 fontCache()->releaseFontData(static_cast<const SimpleFontData*>(m_fontList[i].get())); 72 72 } 73 73 } … … 92 92 { 93 93 if (realizedFontIndex < m_fontList.size()) 94 return m_fontList[realizedFontIndex]. first; // This fallback font is already in our list.94 return m_fontList[realizedFontIndex].get(); // This fallback font is already in our list. 95 95 96 96 // Make sure we're not passing in some crazy value here. … … 105 105 // |m_familyIndex| as it scans for the right font to make. 106 106 ASSERT(fontCache()->generation() == m_generation); 107 const FontData*result = fontCache()->getFontData(*font, m_familyIndex, m_fontSelector.get());107 RefPtr<FontData> result = fontCache()->getFontData(*font, m_familyIndex, m_fontSelector.get()); 108 108 if (result) { 109 m_fontList.append( pair<const FontData*, bool>(result, result->isCustomFont()));109 m_fontList.append(result); 110 110 if (result->isLoading()) 111 111 m_loadingCustomFonts = true; 112 112 } 113 return result ;113 return result.get(); 114 114 } 115 115 … … 118 118 m_familyIndex = cAllFamiliesScanned; 119 119 ASSERT(fontCache()->generation() == m_generation); 120 const FontData*fontData = fontCache()->getCachedFontData(&platformData);121 m_fontList.append( pair<const FontData*, bool>(fontData, fontData->isCustomFont()));120 RefPtr<FontData> fontData = fontCache()->getCachedFontData(&platformData); 121 m_fontList.append(fontData); 122 122 } 123 123 -
trunk/Source/WebCore/platform/graphics/FontFallbackList.h
r130105 r130160 85 85 void releaseFontData(); 86 86 87 mutable Vector< pair<const FontData*, bool>, 1> m_fontList;87 mutable Vector<RefPtr<FontData>, 1> m_fontList; 88 88 mutable GlyphPages m_pages; 89 89 mutable GlyphPageTreeNode* m_pageZero; -
trunk/Source/WebCore/platform/graphics/FontFastPath.cpp
r130105 r130160 98 98 } else { 99 99 if (m_fontDescription.textOrientation() == TextOrientationVerticalRight) { 100 const SimpleFontData*verticalRightFontData = data.fontData->verticalRightOrientationFontData();101 GlyphPageTreeNode* verticalRightNode = GlyphPageTreeNode::getRootChild(verticalRightFontData , pageNumber);100 RefPtr<SimpleFontData> verticalRightFontData = data.fontData->verticalRightOrientationFontData(); 101 GlyphPageTreeNode* verticalRightNode = GlyphPageTreeNode::getRootChild(verticalRightFontData.get(), pageNumber); 102 102 GlyphPage* verticalRightPage = verticalRightNode->page(); 103 103 if (verticalRightPage) { … … 112 112 } 113 113 } else if (m_fontDescription.textOrientation() == TextOrientationUpright) { 114 const SimpleFontData*uprightFontData = data.fontData->uprightOrientationFontData();115 GlyphPageTreeNode* uprightNode = GlyphPageTreeNode::getRootChild(uprightFontData , pageNumber);114 RefPtr<SimpleFontData> uprightFontData = data.fontData->uprightOrientationFontData(); 115 GlyphPageTreeNode* uprightNode = GlyphPageTreeNode::getRootChild(uprightFontData.get(), pageNumber); 116 116 GlyphPage* uprightPage = uprightNode->page(); 117 117 if (uprightPage) { … … 153 153 // The variantFontData function should not normally return 0. 154 154 // But if it does, we will just render the capital letter big. 155 const SimpleFontData*variantFontData = data.fontData->variantFontData(m_fontDescription, variant);155 RefPtr<SimpleFontData> variantFontData = data.fontData->variantFontData(m_fontDescription, variant); 156 156 if (!variantFontData) 157 157 return make_pair(data, page); 158 158 159 GlyphPageTreeNode* variantNode = GlyphPageTreeNode::getRootChild(variantFontData , pageNumber);159 GlyphPageTreeNode* variantNode = GlyphPageTreeNode::getRootChild(variantFontData.get(), pageNumber); 160 160 GlyphPage* variantPage = variantNode->page(); 161 161 if (variantPage) { … … 199 199 codeUnitsLength = 2; 200 200 } 201 const SimpleFontData*characterFontData = fontCache()->getFontDataForCharacters(*this, codeUnits, codeUnitsLength);201 RefPtr<SimpleFontData> characterFontData = fontCache()->getFontDataForCharacters(*this, codeUnits, codeUnitsLength); 202 202 if (characterFontData) { 203 203 if (characterFontData->platformData().orientation() == Vertical && !characterFontData->hasVerticalGlyphs() && isCJKIdeographOrSymbol(c)) … … 208 208 if (characterFontData) { 209 209 // Got the fallback glyph and font. 210 GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterFontData , pageNumber)->page();210 GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterFontData.get(), pageNumber)->page(); 211 211 GlyphData data = fallbackPage && fallbackPage->fontDataForCharacter(c) ? fallbackPage->glyphDataForCharacter(c) : characterFontData->missingGlyphData(); 212 212 // Cache it so we don't have to do system fallback again next time. -
trunk/Source/WebCore/platform/graphics/FontSelector.h
r130105 r130160 28 28 29 29 #include <wtf/Forward.h> 30 #include <wtf/PassRefPtr.h> 30 31 #include <wtf/RefCounted.h> 31 32 … … 39 40 public: 40 41 virtual ~FontSelector() { } 41 virtual FontData*getFontData(const FontDescription&, const AtomicString& familyName) = 0;42 virtual PassRefPtr<FontData> getFontData(const FontDescription&, const AtomicString& familyName) = 0; 42 43 43 44 virtual void fontCacheInvalidated() { } -
trunk/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp
r130105 r130160 243 243 zeroFilled = true; 244 244 } 245 haveGlyphs |= fill(pageToFill, from, to - from, buffer + from * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), range.fontData() );245 haveGlyphs |= fill(pageToFill, from, to - from, buffer + from * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), range.fontData().get()); 246 246 if (scratchPage) { 247 247 ASSERT(to <= static_cast<int>(GlyphPage::size)); -
trunk/Source/WebCore/platform/graphics/SegmentedFontData.cpp
r130105 r130160 42 42 for (Vector<FontDataRange>::const_iterator it = m_ranges.begin(); it != end; ++it) { 43 43 if (it->from() <= c && it->to() >= c) 44 return it->fontData() ;44 return it->fontData().get(); 45 45 } 46 return m_ranges[0].fontData() ;46 return m_ranges[0].fontData().get(); 47 47 } 48 48 -
trunk/Source/WebCore/platform/graphics/SegmentedFontData.h
r130105 r130160 35 35 36 36 struct FontDataRange { 37 FontDataRange(UChar32 from, UChar32 to, const SimpleFontData*fontData)37 FontDataRange(UChar32 from, UChar32 to, PassRefPtr<SimpleFontData> fontData) 38 38 : m_from(from) 39 39 , m_to(to) … … 44 44 UChar32 from() const { return m_from; } 45 45 UChar32 to() const { return m_to; } 46 const SimpleFontData*fontData() const { return m_fontData; }46 PassRefPtr<SimpleFontData> fontData() const { return m_fontData; } 47 47 48 48 private: 49 49 UChar32 m_from; 50 50 UChar32 m_to; 51 const SimpleFontData*m_fontData;51 RefPtr<SimpleFontData> m_fontData; 52 52 }; 53 53 54 54 class SegmentedFontData : public FontData { 55 55 public: 56 static PassRefPtr<SegmentedFontData> create() { return adoptRef(new SegmentedFontData); } 57 56 58 virtual ~SegmentedFontData(); 57 59 … … 65 67 66 68 private: 69 SegmentedFontData() { } 70 67 71 virtual const SimpleFontData* fontDataForCharacter(UChar32) const; 68 72 virtual bool containsCharacters(const UChar*, int length) const; -
trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp
r130105 r130160 171 171 } 172 172 173 SimpleFontData*SimpleFontData::verticalRightOrientationFontData() const173 PassRefPtr<SimpleFontData> SimpleFontData::verticalRightOrientationFontData() const 174 174 { 175 175 if (!m_derivedFontData) … … 178 178 FontPlatformData verticalRightPlatformData(m_platformData); 179 179 verticalRightPlatformData.setOrientation(Horizontal); 180 m_derivedFontData->verticalRightOrientation = adoptPtr(new SimpleFontData(verticalRightPlatformData, isCustomFont(), false, true));181 } 182 return m_derivedFontData->verticalRightOrientation .get();183 } 184 185 SimpleFontData*SimpleFontData::uprightOrientationFontData() const180 m_derivedFontData->verticalRightOrientation = create(verticalRightPlatformData, isCustomFont(), false, true); 181 } 182 return m_derivedFontData->verticalRightOrientation; 183 } 184 185 PassRefPtr<SimpleFontData> SimpleFontData::uprightOrientationFontData() const 186 186 { 187 187 if (!m_derivedFontData) 188 188 m_derivedFontData = DerivedFontData::create(isCustomFont()); 189 189 if (!m_derivedFontData->uprightOrientation) 190 m_derivedFontData->uprightOrientation = adoptPtr(new SimpleFontData(m_platformData, isCustomFont(), false, true));191 return m_derivedFontData->uprightOrientation .get();192 } 193 194 SimpleFontData*SimpleFontData::brokenIdeographFontData() const190 m_derivedFontData->uprightOrientation = create(m_platformData, isCustomFont(), false, true); 191 return m_derivedFontData->uprightOrientation; 192 } 193 194 PassRefPtr<SimpleFontData> SimpleFontData::brokenIdeographFontData() const 195 195 { 196 196 if (!m_derivedFontData) 197 197 m_derivedFontData = DerivedFontData::create(isCustomFont()); 198 198 if (!m_derivedFontData->brokenIdeograph) { 199 m_derivedFontData->brokenIdeograph = adoptPtr(new SimpleFontData(m_platformData, isCustomFont(), false));199 m_derivedFontData->brokenIdeograph = create(m_platformData, isCustomFont(), false); 200 200 m_derivedFontData->brokenIdeograph->m_isBrokenIdeographFallback = true; 201 201 } 202 return m_derivedFontData->brokenIdeograph .get();202 return m_derivedFontData->brokenIdeograph; 203 203 } 204 204 -
trunk/Source/WebCore/platform/graphics/SimpleFontData.h
r130105 r130160 80 80 81 81 // Used to create platform fonts. 82 SimpleFontData(const FontPlatformData&, bool isCustomFont = false, bool isLoading = false, bool isTextOrientationFallback = false); 82 static PassRefPtr<SimpleFontData> create(const FontPlatformData& platformData, bool isCustomFont = false, bool isLoading = false, bool isTextOrientationFallback = false) 83 { 84 return adoptRef(new SimpleFontData(platformData, isCustomFont, isLoading, isTextOrientationFallback)); 85 } 83 86 84 87 // Used to create SVG Fonts. 85 SimpleFontData(PassOwnPtr<AdditionalFontData>, float fontSize, bool syntheticBold, bool syntheticItalic); 88 static PassRefPtr<SimpleFontData> create(PassOwnPtr<AdditionalFontData> fontData, float fontSize, bool syntheticBold, bool syntheticItalic) 89 { 90 return adoptRef(new SimpleFontData(fontData, fontSize, syntheticBold, syntheticItalic)); 91 } 86 92 87 93 virtual ~SimpleFontData(); … … 92 98 #endif 93 99 94 SimpleFontData*smallCapsFontData(const FontDescription&) const;95 SimpleFontData*emphasisMarkFontData(const FontDescription&) const;96 SimpleFontData*brokenIdeographFontData() const;97 98 SimpleFontData*variantFontData(const FontDescription& description, FontDataVariant variant) const100 PassRefPtr<SimpleFontData> smallCapsFontData(const FontDescription&) const; 101 PassRefPtr<SimpleFontData> emphasisMarkFontData(const FontDescription&) const; 102 PassRefPtr<SimpleFontData> brokenIdeographFontData() const; 103 104 PassRefPtr<SimpleFontData> variantFontData(const FontDescription& description, FontDataVariant variant) const 99 105 { 100 106 switch (variant) { … … 113 119 } 114 120 115 SimpleFontData*verticalRightOrientationFontData() const;116 SimpleFontData*uprightOrientationFontData() const;121 PassRefPtr<SimpleFontData> verticalRightOrientationFontData() const; 122 PassRefPtr<SimpleFontData> uprightOrientationFontData() const; 117 123 118 124 bool hasVerticalGlyphs() const { return m_hasVerticalGlyphs; } … … 202 208 203 209 private: 210 SimpleFontData(const FontPlatformData&, bool isCustomFont = false, bool isLoading = false, bool isTextOrientationFallback = false); 211 212 SimpleFontData(PassOwnPtr<AdditionalFontData> , float fontSize, bool syntheticBold, bool syntheticItalic); 213 204 214 void platformInit(); 205 215 void platformGlyphInit(); … … 211 221 void commonInit(); 212 222 213 Pass OwnPtr<SimpleFontData> createScaledFontData(const FontDescription&, float scaleFactor) const;223 PassRefPtr<SimpleFontData> createScaledFontData(const FontDescription&, float scaleFactor) const; 214 224 215 225 #if (PLATFORM(WIN) && !OS(WINCE)) \ … … 255 265 256 266 bool forCustomFont; 257 OwnPtr<SimpleFontData> smallCaps;258 OwnPtr<SimpleFontData> emphasisMark;259 OwnPtr<SimpleFontData> brokenIdeograph;260 OwnPtr<SimpleFontData> verticalRightOrientation;261 OwnPtr<SimpleFontData> uprightOrientation;267 RefPtr<SimpleFontData> smallCaps; 268 RefPtr<SimpleFontData> emphasisMark; 269 RefPtr<SimpleFontData> brokenIdeograph; 270 RefPtr<SimpleFontData> verticalRightOrientation; 271 RefPtr<SimpleFontData> uprightOrientation; 262 272 #if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) 263 273 mutable RetainPtr<CFMutableDictionaryRef> compositeFontReferences; -
trunk/Source/WebCore/platform/graphics/chromium/FontCacheAndroid.cpp
r130105 r130160 98 98 } 99 99 100 const SimpleFontData*FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)100 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) 101 101 { 102 102 // FIXME: We do not use fontconfig on Android, so use simple logic for now. … … 106 106 } 107 107 108 SimpleFontData*FontCache::getSimilarFontPlatformData(const Font& font)108 PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font) 109 109 { 110 110 return 0; 111 111 } 112 112 113 SimpleFontData*FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)113 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain) 114 114 { 115 115 DEFINE_STATIC_LOCAL(const AtomicString, serif, ("Serif")); -
trunk/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp
r130105 r130160 319 319 320 320 // Tries the given font and save it |outFontFamilyName| if it succeeds. 321 SimpleFontData*FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, ShouldRetain shouldRetain, const LOGFONT& font, wchar_t* outFontFamilyName)322 { 323 SimpleFontData*fontData = getCachedFontData(fontDescription, font.lfFaceName, false, shouldRetain);321 PassRefPtr<SimpleFontData> FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, ShouldRetain shouldRetain, const LOGFONT& font, wchar_t* outFontFamilyName) 322 { 323 RefPtr<SimpleFontData> fontData = getCachedFontData(fontDescription, font.lfFaceName, false, shouldRetain); 324 324 if (fontData) 325 325 memcpy(outFontFamilyName, font.lfFaceName, sizeof(font.lfFaceName)); 326 return fontData ;326 return fontData.release(); 327 327 } 328 328 … … 407 407 FontCache::ShouldRetain m_shouldRetain; 408 408 wchar_t* m_fontName; 409 SimpleFontData*m_fontData;409 RefPtr<SimpleFontData> m_fontData; 410 410 }; 411 411 … … 424 424 // Given the desired base font, this will create a SimpleFontData for a specific 425 425 // font that can be used to render the given range of characters. 426 const SimpleFontData*FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)426 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) 427 427 { 428 428 // FIXME: Consider passing fontDescription.dominantScript() … … 509 509 } 510 510 511 SimpleFontData*FontCache::getSimilarFontPlatformData(const Font& font)511 PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font) 512 512 { 513 513 return 0; 514 514 } 515 515 516 SimpleFontData*FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)516 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain) 517 517 { 518 518 FontDescription::GenericFamilyType generic = description.genericFamily(); … … 531 531 fontStr = courierStr; 532 532 533 SimpleFontData*simpleFont = getCachedFontData(description, fontStr, false, shouldRetain);533 RefPtr<SimpleFontData> simpleFont = getCachedFontData(description, fontStr, false, shouldRetain); 534 534 if (simpleFont) 535 return simpleFont ;535 return simpleFont.release(); 536 536 537 537 // Fall back to system fonts as Win Safari does because this function must … … 547 547 GetObject(defaultGUIFont, sizeof(defaultGUILogFont), &defaultGUILogFont); 548 548 if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, defaultGUILogFont, fallbackFontName)) 549 return simpleFont ;549 return simpleFont.release(); 550 550 } 551 551 … … 555 555 if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nonClientMetrics), &nonClientMetrics, 0)) { 556 556 if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfMessageFont, fallbackFontName)) 557 return simpleFont ;557 return simpleFont.release(); 558 558 if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfMenuFont, fallbackFontName)) 559 return simpleFont ;559 return simpleFont.release(); 560 560 if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfStatusFont, fallbackFontName)) 561 return simpleFont ;561 return simpleFont.release(); 562 562 if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfCaptionFont, fallbackFontName)) 563 return simpleFont ;563 return simpleFont.release(); 564 564 if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfSmCaptionFont, fallbackFontName)) 565 return simpleFont ;565 return simpleFont.release(); 566 566 } 567 567 … … 577 577 578 578 if (procData.m_fontData) 579 return procData.m_fontData ;579 return procData.m_fontData.release(); 580 580 } 581 581 -
trunk/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp
r130105 r130160 110 110 } 111 111 112 Pass OwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const112 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const 113 113 { 114 114 LOGFONT winFont; … … 117 117 winFont.lfHeight = -lroundf(scaledSize); 118 118 HFONT hfont = CreateFontIndirect(&winFont); 119 return adoptPtr(new SimpleFontData(FontPlatformData(hfont, scaledSize, m_platformData.orientation()), isCustomFont(), false));120 } 121 122 SimpleFontData*SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const119 return SimpleFontData::create(FontPlatformData(hfont, scaledSize, m_platformData.orientation()), isCustomFont(), false); 120 } 121 122 PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const 123 123 { 124 124 if (!m_derivedFontData) … … 127 127 m_derivedFontData->smallCaps = createScaledFontData(fontDescription, .7); 128 128 129 return m_derivedFontData->smallCaps .get();130 } 131 132 SimpleFontData*SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const129 return m_derivedFontData->smallCaps; 130 } 131 132 PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const 133 133 { 134 134 if (!m_derivedFontData) … … 137 137 m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5); 138 138 139 return m_derivedFontData->emphasisMark .get();139 return m_derivedFontData->emphasisMark; 140 140 } 141 141 -
trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
r130105 r130160 82 82 } 83 83 84 const SimpleFontData*FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)84 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) 85 85 { 86 86 RefPtr<FcPattern> pattern = adoptRef(createFontConfigPatternForCharacters(characters, length)); … … 101 101 } 102 102 103 SimpleFontData*FontCache::getSimilarFontPlatformData(const Font&)103 PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font&) 104 104 { 105 105 return 0; 106 106 } 107 107 108 SimpleFontData*FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)108 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain) 109 109 { 110 110 // We want to return a fallback font here, otherwise the logic preventing FontConfig -
trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
r130105 r130160 88 88 } 89 89 90 Pass OwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const90 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const 91 91 { 92 92 ASSERT(m_platformData.scaledFont()); 93 return adoptPtr(new SimpleFontData(FontPlatformData(cairo_scaled_font_get_font_face(m_platformData.scaledFont()),93 return SimpleFontData::create(FontPlatformData(cairo_scaled_font_get_font_face(m_platformData.scaledFont()), 94 94 scaleFactor * fontDescription.computedSize(), 95 95 m_platformData.syntheticBold(), 96 m_platformData.syntheticOblique()), 97 isCustomFont(), false)); 96 m_platformData.syntheticOblique()), isCustomFont(), false); 98 97 } 99 98 100 SimpleFontData*SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const99 PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const 101 100 { 102 101 if (!m_derivedFontData) … … 106 105 m_derivedFontData->smallCaps = createScaledFontData(fontDescription, .7); 107 106 108 return m_derivedFontData->smallCaps .get();107 return m_derivedFontData->smallCaps; 109 108 } 110 109 111 SimpleFontData*SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const110 PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const 112 111 { 113 112 if (!m_derivedFontData) … … 116 115 m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5); 117 116 118 return m_derivedFontData->emphasisMark .get();117 return m_derivedFontData->emphasisMark; 119 118 } 120 119 -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
r130105 r130160 283 283 continue; 284 284 } 285 runFontData = fontCache()->getCachedFontData(m_font.fontDescription(), fontName.get(), false, FontCache::DoNotRetain) ;285 runFontData = fontCache()->getCachedFontData(m_font.fontDescription(), fontName.get(), false, FontCache::DoNotRetain).get(); 286 286 #if !PLATFORM(WX) 287 287 // Core Text may have used a font that is not known to NSFontManager. In that case, fall back on … … 289 289 if (!runFontData) { 290 290 FontPlatformData runFontPlatformData((NSFont *)runFont, CTFontGetSize(runFont), m_font.fontDescription().usePrinterFont()); 291 runFontData = fontCache()->getCachedFontData(&runFontPlatformData, FontCache::DoNotRetain) ;291 runFontData = fontCache()->getCachedFontData(&runFontPlatformData, FontCache::DoNotRetain).get(); 292 292 } 293 293 #else -
trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm
r130105 r130160 100 100 } 101 101 102 const SimpleFontData*FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)102 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) 103 103 { 104 104 UChar32 character; … … 173 173 } 174 174 175 SimpleFontData*FontCache::getSimilarFontPlatformData(const Font& font)175 PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font) 176 176 { 177 177 // Attempt to find an appropriate font using a match based on 178 178 // the presence of keywords in the the requested names. For example, we'll 179 179 // match any name that contains "Arabic" to Geeza Pro. 180 SimpleFontData* simpleFontData = 0;180 RefPtr<SimpleFontData> simpleFontData; 181 181 const FontFamily* currFamily = &font.fontDescription().family(); 182 182 while (currFamily && !simpleFontData) { … … 191 191 } 192 192 193 return simpleFontData ;194 } 195 196 SimpleFontData*FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)193 return simpleFontData.release(); 194 } 195 196 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain) 197 197 { 198 198 DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times")); … … 200 200 // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick 201 201 // the default that the user would get without changing any prefs. 202 SimpleFontData*simpleFontData = getCachedFontData(fontDescription, timesStr, false, shouldRetain);202 RefPtr<SimpleFontData> simpleFontData = getCachedFontData(fontDescription, timesStr, false, shouldRetain); 203 203 if (simpleFontData) 204 return simpleFontData ;204 return simpleFontData.release(); 205 205 206 206 // The Times fallback will almost always work, but in the highly unusual case where -
trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp
r130105 r130160 190 190 if (isCJKIdeographOrSymbol(baseCharacter) && !simpleFontData->hasVerticalGlyphs()) { 191 191 variant = BrokenIdeographVariant; 192 simpleFontData = simpleFontData->brokenIdeographFontData() ;192 simpleFontData = simpleFontData->brokenIdeographFontData().get(); 193 193 } else if (m_fontDescription.textOrientation() == TextOrientationVerticalRight) { 194 SimpleFontData* verticalRightFontData = simpleFontData->verticalRightOrientationFontData() ;194 SimpleFontData* verticalRightFontData = simpleFontData->verticalRightOrientationFontData().get(); 195 195 Glyph verticalRightGlyph = verticalRightFontData->glyphForCharacter(baseCharacter); 196 196 if (verticalRightGlyph == baseCharacterGlyphData.glyph) 197 197 simpleFontData = verticalRightFontData; 198 198 } else { 199 SimpleFontData* uprightFontData = simpleFontData->uprightOrientationFontData() ;199 SimpleFontData* uprightFontData = simpleFontData->uprightOrientationFontData().get(); 200 200 Glyph uprightGlyph = uprightFontData->glyphForCharacter(baseCharacter); 201 201 if (uprightGlyph != baseCharacterGlyphData.glyph) … … 204 204 } 205 205 } else { 206 if (const SimpleFontData* variantFontData = simpleFontData->variantFontData(m_fontDescription, variant) )206 if (const SimpleFontData* variantFontData = simpleFontData->variantFontData(m_fontDescription, variant).get()) 207 207 simpleFontData = variantFontData; 208 208 } -
trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
r130105 r130160 309 309 // These come from the cache. 310 310 if (m_derivedFontData->smallCaps) 311 fontCache()->releaseFontData(m_derivedFontData->smallCaps. leakPtr());311 fontCache()->releaseFontData(m_derivedFontData->smallCaps.get()); 312 312 313 313 if (m_derivedFontData->emphasisMark) 314 fontCache()->releaseFontData(m_derivedFontData->emphasisMark. leakPtr());315 } 316 } 317 318 Pass OwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const314 fontCache()->releaseFontData(m_derivedFontData->emphasisMark.get()); 315 } 316 } 317 318 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const 319 319 { 320 320 if (isCustomFont()) { 321 321 FontPlatformData scaledFontData(m_platformData); 322 322 scaledFontData.m_size = scaledFontData.m_size * scaleFactor; 323 return adoptPtr(new SimpleFontData(scaledFontData, true, false));323 return SimpleFontData::create(scaledFontData, true, false); 324 324 } 325 325 … … 346 346 347 347 // SimpleFontData::platformDestroy() takes care of not deleting the cached font data twice. 348 return adoptPtr(fontCache()->getCachedFontData(&scaledFontData));348 return fontCache()->getCachedFontData(&scaledFontData); 349 349 } 350 350 END_BLOCK_OBJC_EXCEPTIONS; 351 351 352 return nullptr;353 } 354 355 SimpleFontData*SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const352 return 0; 353 } 354 355 PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const 356 356 { 357 357 if (!m_derivedFontData) … … 360 360 m_derivedFontData->smallCaps = createScaledFontData(fontDescription, smallCapsFontSizeMultiplier); 361 361 362 return m_derivedFontData->smallCaps .get();363 } 364 365 SimpleFontData*SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const362 return m_derivedFontData->smallCaps; 363 } 364 365 PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const 366 366 { 367 367 if (!m_derivedFontData) … … 370 370 m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5f); 371 371 372 return m_derivedFontData->emphasisMark .get();372 return m_derivedFontData->emphasisMark; 373 373 } 374 374 -
trunk/Source/WebCore/platform/graphics/pango/FontCachePango.cpp
r130105 r130160 36 36 } 37 37 38 const SimpleFontData*FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)38 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) 39 39 { 40 40 return 0; 41 41 } 42 42 43 SimpleFontData*FontCache::getSimilarFontPlatformData(const Font& font)43 PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font) 44 44 { 45 45 return 0; 46 46 } 47 47 48 SimpleFontData*FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)48 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain) 49 49 { 50 50 // FIXME: Would be even better to somehow get the user's default font here. -
trunk/Source/WebCore/platform/graphics/pango/SimpleFontDataPango.cpp
r130105 r130160 85 85 } 86 86 87 Pass OwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const87 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const 88 88 { 89 89 FontDescription desc = FontDescription(fontDescription); 90 90 desc.setSpecifiedSize(scaleFactor * fontDescription.computedSize()); 91 91 FontPlatformData platformData(desc, desc.family().family()); 92 return adoptPtr(new SimpleFontData(platformData));92 return SimpleFontData::create(platformData); 93 93 } 94 94 95 SimpleFontData*SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const95 PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const 96 96 { 97 97 if (!m_derivedFontData) … … 100 100 m_derivedFontData->smallCaps = createScaledFontData(fontDescription, .7); 101 101 102 return m_derivedFontData->smallCaps .get();102 return m_derivedFontData->smallCaps; 103 103 } 104 104 105 SimpleFontData*SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const105 PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const 106 106 { 107 107 if (!m_derivedFontData) … … 110 110 m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5); 111 111 112 return m_derivedFontData->emphasisMark .get();112 return m_derivedFontData->emphasisMark; 113 113 } 114 114 -
trunk/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp
r130105 r130160 64 64 } 65 65 66 const SimpleFontData*FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)66 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) 67 67 { 68 68 QString qstring = QString::fromRawData(reinterpret_cast<const QChar*>(characters), length); … … 74 74 } 75 75 76 SimpleFontData*FontCache::getSimilarFontPlatformData(const Font& font)76 PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font) 77 77 { 78 78 return 0; 79 79 } 80 80 81 SimpleFontData*FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)81 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain) 82 82 { 83 83 const AtomicString fallbackFamily = QFont(fontDescription.family().family()).lastResortFamily(); -
trunk/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
r130105 r130160 62 62 } 63 63 64 Pass OwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const64 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const 65 65 { 66 66 const float scaledSize = lroundf(fontDescription.computedSize() * scaleFactor); 67 return adoptPtr(new SimpleFontData(FontPlatformData(m_platformData, scaledSize), isCustomFont(), false));67 return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize), isCustomFont(), false); 68 68 } 69 69 70 SimpleFontData*SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const70 PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const 71 71 { 72 72 if (!m_derivedFontData) … … 75 75 m_derivedFontData->smallCaps = createScaledFontData(fontDescription, smallCapsFraction); 76 76 77 return m_derivedFontData->smallCaps .get();77 return m_derivedFontData->smallCaps; 78 78 } 79 79 80 SimpleFontData*SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const80 PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const 81 81 { 82 82 if (!m_derivedFontData) … … 85 85 m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, emphasisMarkFraction); 86 86 87 return m_derivedFontData->emphasisMark .get();87 return m_derivedFontData->emphasisMark; 88 88 } 89 89 -
trunk/Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp
r130105 r130160 52 52 } 53 53 54 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, 55 const UChar* characters, 56 int length) 54 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) 57 55 { 58 56 icu::Locale locale = icu::Locale::getDefault(); … … 91 89 } 92 90 93 SimpleFontData*FontCache::getSimilarFontPlatformData(const Font& font)91 PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font) 94 92 { 95 93 return 0; 96 94 } 97 95 98 SimpleFontData*FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)96 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain) 99 97 { 100 98 DEFINE_STATIC_LOCAL(const AtomicString, sansStr, ("Sans")); -
trunk/Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp
r130105 r130160 171 171 } 172 172 173 Pass OwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const173 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const 174 174 { 175 175 const float scaledSize = lroundf(fontDescription.computedSize() * scaleFactor); 176 return adoptPtr(new SimpleFontData(FontPlatformData(m_platformData, scaledSize), isCustomFont(), false));177 } 178 179 SimpleFontData*SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const176 return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize), isCustomFont(), false); 177 } 178 179 PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const 180 180 { 181 181 if (!m_derivedFontData) … … 184 184 m_derivedFontData->smallCaps = createScaledFontData(fontDescription, smallCapsFraction); 185 185 186 return m_derivedFontData->smallCaps .get();187 } 188 189 SimpleFontData*SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const186 return m_derivedFontData->smallCaps; 187 } 188 189 PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const 190 190 { 191 191 if (!m_derivedFontData) … … 194 194 m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, emphasisMarkFraction); 195 195 196 return m_derivedFontData->emphasisMark .get();196 return m_derivedFontData->emphasisMark; 197 197 } 198 198 -
trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
r130105 r130160 187 187 } 188 188 189 const SimpleFontData*FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)189 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) 190 190 { 191 191 UChar character = characters[0]; 192 SimpleFontData* fontData = 0;192 RefPtr<SimpleFontData> fontData; 193 193 HWndDC hdc(0); 194 194 HFONT primaryFont = font.primaryFont()->fontDataForCharacter(character)->platformData().hfont(); … … 294 294 } 295 295 296 return fontData ;297 } 298 299 SimpleFontData*FontCache::getSimilarFontPlatformData(const Font& font)296 return fontData.release(); 297 } 298 299 PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font) 300 300 { 301 301 return 0; 302 302 } 303 303 304 SimpleFontData*FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, ShouldRetain shouldRetain, const LOGFONT& font, AtomicString& outFontFamilyName)304 PassRefPtr<SimpleFontData> FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, ShouldRetain shouldRetain, const LOGFONT& font, AtomicString& outFontFamilyName) 305 305 { 306 306 AtomicString familyName = String(font.lfFaceName, wcsnlen(font.lfFaceName, LF_FACESIZE)); 307 SimpleFontData*fontData = getCachedFontData(fontDescription, familyName, false, shouldRetain);307 RefPtr<SimpleFontData> fontData = getCachedFontData(fontDescription, familyName, false, shouldRetain); 308 308 if (fontData) 309 309 outFontFamilyName = familyName; 310 return fontData ;311 } 312 313 SimpleFontData*FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)310 return fontData.release(); 311 } 312 313 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain) 314 314 { 315 315 DEFINE_STATIC_LOCAL(AtomicString, fallbackFontName, ()); … … 330 330 AtomicString("Arial") 331 331 }; 332 SimpleFontData*simpleFont;332 RefPtr<SimpleFontData> simpleFont; 333 333 for (size_t i = 0; i < WTF_ARRAY_LENGTH(fallbackFonts); ++i) { 334 334 if (simpleFont = getCachedFontData(fontDescription, fallbackFonts[i], false, shouldRetain)) { 335 335 fallbackFontName = fallbackFonts[i]; 336 return simpleFont ;336 return simpleFont.release(); 337 337 } 338 338 } … … 343 343 GetObject(defaultGUIFont, sizeof(defaultGUILogFont), &defaultGUILogFont); 344 344 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, defaultGUILogFont, fallbackFontName)) 345 return simpleFont ;345 return simpleFont.release(); 346 346 } 347 347 … … 351 351 if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nonClientMetrics), &nonClientMetrics, 0)) { 352 352 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfMessageFont, fallbackFontName)) 353 return simpleFont ;353 return simpleFont.release(); 354 354 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfMenuFont, fallbackFontName)) 355 return simpleFont ;355 return simpleFont.release(); 356 356 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfStatusFont, fallbackFontName)) 357 return simpleFont ;357 return simpleFont.release(); 358 358 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfCaptionFont, fallbackFontName)) 359 return simpleFont ;359 return simpleFont.release(); 360 360 if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfSmCaptionFont, fallbackFontName)) 361 return simpleFont ;361 return simpleFont.release(); 362 362 } 363 363 -
trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
r130105 r130160 133 133 } 134 134 135 Pass OwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const135 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const 136 136 { 137 137 float scaledSize = scaleFactor * m_platformData.size(); … … 139 139 FontPlatformData scaledFont(m_platformData); 140 140 scaledFont.setSize(scaledSize); 141 return adoptPtr(new SimpleFontData(scaledFont, true, false));141 return SimpleFontData::create(scaledFont, true, false); 142 142 } 143 143 … … 146 146 winfont.lfHeight = -lroundf(scaledSize * (m_platformData.useGDI() ? 1 : 32)); 147 147 HFONT hfont = CreateFontIndirect(&winfont); 148 return adoptPtr(new SimpleFontData(FontPlatformData(hfont, scaledSize, m_platformData.syntheticBold(), m_platformData.syntheticOblique(), m_platformData.useGDI()), isCustomFont(), false));149 } 150 151 SimpleFontData*SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const148 return SimpleFontData::create(FontPlatformData(hfont, scaledSize, m_platformData.syntheticBold(), m_platformData.syntheticOblique(), m_platformData.useGDI()), isCustomFont(), false); 149 } 150 151 PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const 152 152 { 153 153 if (!m_derivedFontData) … … 156 156 m_derivedFontData->smallCaps = createScaledFontData(fontDescription, cSmallCapsFontSizeMultiplier); 157 157 158 return m_derivedFontData->smallCaps .get();159 } 160 161 SimpleFontData*SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const158 return m_derivedFontData->smallCaps; 159 } 160 161 PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const 162 162 { 163 163 if (!m_derivedFontData) … … 166 166 m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5); 167 167 168 return m_derivedFontData->emphasisMark .get();168 return m_derivedFontData->emphasisMark; 169 169 } 170 170 -
trunk/Source/WebCore/platform/graphics/wince/FontCacheWinCE.cpp
r130105 r130160 226 226 } 227 227 228 const SimpleFontData*FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)228 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) 229 229 { 230 230 String familyName; … … 236 236 237 237 #if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2) 238 if (IMLangFontLink2* langFontLink = getFontLinkInterface()) { 239 #else 240 if (IMLangFontLink* langFontLink = getFontLinkInterface()) { 241 #endif 238 if (IMLangFontLink2* langFontLink = getFontLinkInterface()) 239 #else 240 if (IMLangFontLink* langFontLink = getFontLinkInterface()) 241 #endif 242 { 242 243 HGDIOBJ oldFont = GetCurrentObject(g_screenDC, OBJ_FONT); 243 244 HFONT hfont = 0; … … 268 269 // returned by MLang, so the font might not contain the character. 269 270 #if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2) 270 if (!currentFontContainsCharacter(langFontLink, g_screenDC, character)) { 271 #else 272 if (!currentFontContainsCharacter(langFontLink, g_screenDC, hfont, character, name)) { 273 #endif 271 if (!currentFontContainsCharacter(langFontLink, g_screenDC, character)) 272 #else 273 if (!currentFontContainsCharacter(langFontLink, g_screenDC, hfont, character, name)) 274 #endif 275 { 274 276 SelectObject(g_screenDC, oldFont); 275 277 langFontLink->ReleaseFont(hfont); … … 309 311 FontPlatformData* result = getCachedFontPlatformData(fontDescription, familyName); 310 312 if (result && result->hash() != origFont.hash()) { 311 if ( SimpleFontData*fontData = getCachedFontData(result, DoNotRetain))312 return fontData ;313 if (RefPtr<SimpleFontData> fontData = getCachedFontData(result, DoNotRetain)) 314 return fontData.release(); 313 315 } 314 316 } … … 317 319 } 318 320 319 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)321 PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font&) 320 322 { 321 323 return 0; 322 324 } 323 325 324 SimpleFontData*FontCache::getLastResortFallbackFont(const FontDescription& fontDesc, ShouldRetain shouldRetain)326 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDesc, ShouldRetain shouldRetain) 325 327 { 326 328 // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick -
trunk/Source/WebCore/platform/graphics/wince/SimpleFontDataWinCE.cpp
r130105 r130160 64 64 } 65 65 66 Pass OwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const66 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const 67 67 { 68 68 FontDescription fontDesc(fontDescription); … … 72 72 FontPlatformData* result = fontCache()->getCachedFontPlatformData(fontDesc, m_platformData.family()); 73 73 if (!result) 74 return nullptr;75 return adoptPtr(new SimpleFontData(*result));74 return 0; 75 return SimpleFontData::create(*result); 76 76 } 77 77 78 SimpleFontData*SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const78 PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const 79 79 { 80 80 if (!m_derivedFontData) … … 83 83 m_derivedFontData->smallCaps = createScaledFontData(fontDescription, .7); 84 84 85 return m_derivedFontData->smallCaps .get();85 return m_derivedFontData->smallCaps; 86 86 } 87 87 88 SimpleFontData*SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const88 PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const 89 89 { 90 90 if (!m_derivedFontData) … … 93 93 m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5); 94 94 95 return m_derivedFontData->emphasisMark .get();95 return m_derivedFontData->emphasisMark; 96 96 } 97 97 -
trunk/Source/WebCore/platform/graphics/wx/FontCacheWx.cpp
r130105 r130160 44 44 } 45 45 46 const SimpleFontData*FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)46 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) 47 47 { 48 SimpleFontData*fontData = 0;48 RefPtr<SimpleFontData> fontData = 0; 49 49 fontData = getCachedFontData(font.fontDescription(), font.family().family(), false, DoNotRetain); 50 50 if (!fontData->containsCharacters(characters, length)) … … 54 54 55 55 ASSERT(fontData); 56 return fontData ;56 return fontData.release(); 57 57 } 58 58 59 SimpleFontData*FontCache::getSimilarFontPlatformData(const Font& font)59 PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font) 60 60 { 61 SimpleFontData*simpleFontData = 0;61 RefPtr<SimpleFontData> simpleFontData = 0; 62 62 #if OS(DARWIN) 63 63 // Attempt to find an appropriate font using a match based on … … 79 79 simpleFontData = getCachedFontData(font.fontDescription(), font.family().family()); 80 80 81 return simpleFontData ;81 return simpleFontData.release(); 82 82 } 83 83 84 SimpleFontData*FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)84 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain) 85 85 { 86 86 // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick 87 87 // the default that the user would get without changing any prefs. 88 SimpleFontData*fallback = 0;88 RefPtr<SimpleFontData> fallback = 0; 89 89 #if OS(WINDOWS) 90 90 static AtomicString fallbackName("Arial Unicode MS"); … … 95 95 ASSERT(fallback); 96 96 97 return fallback ;97 return fallback.release(); 98 98 } 99 99 -
trunk/Source/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp
r130105 r130160 91 91 } 92 92 93 Pass OwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const93 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const 94 94 { 95 95 FontDescription desc = FontDescription(fontDescription); 96 96 desc.setSpecifiedSize(scaleFactor * fontDescription.computedSize()); 97 97 FontPlatformData platformData(desc, desc.family().family()); 98 return adoptPtr(new SimpleFontData(platformData, isCustomFont(), false));99 } 100 101 SimpleFontData*SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const98 return SimpleFontData::create(platformData, isCustomFont(), false); 99 } 100 101 PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const 102 102 { 103 103 if (!m_derivedFontData) … … 106 106 m_derivedFontData->smallCaps = createScaledFontData(fontDescription, .7); 107 107 108 return m_derivedFontData->smallCaps .get();109 } 110 111 SimpleFontData*SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const108 return m_derivedFontData->smallCaps; 109 } 110 111 PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const 112 112 { 113 113 if (!m_derivedFontData) … … 116 116 m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5); 117 117 118 return m_derivedFontData->emphasisMark .get();118 return m_derivedFontData->emphasisMark; 119 119 } 120 120
Note:
See TracChangeset
for help on using the changeset viewer.