Changeset 88260 in webkit
- Timestamp:
- Jun 7, 2011 1:46:28 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r88259 r88260 1 2011-06-07 Michael Saboff <msaboff@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 Fonts returned by FontCache::getFontDataForCharacters() are never released 6 https://bugs.webkit.org/show_bug.cgi?id=61875 7 8 This change allows fonts allocated as system fallback fonts to be 9 released. Previously, the reference counts for these fonts grew 10 without bound. This is implemented as an auto release class that wraps 11 accesses to the cache for system fallback fonts. All such accesses are 12 via the method FontCache::getFontDataForCharacters. The new class is 13 called FontCachePurgePreventer. When such an object exists, it protects 14 these fonts from deletion. 15 16 Most accesses to the font cache still use the reference counting 17 implemented by FontCache::getCacheFontData() and 18 FontCache::releaseFontData() and that operation is not affected by 19 this change. 20 21 Added local scoped instance of FontCachePurgePreventer to wrap code 22 that directly or indirectly accesses fonts via getFontDataForCharacters. 23 Did a few other miscellaneous bug fixes and changes to allow system 24 fallback fonts to be pruned from the GlyphPageTree. Changed the 25 calls to getFontData in the platform specific versions of 26 Fontcache::getFontDataForCharacters to not increment the reference 27 count. Moved the purge font check 28 outside of FontCache::getCachedFontData() into a separate method, 29 purgeInactiveFontDataIfNeeded() since almost all calls to 30 getCachedFontData() now happen when purging is not allowed. 31 purgeInactiveFontDataIfNeeded is invoked in enablePurging() when 32 m_purgePreventCount is 0. 33 34 No new test as the functionality has not changed. Improved font life 35 cycle management. 36 37 * WebCore.exp.in: Added FontCache::purgeInactiveFontDataIfNeeded(). 38 * html/canvas/CanvasRenderingContext2D.cpp: 39 (WebCore::CanvasRenderingContext2D::measureText): 40 (WebCore::CanvasRenderingContext2D::drawTextInternal): 41 Wrapped code accessing fallback fonts with local 42 FontCachePurgePreventer in these methods. 43 44 * page/FrameView.cpp: 45 (WebCore::FrameView::layout): 46 (WebCore::FrameView::paintContents): 47 Wrapped code accessing fallback fonts with local 48 FontCachePurgePreventer in these methods. 49 50 * platform/graphics/FontCache.cpp: 51 (WebCore::FontCache::FontCache): 52 (WebCore::FontCache::getCachedFontData): 53 Moved purge check to new method since it likely can't happen here. 54 (WebCore::FontCache::releaseFontData): 55 (WebCore::FontCache::purgeInactiveFontDataIfNeeded): 56 (WebCore::FontCache::purgeInactiveFontData): 57 Made purging conditional on m_purgePreventCount. Now some fonts 58 in the cache are reference counted while other can be purged 59 outside of code wrapped by in scope FontCachePurgePreventer objects. 60 61 * platform/graphics/FontCache.h: 62 (WebCore::FontCache::disablePurging): 63 (WebCore::FontCache::enablePurging): 64 (WebCore::FontCachePurgePreventer::FontCachePurgePreventer): 65 (WebCore::FontCachePurgePreventer::~FontCachePurgePreventer): 66 Added new simple purge prevention wrapper class and methods 67 that it calls in FontCache actually prevent purging. The 68 simple methods inlined to reduce overhead. 69 70 * platform/graphics/FontFastPath.cpp: 71 (WebCore::Font::glyphDataForCharacter): Update level in 72 glyph page tree for system fallback fonts so pruning works. 73 74 * platform/graphics/GlyphPage.h: 75 (WebCore::GlyphPage::clearForFontData): New method used for pruning 76 * platform/graphics/GlyphPageTreeNode.cpp: 77 (WebCore::GlyphPageTreeNode::pruneFontData): 78 Now we prune system fallback fonts. 79 80 * platform/graphics/chromium/FontCacheChromiumWin.cpp: 81 (WebCore::FontCache::getFontDataForCharacters): 82 * platform/graphics/freetype/FontCacheFreeType.cpp: 83 (WebCore::FontCache::getFontDataForCharacters): 84 * platform/graphics/haiku/FontCacheHaiku.cpp: 85 (WebCore::FontCache::getFontDataForCharacters): 86 * platform/graphics/mac/FontCacheMac.mm: 87 (WebCore::FontCache::getFontDataForCharacters): 88 * platform/graphics/qt/FontCacheQt.cpp: 89 (WebCore::FontCache::getFontDataForCharacters): 90 * platform/graphics/win/FontCacheWin.cpp: 91 (WebCore::FontCache::getFontDataForCharacters): 92 * platform/graphics/wince/FontCacheWinCE.cpp: 93 * platform/graphics/wx/FontCacheWx.cpp: 94 (WebCore::FontCache::getFontDataForCharacters): 95 Changed the calls to getFontData() to not increment the reference 96 count. The caller of this getFontDataForCharacters() (currently only 97 Font::glyphDataForCharacter() in fontFastPath.cpp) and it's callers 98 don't attempt to release the returned fonts so we use the purge 99 protection described above. 100 101 * rendering/InlineTextBox.cpp: 102 (WebCore::InlineTextBox::selectionRect): 103 (WebCore::InlineTextBox::offsetForPosition): 104 (WebCore::InlineTextBox::positionForOffset): 105 Wrapped code accessing fallback fonts with local 106 FontCachePurgePreventer in these methods. 107 108 * rendering/RenderImage.cpp: 109 (WebCore::RenderImage::setImageSizeForAltText): 110 Wrapped code accessing fallback fonts with local 111 FontCachePurgePreventer in this method. 112 113 * rendering/RenderListBox.cpp: 114 (WebCore::RenderListBox::updateFromElement): 115 (WebCore::RenderListBox::paintItemForeground): 116 Wrapped code accessing fallback fonts with local 117 FontCachePurgePreventer in these methods 118 119 * rendering/svg/SVGInlineTextBox.cpp: 120 (WebCore::SVGInlineTextBox::selectionRectForTextFragment): 121 Wrapped code accessing fallback fonts with local 122 FontCachePurgePreventer in this method. 123 1 124 2011-06-07 Tim Horton <timothy_horton@apple.com> 2 125 -
trunk/Source/WebCore/WebCore.exp.in
r88178 r88260 924 924 __ZN7WebCore9FontCache21inactiveFontDataCountEv 925 925 __ZN7WebCore9FontCache21purgeInactiveFontDataEi 926 __ZN7WebCore9FontCache29purgeInactiveFontDataIfNeededEv 926 927 __ZN7WebCore9FrameTree11appendChildEN3WTF10PassRefPtrINS_5FrameEEE 927 928 __ZN7WebCore9FrameTree7setNameERKN3WTF12AtomicStringE -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r87473 r88260 44 44 #include "ExceptionCode.h" 45 45 #include "FloatConversion.h" 46 #include "FontCache.h" 46 47 #include "GraphicsContext.h" 47 48 #include "HTMLCanvasElement.h" … … 1875 1876 PassRefPtr<TextMetrics> CanvasRenderingContext2D::measureText(const String& text) 1876 1877 { 1878 FontCachePurgePreventer fontCachePurgePreventer; 1879 1877 1880 RefPtr<TextMetrics> metrics = TextMetrics::create(); 1878 1881 … … 1901 1904 if (!isfinite(x) | !isfinite(y)) 1902 1905 return; 1906 1907 FontCachePurgePreventer fontCachePurgePreventer; 1903 1908 1904 1909 const Font& font = accessFont(); -
trunk/Source/WebCore/page/FrameView.cpp
r88250 r88260 38 38 #include "FloatRect.h" 39 39 #include "FocusController.h" 40 #include "FontCache.h" 40 41 #include "Frame.h" 41 42 #include "FrameActionScheduler.h" … … 897 898 } 898 899 900 FontCachePurgePreventer fontCachePurgePreventer; 901 899 902 m_nestedLayoutCount++; 900 903 … … 2445 2448 if (needsLayout()) 2446 2449 return; 2450 2451 FontCachePurgePreventer fontCachePurgePreventer; 2447 2452 2448 2453 #if USE(ACCELERATED_COMPOSITING) -
trunk/Source/WebCore/platform/graphics/FontCache.cpp
r83664 r88260 35 35 #include "FontPlatformData.h" 36 36 #include "FontSelector.h" 37 #include "GlyphPageTreeNode.h" 37 38 #include <wtf/HashMap.h> 38 39 #include <wtf/ListHashSet.h> … … 51 52 52 53 FontCache::FontCache() 54 : m_purgePreventCount(0) 53 55 { 54 56 } … … 250 252 static FontDataCache* gFontDataCache = 0; 251 253 252 const int cMaxInactiveFontData = 120;// Pretty Low Threshold253 const int cTargetInactiveFontData = 100;254 const int cMaxInactiveFontData = 50; // Pretty Low Threshold 255 const int cTargetInactiveFontData = 30; 254 256 static ListHashSet<const SimpleFontData*>* gInactiveFontData = 0; 255 257 256 SimpleFontData* FontCache::getCachedFontData(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName )258 SimpleFontData* FontCache::getCachedFontData(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName, ShouldRetain shouldRetain) 257 259 { 258 260 FontPlatformData* platformData = getCachedFontPlatformData(fontDescription, family, checkingAlternateName); … … 260 262 return 0; 261 263 262 return getCachedFontData(platformData );263 } 264 265 SimpleFontData* FontCache::getCachedFontData(const FontPlatformData* platformData )264 return getCachedFontData(platformData, shouldRetain); 265 } 266 267 SimpleFontData* FontCache::getCachedFontData(const FontPlatformData* platformData, ShouldRetain shouldRetain) 266 268 { 267 269 if (!platformData) 268 270 return 0; 271 272 #if !ASSERT_DISABLED 273 if (shouldRetain == DoNotRetain) 274 ASSERT(m_purgePreventCount); 275 #endif 269 276 270 277 if (!gFontDataCache) { … … 272 279 gInactiveFontData = new ListHashSet<const SimpleFontData*>; 273 280 } 274 281 275 282 FontDataCache::iterator result = gFontDataCache->find(*platformData); 276 283 if (result == gFontDataCache->end()) { 277 pair<SimpleFontData*, unsigned> newValue(new SimpleFontData(*platformData), 1);284 pair<SimpleFontData*, unsigned> newValue(new SimpleFontData(*platformData), shouldRetain == Retain ? 1 : 0); 278 285 gFontDataCache->set(*platformData, newValue); 286 if (shouldRetain == DoNotRetain) 287 gInactiveFontData->add(newValue.first); 279 288 return newValue.first; 280 289 } 281 if (!result.get()->second.second++) { 290 291 if (!result.get()->second.second) { 282 292 ASSERT(gInactiveFontData->contains(result.get()->second.first)); 283 293 gInactiveFontData->remove(result.get()->second.first); 284 294 } 285 295 296 if (shouldRetain == Retain) 297 result.get()->second.second++; 298 else if (!result.get()->second.second) { 299 // If shouldRetain is DoNotRetain and count is 0, we want to remove the fontData from 300 // gInactiveFontData (above) and re-add here to update LRU position. 301 gInactiveFontData->add(result.get()->second.first); 302 } 303 286 304 return result.get()->second.first; 287 305 } … … 295 313 ASSERT(it != gFontDataCache->end()); 296 314 297 if (!--it->second.second) { 315 ASSERT(it->second.second); 316 if (!--it->second.second) 298 317 gInactiveFontData->add(fontData); 299 if (gInactiveFontData->size() > cMaxInactiveFontData) 300 purgeInactiveFontData(gInactiveFontData->size() - cTargetInactiveFontData); 301 } 318 } 319 320 void FontCache::purgeInactiveFontDataIfNeeded() 321 { 322 if (gInactiveFontData && !m_purgePreventCount && gInactiveFontData->size() > cMaxInactiveFontData) 323 purgeInactiveFontData(gInactiveFontData->size() - cTargetInactiveFontData); 302 324 } 303 325 304 326 void FontCache::purgeInactiveFontData(int count) 305 327 { 306 if (!gInactiveFontData )328 if (!gInactiveFontData || m_purgePreventCount) 307 329 return; 308 330 -
trunk/Source/WebCore/platform/graphics/FontCache.h
r76248 r88260 52 52 53 53 class FontCache { 54 friend class FontCachePurgePreventer; 55 56 enum ShouldRetain { Retain, DoNotRetain }; 57 54 58 WTF_MAKE_NONCOPYABLE(FontCache); WTF_MAKE_FAST_ALLOCATED; 55 59 public: … … 58 62 const FontData* getFontData(const Font&, int& familyIndex, FontSelector*); 59 63 void releaseFontData(const SimpleFontData*); 60 64 61 65 // This method is implemented by the platform. 62 // FIXME: Font data returned by this method never go inactive because callers don't track and release them.63 66 const SimpleFontData* getFontDataForCharacters(const Font&, const UChar* characters, int length); 64 67 65 68 // Also implemented by the platform. 66 69 void platformInit(); … … 81 84 void getTraitsInFamily(const AtomicString&, Vector<unsigned>&); 82 85 83 SimpleFontData* getCachedFontData(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName = false);86 SimpleFontData* getCachedFontData(const FontDescription&, const AtomicString&, bool checkingAlternateName = false, ShouldRetain = Retain); 84 87 SimpleFontData* getLastResortFallbackFont(const FontDescription&); 85 88 … … 98 101 ~FontCache(); 99 102 103 void disablePurging() { m_purgePreventCount++; } 104 void enablePurging() 105 { 106 ASSERT(m_purgePreventCount); 107 if (!--m_purgePreventCount) 108 purgeInactiveFontDataIfNeeded(); 109 } 110 111 void purgeInactiveFontDataIfNeeded(); 112 100 113 // FIXME: This method should eventually be removed. 101 114 FontPlatformData* getCachedFontPlatformData(const FontDescription&, const AtomicString& family, bool checkingAlternateName = false); … … 105 118 FontPlatformData* createFontPlatformData(const FontDescription&, const AtomicString& family); 106 119 107 SimpleFontData* getCachedFontData(const FontPlatformData*); 120 SimpleFontData* getCachedFontData(const FontPlatformData*, ShouldRetain = Retain); 121 122 // Don't purge if this count is > 0; 123 int m_purgePreventCount; 108 124 109 125 friend class SimpleFontData; // For getCachedFontData(const FontPlatformData*) … … 114 130 FontCache* fontCache(); 115 131 132 class FontCachePurgePreventer { 133 public: 134 FontCachePurgePreventer() { fontCache()->disablePurging(); } 135 ~FontCachePurgePreventer() { fontCache()->enablePurging(); } 136 }; 137 116 138 } 117 139 -
trunk/Source/WebCore/platform/graphics/FontFastPath.cpp
r87215 r88260 38 38 using namespace WTF; 39 39 using namespace Unicode; 40 using namespace std; 40 41 41 42 namespace WebCore { … … 211 212 // So we just always set the glyph to be same as the character, and let GDI solve it. 212 213 page->setGlyphDataForCharacter(c, c, characterFontData); 214 characterFontData->setMaxGlyphPageTreeLevel(max(characterFontData->maxGlyphPageTreeLevel(), node->level())); 213 215 return page->glyphDataForCharacter(c); 214 216 #else 215 217 page->setGlyphDataForCharacter(c, data.glyph, data.fontData); 218 data.fontData->setMaxGlyphPageTreeLevel(max(data.fontData->maxGlyphPageTreeLevel(), node->level())); 216 219 #endif 217 220 } … … 226 229 // See comment about WINCE GDI handling near setGlyphDataForCharacter above. 227 230 page->setGlyphDataForCharacter(c, c, data.fontData); 231 data.fontData->setMaxGlyphPageTreeLevel(max(data.fontData->maxGlyphPageTreeLevel(), node->level())); 228 232 return page->glyphDataForCharacter(c); 229 233 #else 230 234 page->setGlyphDataForCharacter(c, data.glyph, data.fontData); 235 data.fontData->setMaxGlyphPageTreeLevel(max(data.fontData->maxGlyphPageTreeLevel(), node->level())); 231 236 #endif 232 237 } -
trunk/Source/WebCore/platform/graphics/GlyphPage.h
r84490 r88260 122 122 memset(m_glyphFontData, 0, sizeof(m_glyphFontData)); 123 123 } 124 124 125 void clearForFontData(const SimpleFontData* fontData) 126 { 127 for (size_t i = 0; i < size; ++i) { 128 if (m_glyphFontData[i] == fontData) { 129 m_glyphs[i] = 0; 130 m_glyphFontData[i] = 0; 131 } 132 } 133 } 134 125 135 GlyphPageTreeNode* owner() const { return m_owner; } 126 136 -
trunk/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp
r84264 r88260 375 375 return; 376 376 377 // Prune fall back child (if any) of this font. 378 if (m_systemFallbackChild && m_systemFallbackChild->m_page) 379 m_systemFallbackChild->m_page->clearForFontData(fontData); 380 377 381 // Prune any branch that contains this FontData. 378 382 HashMap<const FontData*, GlyphPageTreeNode*>::iterator child = m_children.find(fontData); 379 if (child == m_children.end()) { 380 // If there is no level-1 node for fontData, then there is no deeper node for it in this tree. 381 if (!level) 382 return; 383 } else { 383 if (child != m_children.end()) { 384 384 GlyphPageTreeNode* node = child->second; 385 385 m_children.remove(fontData); -
trunk/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp
r79174 r88260 507 507 // So, we have to use '<=" rather than '<' to see if we found a font 508 508 // covering the character. 509 if (i <= numFonts) 510 return getCachedFontData(data);509 if (i <= numFonts) 510 return getCachedFontData(data, DoNotRetain); 511 511 512 512 return 0; -
trunk/Source/WebCore/platform/graphics/chromium/FontCacheLinux.cpp
r80654 r88260 65 65 66 66 AtomicString atomicFamily(family); 67 return getCachedFontData(getCachedFontPlatformData(font.fontDescription(), atomicFamily, false));67 return getCachedFontData(getCachedFontPlatformData(font.fontDescription(), atomicFamily, DoNotRetain)); 68 68 } 69 69 -
trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
r78614 r88260 90 90 if (fallbackPattern) { 91 91 FontPlatformData alternateFontData(fallbackPattern.get(), font.fontDescription()); 92 return getCachedFontData(&alternateFontData );92 return getCachedFontData(&alternateFontData, DoNotRetain); 93 93 } 94 94 … … 98 98 return 0; 99 99 FontPlatformData alternateFontData(resultPattern.get(), font.fontDescription()); 100 return getCachedFontData(&alternateFontData );100 return getCachedFontData(&alternateFontData, DoNotRetain); 101 101 } 102 102 -
trunk/Source/WebCore/platform/graphics/haiku/FontCacheHaiku.cpp
r57517 r88260 50 50 { 51 51 FontPlatformData data(font.fontDescription(), font.family().family()); 52 return getCachedFontData(&data );52 return getCachedFontData(&data, DoNotRetain); 53 53 } 54 54 -
trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm
r87462 r88260 153 153 !font.isPlatformFont() && (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTrait), 154 154 platformData.m_orientation); 155 return getCachedFontData(&alternateFont); 155 156 return getCachedFontData(&alternateFont, DoNotRetain); 156 157 } 157 158 -
trunk/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp
r85853 r88260 81 81 return 0; 82 82 FontPlatformData alternateFont(computedFont); 83 return getCachedFontData(&alternateFont );83 return getCachedFontData(&alternateFont, DoNotRetain); 84 84 #else 85 85 Q_UNUSED(font); -
trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
r84996 r88260 286 286 FontPlatformData* result = getCachedFontPlatformData(font.fontDescription(), familyName); 287 287 if (result) 288 fontData = getCachedFontData(result );288 fontData = getCachedFontData(result, false); 289 289 } 290 290 -
trunk/Source/WebCore/platform/graphics/wince/FontCacheWinCE.cpp
r67788 r88260 309 309 FontPlatformData* result = getCachedFontPlatformData(fontDescription, familyName); 310 310 if (result && result->hash() != origFont.hash()) { 311 if (SimpleFontData* fontData = getCachedFontData(result ))311 if (SimpleFontData* fontData = getCachedFontData(result, false)) 312 312 return fontData; 313 313 } -
trunk/Source/WebCore/platform/graphics/wx/FontCacheWx.cpp
r59780 r88260 43 43 { 44 44 SimpleFontData* fontData = 0; 45 fontData = getCachedFontData(font.fontDescription(), font.family().family() );45 fontData = getCachedFontData(font.fontDescription(), font.family().family(), false, false); 46 46 if (!fontData->containsCharacters(characters, length)) 47 47 fontData = getSimilarFontPlatformData(font); 48 48 if (!fontData->containsCharacters(characters, length)) 49 49 fontData = getLastResortFallbackFont(font.fontDescription()); 50 50 51 51 ASSERT(fontData); 52 52 return fontData; -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r88188 r88260 30 30 #include "Editor.h" 31 31 #include "EllipsisBox.h" 32 #include "FontCache.h" 32 33 #include "Frame.h" 33 34 #include "GraphicsContext.h" … … 180 181 if (sPos > ePos) 181 182 return IntRect(); 183 184 FontCachePurgePreventer fontCachePurgePreventer; 182 185 183 186 RenderText* textObj = textRenderer(); … … 1233 1236 return leftOffset; 1234 1237 1238 FontCachePurgePreventer fontCachePurgePreventer; 1239 1235 1240 RenderText* text = toRenderText(renderer()); 1236 1241 RenderStyle* style = text->style(m_firstLine); … … 1249 1254 if (isLineBreak()) 1250 1255 return logicalLeft(); 1256 1257 FontCachePurgePreventer fontCachePurgePreventer; 1251 1258 1252 1259 RenderText* text = toRenderText(renderer()); -
trunk/Source/WebCore/rendering/RenderImage.cpp
r88250 r88260 28 28 #include "RenderImage.h" 29 29 30 #include "FontCache.h" 30 31 #include "Frame.h" 31 32 #include "FrameSelection.h" … … 103 104 // we have an alt and the user meant it (its not a text we invented) 104 105 if (!m_altText.isEmpty()) { 106 FontCachePurgePreventer fontCachePurgePreventer; 107 105 108 const Font& font = style()->font(); 106 109 IntSize textSize(min(font.width(RenderBlock::constructTextRun(this, font, m_altText, style())), maxAltTextWidth), min(font.fontMetrics().height(), maxAltTextHeight)); -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r88193 r88260 38 38 #include "EventQueue.h" 39 39 #include "FocusController.h" 40 #include "FontCache.h" 40 41 #include "Frame.h" 41 42 #include "FrameSelection.h" … … 99 100 void RenderListBox::updateFromElement() 100 101 { 102 FontCachePurgePreventer fontCachePurgePreventer; 103 101 104 if (m_optionsChanged) { 102 105 const Vector<Element*>& listItems = toSelectElement(static_cast<Element*>(node()))->listItems(); … … 359 362 void RenderListBox::paintItemForeground(PaintInfo& paintInfo, const IntPoint& paintOffset, int listIndex) 360 363 { 364 FontCachePurgePreventer fontCachePurgePreventer; 365 361 366 SelectElement* select = toSelectElement(static_cast<Element*>(node())); 362 367 const Vector<Element*>& listItems = select->listItems(); -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
r88188 r88260 25 25 #if ENABLE(SVG) 26 26 #include "FloatConversion.h" 27 #include "FontCache.h" 27 28 #include "GraphicsContext.h" 28 29 #include "InlineFlowBox.h" … … 91 92 ASSERT(style); 92 93 94 FontCachePurgePreventer fontCachePurgePreventer; 95 93 96 RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer()); 94 97 ASSERT(textRenderer); -
trunk/Source/WebKit/mac/ChangeLog
r88178 r88260 1 2011-06-06 Michael Saboff <msaboff@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 Fonts returned by FontCache::getFontDataForCharacters() are never released 6 https://bugs.webkit.org/show_bug.cgi?id=61875 7 8 This change allows fonts allocated as system fallback fonts to be 9 released. Previously, the reference counts for these fonts grew 10 without bound. This is implemented as an auto release class that wraps 11 accesses to the cache for system fallback fonts. All such accesses are 12 via the method FontCache::getFontDataForCharacters. The new class is 13 called FontCachePurgePreventer. When such an object exists, it protects 14 these fonts from deletion. 15 16 See more comments for this defect in Source/WebCore/ChangeLog. 17 18 * Misc/WebKitNSStringExtras.mm: 19 (-[NSString _web_drawAtPoint:font:textColor:allowingFontSmoothing:]): 20 (-[NSString _web_widthWithFont:]): 21 Wrapped code accessing fallback fonts with local 22 FontCachePurgePreventer in these methods. 23 24 * Misc/WebStringTruncator.mm: 25 (+[WebStringTruncator centerTruncateString:toWidth:]): 26 (+[WebStringTruncator centerTruncateString:toWidth:withFont:]): 27 (+[WebStringTruncator rightTruncateString:toWidth:withFont:]): 28 (+[WebStringTruncator widthOfString:font:]): 29 Wrapped code accessing fallback fonts with local 30 FontCachePurgePreventer in these methods. 31 1 32 2011-06-06 Peter Kasting <pkasting@google.com> 2 33 -
trunk/Source/WebKit/mac/Misc/WebKitNSStringExtras.mm
r85036 r88260 30 30 31 31 #import <WebCore/Font.h> 32 #import <WebCore/FontCache.h> 32 33 #import <WebCore/GraphicsContext.h> 33 34 #import <WebCore/TextRun.h> … … 89 90 if (!flipped) 90 91 CGContextScaleCTM(cgContext, 1, -1); 92 93 FontCachePurgePreventer fontCachePurgePreventer; 91 94 92 95 Font webCoreFont(FontPlatformData(font, [font pointSize]), ![nsContext isDrawingToScreen], fontSmoothingIsAllowed ? AutoSmoothing : Antialiased); … … 135 138 136 139 if (canUseFastRenderer(buffer.data(), length)) { 140 FontCachePurgePreventer fontCachePurgePreventer; 141 137 142 Font webCoreFont(FontPlatformData(font, [font pointSize]), ![[NSGraphicsContext currentContext] isDrawingToScreen]); 138 143 TextRun run(buffer.data(), length); -
trunk/Source/WebKit/mac/Misc/WebStringTruncator.mm
r72141 r88260 31 31 #import "WebSystemInterface.h" 32 32 #import <WebCore/Font.h> 33 #import <WebCore/FontCache.h> 33 34 #import <WebCore/FontPlatformData.h> 34 35 #import <WebCore/PlatformString.h> … … 73 74 + (NSString *)centerTruncateString:(NSString *)string toWidth:(float)maxWidth 74 75 { 76 FontCachePurgePreventer fontCachePurgePreventer; 75 77 return StringTruncator::centerTruncate(string, maxWidth, fontFromNSFont(defaultMenuFont())); 76 78 } … … 78 80 + (NSString *)centerTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font 79 81 { 82 FontCachePurgePreventer fontCachePurgePreventer; 80 83 return StringTruncator::centerTruncate(string, maxWidth, fontFromNSFont(font)); 81 84 } … … 83 86 + (NSString *)rightTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font 84 87 { 88 FontCachePurgePreventer fontCachePurgePreventer; 85 89 return StringTruncator::rightTruncate(string, maxWidth, fontFromNSFont(font)); 86 90 } … … 88 92 + (float)widthOfString:(NSString *)string font:(NSFont *)font 89 93 { 94 FontCachePurgePreventer fontCachePurgePreventer; 90 95 return StringTruncator::width(string, fontFromNSFont(font)); 91 96 } -
trunk/Source/WebKit/win/ChangeLog
r88159 r88260 1 2011-06-06 Michael Saboff <msaboff@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 Fonts returned by FontCache::getFontDataForCharacters() are never released 6 https://bugs.webkit.org/show_bug.cgi?id=61875 7 8 This change allows fonts allocated as system fallback fonts to be 9 released. Previously, the reference counts for these fonts grew 10 without bound. This is implemented as an auto release class that wraps 11 accesses to the cache for system fallback fonts. All such accesses are 12 via the method FontCache::getFontDataForCharacters. The new class is 13 called FontCachePurgePreventer. When such an object exists, it protects 14 these fonts from deletion. 15 16 See more comments for this defect in Source/WebCore/ChangeLog. 17 18 * WebKitGraphics.cpp: 19 (CenterTruncateStringToWidth): 20 (RightTruncateStringToWidth): 21 Wrapped code accessing fallback fonts with local 22 FontCachePurgePreventer in these methods. 23 1 24 2011-06-04 Dominic Cooney <dominicc@chromium.org> 2 25 -
trunk/Source/WebKit/win/WebKitGraphics.cpp
r82294 r88260 33 33 34 34 #include <WebCore/Font.h> 35 #include <WebCore/FontCache.h> 35 36 #include <WebCore/FontDescription.h> 36 37 #include <WebCore/FontSelector.h> … … 148 149 ASSERT(buffer); 149 150 151 FontCachePurgePreventer fontCachePurgePreventer; 152 150 153 String result = StringTruncator::centerTruncate(String(text, length), width, makeFont(description)); 151 154 memcpy(buffer, result.characters(), result.length() * sizeof(UChar)); … … 157 160 { 158 161 ASSERT(buffer); 162 163 FontCachePurgePreventer fontCachePurgePreventer; 159 164 160 165 String result = StringTruncator::rightTruncate(String(text, length), width, makeFont(description));
Note: See TracChangeset
for help on using the changeset viewer.