Changeset 130160 in webkit


Ignore:
Timestamp:
Oct 2, 2012, 6:03:18 AM (13 years ago)
Author:
schenney@chromium.org
Message:

Refactor WebCore::FontData handling to clarify pointer ownership
https://bugs.webkit.org/show_bug.cgi?id=95866

Reviewed by Eric Seidel.

Re-commit for a rolled-out original, now with Chromium Windows build fix.

This patch makes all FontData and derived classes ref-counted in all
code paths that lead to caching or other retention of a
pointer. The goal is to avert crashes and memory leaks, and to bring
the code more in line with current WebKit practices.

Specifically, this patch allows us to use ref pointers for all the
FontData stored in FontFallbackList objects. The FontFallbackList can
then own custom font data and manage its lifetime (forthcoming patch).
Currently Document owns custom font data and does an end run around
FontFallbackList in deleting glyph pages and custom font data, leaving
FontFallbackList with invalid pointers.

All FontData derived classes have been switched to use static create
methods with private constructors.

All caches that hold FontData now use RefPtrs.

All methods that construct new font data now return PassRefPtr, with the
exception of code only used to generate temporary data for text run layout.

All methods that handle FontData in a call stack that passes through
FontFallbackList::fontDataAt return PassRefPtr.

Performance tested with both WebKit Perf-o-matic, which showed
performance changes in the noise, and Chrome's page cycling tests with
the acid3 benchmark set, which showed no performance difference at all.

No new tests as this is refactoring code only and has no impact on functionality.

  • css/CSSFontFace.cpp:

(WebCore::CSSFontFace::getFontData):

  • css/CSSFontFace.h:

(CSSFontFace):

  • css/CSSFontFaceSource.cpp:

(WebCore::CSSFontFaceSource::getFontData):

  • css/CSSFontFaceSource.h:

(CSSFontFaceSource):

  • css/CSSFontSelector.cpp:

(WebCore::fontDataForGenericFamily):
(WebCore::CSSFontSelector::getFontData):

  • css/CSSFontSelector.h:
  • css/CSSSegmentedFontFace.cpp:

(WebCore::appendFontDataWithInvalidUnicodeRangeIfLoading):
(WebCore::CSSSegmentedFontFace::getFontData):

  • css/CSSSegmentedFontFace.h:

(CSSSegmentedFontFace):

  • dom/Document.cpp:

(WebCore::Document::registerCustomFont):

  • dom/Document.h:

(Document):

  • platform/graphics/Font.h:

(WebCore):

  • platform/graphics/FontCache.cpp:

(WebCore):
(WebCore::FontCache::getCachedFontData):
(WebCore::FontCache::getNonRetainedLastResortFallbackFont):
(WebCore::FontCache::releaseFontData):
(WebCore::FontCache::purgeInactiveFontData):
(WebCore::FontCache::getFontData):

  • platform/graphics/FontCache.h:

(FontCache):

  • platform/graphics/FontData.h:
  • platform/graphics/FontFallbackList.cpp:

(WebCore::FontFallbackList::releaseFontData):
(WebCore::FontFallbackList::fontDataAt):
(WebCore::FontFallbackList::setPlatformFont):

  • platform/graphics/FontFallbackList.h:

(FontFallbackList):

  • platform/graphics/FontFastPath.cpp:

(WebCore::Font::glyphDataAndPageForCharacter):

  • platform/graphics/FontSelector.h:

(FontSelector):

  • platform/graphics/GlyphPageTreeNode.cpp:

(WebCore::GlyphPageTreeNode::initializePage):

  • platform/graphics/SegmentedFontData.cpp:

(WebCore::SegmentedFontData::fontDataForCharacter):

  • platform/graphics/SegmentedFontData.h:

(WebCore::FontDataRange::FontDataRange):
(WebCore::FontDataRange::fontData):
(FontDataRange):
(WebCore::SegmentedFontData::create):
(SegmentedFontData):
(WebCore::SegmentedFontData::SegmentedFontData):

  • platform/graphics/SimpleFontData.cpp:

(WebCore::SimpleFontData::verticalRightOrientationFontData):
(WebCore::SimpleFontData::uprightOrientationFontData):
(WebCore::SimpleFontData::brokenIdeographFontData):

  • platform/graphics/SimpleFontData.h:

(WebCore::SimpleFontData::create):
(SimpleFontData):
(WebCore::SimpleFontData::variantFontData):
(DerivedFontData):

  • platform/graphics/chromium/FontCacheAndroid.cpp:

(WebCore::FontCache::getFontDataForCharacters):
(WebCore::FontCache::getSimilarFontPlatformData):
(WebCore::FontCache::getLastResortFallbackFont):

  • platform/graphics/chromium/FontCacheChromiumWin.cpp:

(WebCore::FontCache::fontDataFromDescriptionAndLogFont):
(GetLastResortFallbackFontProcData):
(WebCore::FontCache::getFontDataForCharacters):
(WebCore::FontCache::getSimilarFontPlatformData):
(WebCore::FontCache::getLastResortFallbackFont):

  • platform/graphics/chromium/SimpleFontDataChromiumWin.cpp:

(WebCore::SimpleFontData::createScaledFontData):
(WebCore::SimpleFontData::smallCapsFontData):
(WebCore::SimpleFontData::emphasisMarkFontData):

  • platform/graphics/freetype/FontCacheFreeType.cpp:

(WebCore::FontCache::getFontDataForCharacters):
(WebCore::FontCache::getSimilarFontPlatformData):
(WebCore::FontCache::getLastResortFallbackFont):

  • platform/graphics/freetype/SimpleFontDataFreeType.cpp:

(WebCore::SimpleFontData::createScaledFontData):
(WebCore::SimpleFontData::smallCapsFontData):
(WebCore::SimpleFontData::emphasisMarkFontData):

  • platform/graphics/mac/ComplexTextControllerCoreText.mm:

(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):

  • platform/graphics/mac/FontCacheMac.mm:

(WebCore::FontCache::getFontDataForCharacters):
(WebCore::FontCache::getSimilarFontPlatformData):
(WebCore::FontCache::getLastResortFallbackFont):

  • platform/graphics/mac/FontComplexTextMac.cpp:

(WebCore::Font::fontDataForCombiningCharacterSequence):

  • platform/graphics/mac/SimpleFontDataMac.mm:

(WebCore::SimpleFontData::platformDestroy):
(WebCore::SimpleFontData::createScaledFontData):
(WebCore::SimpleFontData::smallCapsFontData):
(WebCore::SimpleFontData::emphasisMarkFontData):

  • platform/graphics/pango/FontCachePango.cpp:

(WebCore::FontCache::getFontDataForCharacters):
(WebCore::FontCache::getSimilarFontPlatformData):
(WebCore::FontCache::getLastResortFallbackFont):

  • platform/graphics/pango/SimpleFontDataPango.cpp:

(WebCore::SimpleFontData::createScaledFontData):
(WebCore::SimpleFontData::smallCapsFontData):
(WebCore::SimpleFontData::emphasisMarkFontData):

  • platform/graphics/qt/FontCacheQt.cpp:

(WebCore::FontCache::getFontDataForCharacters):
(WebCore::FontCache::getSimilarFontPlatformData):
(WebCore::FontCache::getLastResortFallbackFont):

  • platform/graphics/qt/SimpleFontDataQt.cpp:

(WebCore::SimpleFontData::createScaledFontData):
(WebCore::SimpleFontData::smallCapsFontData):
(WebCore::SimpleFontData::emphasisMarkFontData):

  • platform/graphics/skia/FontCacheSkia.cpp:

(WebCore::FontCache::getFontDataForCharacters):
(WebCore::FontCache::getSimilarFontPlatformData):
(WebCore::FontCache::getLastResortFallbackFont):

  • platform/graphics/skia/SimpleFontDataSkia.cpp:

(WebCore::SimpleFontData::createScaledFontData):
(WebCore::SimpleFontData::smallCapsFontData):
(WebCore::SimpleFontData::emphasisMarkFontData):

  • platform/graphics/win/FontCacheWin.cpp:

(WebCore::FontCache::getFontDataForCharacters):
(WebCore::FontCache::getSimilarFontPlatformData):
(WebCore::FontCache::fontDataFromDescriptionAndLogFont):
(WebCore::FontCache::getLastResortFallbackFont):

  • platform/graphics/win/SimpleFontDataWin.cpp:

(WebCore::SimpleFontData::createScaledFontData):
(WebCore::SimpleFontData::smallCapsFontData):
(WebCore::SimpleFontData::emphasisMarkFontData):

  • platform/graphics/wince/FontCacheWinCE.cpp:

(WebCore::FontCache::getFontDataForCharacters):
(WebCore::FontCache::getSimilarFontPlatformData):
(WebCore::FontCache::getLastResortFallbackFont):

  • platform/graphics/wince/SimpleFontDataWinCE.cpp:

(WebCore::SimpleFontData::createScaledFontData):
(WebCore::SimpleFontData::smallCapsFontData):
(WebCore::SimpleFontData::emphasisMarkFontData):

  • platform/graphics/wx/FontCacheWx.cpp:

(WebCore::FontCache::getFontDataForCharacters):
(WebCore::FontCache::getSimilarFontPlatformData):
(WebCore::FontCache::getLastResortFallbackFont):

  • platform/graphics/wx/SimpleFontDataWx.cpp:

(WebCore::SimpleFontData::createScaledFontData):
(WebCore::SimpleFontData::smallCapsFontData):
(WebCore::SimpleFontData::emphasisMarkFontData):

Location:
trunk/Source/WebCore
Files:
45 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r130158 r130160  
     12012-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
    11872012-10-02  Christophe Dumez  <christophe.dumez@intel.com>
    2188
  • trunk/Source/WebCore/css/CSSFontFace.cpp

    r130105 r130160  
    9292}
    9393
    94 SimpleFontData* CSSFontFace::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic)
     94PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic)
    9595{
    9696    m_activeSource = 0;
     
    103103    size_t size = m_sources.size();
    104104    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)) {
    106106            m_activeSource = m_sources[i].get();
    107             return result;
     107            return result.release();
    108108        }
    109109    }
  • trunk/Source/WebCore/css/CSSFontFace.h

    r130105 r130160  
    6565    void fontLoaded(CSSFontFaceSource*);
    6666
    67     SimpleFontData* getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic);
     67    PassRefPtr<SimpleFontData> getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic);
    6868
    6969    struct UnicodeRange {
  • trunk/Source/WebCore/css/CSSFontFaceSource.cpp

    r130105 r130160  
    3434#include "FontCache.h"
    3535#include "FontDescription.h"
    36 #include "GlyphPageTreeNode.h"
    3736#include "SimpleFontData.h"
    3837
     
    9695}
    9796
    98 SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector)
     97PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector)
    9998{
    10099    // If the font hasn't loaded or an error occurred, then we've got nothing.
     
    115114                       | (fontDescription.textOrientation() == TextOrientationUpright ? 8 : 0) | (fontDescription.orientation() == Vertical ? 4 : 0) | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0);
    116115
    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.
    122119
    123120    // If we are still loading, then we let the system pick a font.
     
    158155                    }
    159156
    160                     fontData = adoptPtr(new SimpleFontData(SVGFontData::create(fontFaceElement), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));
     157                    fontData = SimpleFontData::create(SVGFontData::create(fontFaceElement), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
    161158                }
    162159            } else
     
    167164                    return 0;
    168165
    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);
    171168            }
    172169        } else {
     
    174171            // In-Document SVG Fonts
    175172            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);
    177174#endif
    178175        }
     
    185182        FontCachePurgePreventer fontCachePurgePreventer;
    186183        SimpleFontData* temporaryFont = fontCache()->getNonRetainedLastResortFallbackFont(fontDescription);
    187         fontData = adoptPtr(new SimpleFontData(temporaryFont->platformData(), true, true));
     184        fontData = SimpleFontData::create(temporaryFont->platformData(), true, true);
    188185    }
    189186
    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.
    196193}
    197194
  • trunk/Source/WebCore/css/CSSFontFaceSource.h

    r130105 r130160  
    6060    virtual void fontLoaded(CachedFont*);
    6161
    62     SimpleFontData* getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic, CSSFontSelector*);
     62    PassRefPtr<SimpleFontData> getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic, CSSFontSelector*);
    6363
    6464    void pruneTable();
     
    7777    CachedResourceHandle<CachedFont> m_font; // For remote fonts, a pointer to our cached resource.
    7878    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.
    8080
    8181#if ENABLE(SVG_FONTS)
  • trunk/Source/WebCore/css/CSSFontSelector.cpp

    r130105 r130160  
    351351}
    352352
    353 static FontData* fontDataForGenericFamily(Document* document, const FontDescription& fontDescription, const AtomicString& familyName)
     353static PassRefPtr<FontData> fontDataForGenericFamily(Document* document, const FontDescription& fontDescription, const AtomicString& familyName)
    354354{
    355355    if (!document || !document->frame())
     
    466466}
    467467
    468 FontData* CSSFontSelector::getFontData(const FontDescription& fontDescription, const AtomicString& familyName)
     468PassRefPtr<FontData> CSSFontSelector::getFontData(const FontDescription& fontDescription, const AtomicString& familyName)
    469469{
    470470    if (m_fontFaces.isEmpty()) {
  • trunk/Source/WebCore/css/CSSFontSelector.h

    r130105 r130160  
    5656    virtual unsigned version() const OVERRIDE { return m_version; }
    5757
    58     virtual FontData* getFontData(const FontDescription& fontDescription, const AtomicString& familyName);
     58    virtual PassRefPtr<FontData> getFontData(const FontDescription&, const AtomicString&);
    5959
    6060    void clearDocument();
  • trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp

    r130105 r130160  
    8282}
    8383
    84 static void appendFontDataWithInvalidUnicodeRangeIfLoading(SegmentedFontData* newFontData, const SimpleFontData* faceFontData, const Vector<CSSFontFace::UnicodeRange>& ranges)
     84static void appendFontDataWithInvalidUnicodeRangeIfLoading(SegmentedFontData* newFontData, PassRefPtr<SimpleFontData> prpFaceFontData, const Vector<CSSFontFace::UnicodeRange>& ranges)
    8585{
     86    RefPtr<SimpleFontData> faceFontData = prpFaceFontData;
    8687    if (faceFontData->isLoading()) {
    8788        newFontData->appendRange(FontDataRange(0, 0, faceFontData));
     
    99100}
    100101
    101 FontData* CSSSegmentedFontFace::getFontData(const FontDescription& fontDescription)
     102PassRefPtr<FontData> CSSSegmentedFontFace::getFontData(const FontDescription& fontDescription)
    102103{
    103104    if (!isValid())
     
    107108    unsigned hashKey = ((fontDescription.computedPixelSize() + 1) << (FontTraitsMaskWidth + 1)) | ((fontDescription.orientation() == Vertical ? 1 : 0) << FontTraitsMaskWidth) | desiredTraitsMask;
    108109
    109     SegmentedFontData*& fontData = m_fontDataTable.add(hashKey, 0).iterator->second;
     110    RefPtr<SegmentedFontData>& fontData = m_fontDataTable.add(hashKey, 0).iterator->second;
    110111    if (fontData)
    111112        return fontData;
    112113
    113     OwnPtr<SegmentedFontData> newFontData = adoptPtr(new SegmentedFontData);
     114    fontData = SegmentedFontData::create();
    114115
    115116    unsigned size = m_fontFaces.size();
     
    120121        bool syntheticBold = !(traitsMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask)) && (desiredTraitsMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask));
    121122        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)) {
    123124            ASSERT(!faceFontData->isSegmented());
    124             appendFontDataWithInvalidUnicodeRangeIfLoading(newFontData.get(), faceFontData, m_fontFaces[i]->ranges());
     125            appendFontDataWithInvalidUnicodeRangeIfLoading(fontData.get(), faceFontData.release(), m_fontFaces[i]->ranges());
    125126        }
    126127    }
    127     if (newFontData->numRanges()) {
     128    if (fontData->numRanges()) {
    128129        if (Document* document = m_fontSelector->document()) {
    129             fontData = newFontData.get();
    130             document->registerCustomFont(newFontData.release());
     130            document->registerCustomFont(fontData);
     131            return fontData;
    131132        }
    132133    }
    133134
    134     return fontData;
     135    return 0;
    135136}
    136137
  • trunk/Source/WebCore/css/CSSSegmentedFontFace.h

    r130105 r130160  
    5252    void appendFontFace(PassRefPtr<CSSFontFace>);
    5353
    54     FontData* getFontData(const FontDescription&);
     54    PassRefPtr<FontData> getFontData(const FontDescription&);
    5555
    5656private:
     
    6161
    6262    CSSFontSelector* m_fontSelector;
    63     HashMap<unsigned, SegmentedFontData*> m_fontDataTable;
     63    HashMap<unsigned, RefPtr<SegmentedFontData> > m_fontDataTable;
    6464    Vector<RefPtr<CSSFontFace>, 1> m_fontFaces;
    6565};
  • trunk/Source/WebCore/dom/Document.cpp

    r130105 r130160  
    19751975}
    19761976
    1977 void Document::registerCustomFont(PassOwnPtr<FontData> fontData)
     1977void Document::registerCustomFont(PassRefPtr<FontData> fontData)
    19781978{
    19791979    m_customFonts.append(fontData);
  • trunk/Source/WebCore/dom/Document.h

    r130105 r130160  
    541541    PassRefPtr<RenderStyle> styleForPage(int pageIndex);
    542542
    543     void registerCustomFont(PassOwnPtr<FontData>);
     543    void registerCustomFont(PassRefPtr<FontData>);
    544544
    545545    // Returns true if page box (margin boxes and page borders) is visible.
     
    12571257    PendingSheetLayout m_pendingSheetLayout;
    12581258
    1259     Vector<OwnPtr<FontData> > m_customFonts;
     1259    Vector<RefPtr<FontData> > m_customFonts;
    12601260
    12611261    Frame* m_frame;
  • trunk/Source/WebCore/platform/graphics/Font.h

    r130105 r130160  
    5252class FontSelector;
    5353class GlyphBuffer;
    54 class GlyphPageTreeNode;
    5554class GraphicsContext;
    5655class RenderText;
  • trunk/Source/WebCore/platform/graphics/FontCache.cpp

    r130105 r130160  
    3535#include "FontPlatformData.h"
    3636#include "FontSelector.h"
    37 #include "GlyphPageTreeNode.h"
    3837#include "OpenTypeVerticalData.h"
    3938#include "WebKitFontFamilyNames.h"
     
    287286};
    288287
    289 typedef HashMap<FontPlatformData, pair<SimpleFontData*, unsigned>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache;
     288typedef HashMap<FontPlatformData, pair<RefPtr<SimpleFontData>, unsigned>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache;
    290289
    291290static FontDataCache* gFontDataCache = 0;
     
    298297const int cTargetInactiveFontData = 30;
    299298#endif
    300 static ListHashSet<const SimpleFontData*>* gInactiveFontData = 0;
    301 
    302 SimpleFontData* FontCache::getCachedFontData(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName, ShouldRetain shouldRetain)
     299static ListHashSet<RefPtr<SimpleFontData> >* gInactiveFontData = 0;
     300
     301PassRefPtr<SimpleFontData> FontCache::getCachedFontData(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName, ShouldRetain shouldRetain)
    303302{
    304303    FontPlatformData* platformData = getCachedFontPlatformData(fontDescription, family, checkingAlternateName);
     
    309308}
    310309
    311 SimpleFontData* FontCache::getCachedFontData(const FontPlatformData* platformData, ShouldRetain shouldRetain)
     310PassRefPtr<SimpleFontData> FontCache::getCachedFontData(const FontPlatformData* platformData, ShouldRetain shouldRetain)
    312311{
    313312    if (!platformData)
     
    321320    if (!gFontDataCache) {
    322321        gFontDataCache = new FontDataCache;
    323         gInactiveFontData = new ListHashSet<const SimpleFontData*>;
     322        gInactiveFontData = new ListHashSet<RefPtr<SimpleFontData> >;
    324323    }
    325324
    326325    FontDataCache::iterator result = gFontDataCache->find(*platformData);
    327326    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);
    329328        gFontDataCache->set(*platformData, newValue);
    330329        if (shouldRetain == DoNotRetain)
    331330            gInactiveFontData->add(newValue.first);
    332         return newValue.first;
     331        return newValue.first.release();
    333332    }
    334333
     
    351350SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont(const FontDescription& fontDescription)
    352351{
    353     return getLastResortFallbackFont(fontDescription, DoNotRetain);
     352    return getLastResortFallbackFont(fontDescription, DoNotRetain).leakRef();
    354353}
    355354
     
    364363    ASSERT(it->second.second);
    365364    if (!--it->second.second)
    366         gInactiveFontData->add(fontData);
     365        gInactiveFontData->add(it->second.first);
    367366}
    368367
     
    384383    isPurging = true;
    385384
    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();
    389388    for (int i = 0; i < count && it != end; ++it, ++i) {
    390         const SimpleFontData* fontData = *it.get();
     389        RefPtr<SimpleFontData>& fontData = *it.get();
    391390        gFontDataCache->remove(fontData->platformData());
    392391        // We should not delete SimpleFontData here because deletion can modify gInactiveFontData. See http://trac.webkit.org/changeset/44011
     
    402401    }
    403402
    404     size_t fontDataToDeleteCount = fontDataToDelete.size();
    405     for (size_t i = 0; i < fontDataToDeleteCount; ++i)
    406         delete fontDataToDelete[i];
     403    fontDataToDelete.clear();
    407404
    408405    if (gFontPlatformDataCache) {
     
    463460}
    464461
    465 const FontData* FontCache::getFontData(const Font& font, int& familyIndex, FontSelector* fontSelector)
    466 {
    467     FontData* result = 0;
     462PassRefPtr<FontData> FontCache::getFontData(const Font& font, int& familyIndex, FontSelector* fontSelector)
     463{
     464    RefPtr<FontData> result;
    468465
    469466    int startIndex = familyIndex;
     
    499496        if (fontSelector) {
    500497            // 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();
    503500        }
    504501
     
    506503        result = getLastResortFallbackFont(font.fontDescription());
    507504    }
    508     return result;
     505    return result.release();
    509506}
    510507
  • trunk/Source/WebCore/platform/graphics/FontCache.h

    r130105 r130160  
    3333#include <limits.h>
    3434#include <wtf/Forward.h>
     35#include <wtf/PassRefPtr.h>
     36#include <wtf/RefPtr.h>
    3537#include <wtf/Vector.h>
    3638#include <wtf/text/WTFString.h>
     
    6264    enum ShouldRetain { Retain, DoNotRetain };
    6365
    64     const FontData* getFontData(const Font&, int& familyIndex, FontSelector*);
     66    PassRefPtr<FontData> getFontData(const Font&, int& familyIndex, FontSelector*);
    6567    void releaseFontData(const SimpleFontData*);
    6668
    6769    // 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);
    6971
    7072    // Also implemented by the platform.
     
    8688    void getTraitsInFamily(const AtomicString&, Vector<unsigned>&);
    8789
    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);
    9092    SimpleFontData* getNonRetainedLastResortFallbackFont(const FontDescription&);
    9193
     
    101103
    102104#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);
    104106#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);
    106108#endif
    107109
     
    140142
    141143    // These methods are implemented by each platform.
    142     SimpleFontData* getSimilarFontPlatformData(const Font&);
     144    PassRefPtr<SimpleFontData> getSimilarFontPlatformData(const Font&);
    143145    FontPlatformData* createFontPlatformData(const FontDescription&, const AtomicString& family);
    144146
    145     SimpleFontData* getCachedFontData(const FontPlatformData*, ShouldRetain = Retain);
     147    PassRefPtr<SimpleFontData> getCachedFontData(const FontPlatformData*, ShouldRetain = Retain);
    146148
    147149    // Don't purge if this count is > 0;
  • trunk/Source/WebCore/platform/graphics/FontData.h

    r130105 r130160  
    3030#include <wtf/Forward.h>
    3131#include <wtf/Noncopyable.h>
     32#include <wtf/PassRefPtr.h>
     33#include <wtf/RefCounted.h>
    3234#include <wtf/unicode/Unicode.h>
    3335
     
    3638class SimpleFontData;
    3739
    38 class FontData {
     40class FontData : public RefCounted<FontData> {
    3941    WTF_MAKE_NONCOPYABLE(FontData); WTF_MAKE_FAST_ALLOCATED;
    4042public:
  • trunk/Source/WebCore/platform/graphics/FontFallbackList.cpp

    r130105 r130160  
    6767    unsigned numFonts = m_fontList.size();
    6868    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()));
    7272        }
    7373    }
     
    9292{
    9393    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.
    9595
    9696    // Make sure we're not passing in some crazy value here.
     
    105105    // |m_familyIndex| as it scans for the right font to make.
    106106    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());
    108108    if (result) {
    109         m_fontList.append(pair<const FontData*, bool>(result, result->isCustomFont()));
     109        m_fontList.append(result);
    110110        if (result->isLoading())
    111111            m_loadingCustomFonts = true;
    112112    }
    113     return result;
     113    return result.get();
    114114}
    115115
     
    118118    m_familyIndex = cAllFamiliesScanned;
    119119    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);
    122122}
    123123
  • trunk/Source/WebCore/platform/graphics/FontFallbackList.h

    r130105 r130160  
    8585    void releaseFontData();
    8686
    87     mutable Vector<pair<const FontData*, bool>, 1> m_fontList;
     87    mutable Vector<RefPtr<FontData>, 1> m_fontList;
    8888    mutable GlyphPages m_pages;
    8989    mutable GlyphPageTreeNode* m_pageZero;
  • trunk/Source/WebCore/platform/graphics/FontFastPath.cpp

    r130105 r130160  
    9898                    } else {
    9999                        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);
    102102                            GlyphPage* verticalRightPage = verticalRightNode->page();
    103103                            if (verticalRightPage) {
     
    112112                            }
    113113                        } 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);
    116116                            GlyphPage* uprightPage = uprightNode->page();
    117117                            if (uprightPage) {
     
    153153                    // The variantFontData function should not normally return 0.
    154154                    // 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);
    156156                    if (!variantFontData)
    157157                        return make_pair(data, page);
    158158
    159                     GlyphPageTreeNode* variantNode = GlyphPageTreeNode::getRootChild(variantFontData, pageNumber);
     159                    GlyphPageTreeNode* variantNode = GlyphPageTreeNode::getRootChild(variantFontData.get(), pageNumber);
    160160                    GlyphPage* variantPage = variantNode->page();
    161161                    if (variantPage) {
     
    199199        codeUnitsLength = 2;
    200200    }
    201     const SimpleFontData* characterFontData = fontCache()->getFontDataForCharacters(*this, codeUnits, codeUnitsLength);
     201    RefPtr<SimpleFontData> characterFontData = fontCache()->getFontDataForCharacters(*this, codeUnits, codeUnitsLength);
    202202    if (characterFontData) {
    203203        if (characterFontData->platformData().orientation() == Vertical && !characterFontData->hasVerticalGlyphs() && isCJKIdeographOrSymbol(c))
     
    208208    if (characterFontData) {
    209209        // Got the fallback glyph and font.
    210         GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterFontData, pageNumber)->page();
     210        GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterFontData.get(), pageNumber)->page();
    211211        GlyphData data = fallbackPage && fallbackPage->fontDataForCharacter(c) ? fallbackPage->glyphDataForCharacter(c) : characterFontData->missingGlyphData();
    212212        // Cache it so we don't have to do system fallback again next time.
  • trunk/Source/WebCore/platform/graphics/FontSelector.h

    r130105 r130160  
    2828
    2929#include <wtf/Forward.h>
     30#include <wtf/PassRefPtr.h>
    3031#include <wtf/RefCounted.h>
    3132
     
    3940public:
    4041    virtual ~FontSelector() { }
    41     virtual FontData* getFontData(const FontDescription&, const AtomicString& familyName) = 0;
     42    virtual PassRefPtr<FontData> getFontData(const FontDescription&, const AtomicString& familyName) = 0;
    4243
    4344    virtual void fontCacheInvalidated() { }
  • trunk/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp

    r130105 r130160  
    243243                            zeroFilled = true;
    244244                        }
    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());
    246246                        if (scratchPage) {
    247247                            ASSERT(to <=  static_cast<int>(GlyphPage::size));
  • trunk/Source/WebCore/platform/graphics/SegmentedFontData.cpp

    r130105 r130160  
    4242    for (Vector<FontDataRange>::const_iterator it = m_ranges.begin(); it != end; ++it) {
    4343        if (it->from() <= c && it->to() >= c)
    44             return it->fontData();
     44            return it->fontData().get();
    4545    }
    46     return m_ranges[0].fontData();
     46    return m_ranges[0].fontData().get();
    4747}
    4848
  • trunk/Source/WebCore/platform/graphics/SegmentedFontData.h

    r130105 r130160  
    3535
    3636struct FontDataRange {
    37     FontDataRange(UChar32 from, UChar32 to, const SimpleFontData* fontData)
     37    FontDataRange(UChar32 from, UChar32 to, PassRefPtr<SimpleFontData> fontData)
    3838        : m_from(from)
    3939        , m_to(to)
     
    4444    UChar32 from() const { return m_from; }
    4545    UChar32 to() const { return m_to; }
    46     const SimpleFontData* fontData() const { return m_fontData; }
     46    PassRefPtr<SimpleFontData> fontData() const { return m_fontData; }
    4747
    4848private:
    4949    UChar32 m_from;
    5050    UChar32 m_to;
    51     const SimpleFontData* m_fontData;
     51    RefPtr<SimpleFontData> m_fontData;
    5252};
    5353
    5454class SegmentedFontData : public FontData {
    5555public:
     56    static PassRefPtr<SegmentedFontData> create() { return adoptRef(new SegmentedFontData); }
     57
    5658    virtual ~SegmentedFontData();
    5759
     
    6567
    6668private:
     69    SegmentedFontData() { }
     70
    6771    virtual const SimpleFontData* fontDataForCharacter(UChar32) const;
    6872    virtual bool containsCharacters(const UChar*, int length) const;
  • trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp

    r130105 r130160  
    171171}
    172172
    173 SimpleFontData* SimpleFontData::verticalRightOrientationFontData() const
     173PassRefPtr<SimpleFontData> SimpleFontData::verticalRightOrientationFontData() const
    174174{
    175175    if (!m_derivedFontData)
     
    178178        FontPlatformData verticalRightPlatformData(m_platformData);
    179179        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() const
     180        m_derivedFontData->verticalRightOrientation = create(verticalRightPlatformData, isCustomFont(), false, true);
     181    }
     182    return m_derivedFontData->verticalRightOrientation;
     183}
     184
     185PassRefPtr<SimpleFontData> SimpleFontData::uprightOrientationFontData() const
    186186{
    187187    if (!m_derivedFontData)
    188188        m_derivedFontData = DerivedFontData::create(isCustomFont());
    189189    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() const
     190        m_derivedFontData->uprightOrientation = create(m_platformData, isCustomFont(), false, true);
     191    return m_derivedFontData->uprightOrientation;
     192}
     193
     194PassRefPtr<SimpleFontData> SimpleFontData::brokenIdeographFontData() const
    195195{
    196196    if (!m_derivedFontData)
    197197        m_derivedFontData = DerivedFontData::create(isCustomFont());
    198198    if (!m_derivedFontData->brokenIdeograph) {
    199         m_derivedFontData->brokenIdeograph = adoptPtr(new SimpleFontData(m_platformData, isCustomFont(), false));
     199        m_derivedFontData->brokenIdeograph = create(m_platformData, isCustomFont(), false);
    200200        m_derivedFontData->brokenIdeograph->m_isBrokenIdeographFallback = true;
    201201    }
    202     return m_derivedFontData->brokenIdeograph.get();
     202    return m_derivedFontData->brokenIdeograph;
    203203}
    204204
  • trunk/Source/WebCore/platform/graphics/SimpleFontData.h

    r130105 r130160  
    8080
    8181    // 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    }
    8386
    8487    // 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    }
    8692
    8793    virtual ~SimpleFontData();
     
    9298#endif
    9399
    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) const
     100    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
    99105    {
    100106        switch (variant) {
     
    113119    }
    114120
    115     SimpleFontData* verticalRightOrientationFontData() const;
    116     SimpleFontData* uprightOrientationFontData() const;
     121    PassRefPtr<SimpleFontData> verticalRightOrientationFontData() const;
     122    PassRefPtr<SimpleFontData> uprightOrientationFontData() const;
    117123
    118124    bool hasVerticalGlyphs() const { return m_hasVerticalGlyphs; }
     
    202208
    203209private:
     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
    204214    void platformInit();
    205215    void platformGlyphInit();
     
    211221    void commonInit();
    212222
    213     PassOwnPtr<SimpleFontData> createScaledFontData(const FontDescription&, float scaleFactor) const;
     223    PassRefPtr<SimpleFontData> createScaledFontData(const FontDescription&, float scaleFactor) const;
    214224
    215225#if (PLATFORM(WIN) && !OS(WINCE)) \
     
    255265
    256266        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;
    262272#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
    263273        mutable RetainPtr<CFMutableDictionaryRef> compositeFontReferences;
  • trunk/Source/WebCore/platform/graphics/chromium/FontCacheAndroid.cpp

    r130105 r130160  
    9898}
    9999
    100 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
     100PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
    101101{
    102102    // FIXME: We do not use fontconfig on Android, so use simple logic for now.
     
    106106}
    107107
    108 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
     108PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
    109109{
    110110    return 0;
    111111}
    112112
    113 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)
     113PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)
    114114{
    115115    DEFINE_STATIC_LOCAL(const AtomicString, serif, ("Serif"));
  • trunk/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp

    r130105 r130160  
    319319
    320320// 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);
     321PassRefPtr<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);
    324324    if (fontData)
    325325        memcpy(outFontFamilyName, font.lfFaceName, sizeof(font.lfFaceName));
    326     return fontData;
     326    return fontData.release();
    327327}
    328328
     
    407407    FontCache::ShouldRetain m_shouldRetain;
    408408    wchar_t* m_fontName;
    409     SimpleFontData* m_fontData;
     409    RefPtr<SimpleFontData> m_fontData;
    410410};
    411411
     
    424424// Given the desired base font, this will create a SimpleFontData for a specific
    425425// 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)
     426PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
    427427{
    428428    // FIXME: Consider passing fontDescription.dominantScript()
     
    509509}
    510510
    511 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
     511PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
    512512{
    513513    return 0;
    514514}
    515515
    516 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)
     516PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)
    517517{
    518518    FontDescription::GenericFamilyType generic = description.genericFamily();
     
    531531        fontStr = courierStr;
    532532
    533     SimpleFontData* simpleFont = getCachedFontData(description, fontStr, false, shouldRetain);
     533    RefPtr<SimpleFontData> simpleFont = getCachedFontData(description, fontStr, false, shouldRetain);
    534534    if (simpleFont)
    535         return simpleFont;
     535        return simpleFont.release();
    536536
    537537    // Fall back to system fonts as Win Safari does because this function must
     
    547547        GetObject(defaultGUIFont, sizeof(defaultGUILogFont), &defaultGUILogFont);
    548548        if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, defaultGUILogFont, fallbackFontName))
    549             return simpleFont;
     549            return simpleFont.release();
    550550    }
    551551
     
    555555    if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nonClientMetrics), &nonClientMetrics, 0)) {
    556556        if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfMessageFont, fallbackFontName))
    557             return simpleFont;
     557            return simpleFont.release();
    558558        if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfMenuFont, fallbackFontName))
    559             return simpleFont;
     559            return simpleFont.release();
    560560        if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfStatusFont, fallbackFontName))
    561             return simpleFont;
     561            return simpleFont.release();
    562562        if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfCaptionFont, fallbackFontName))
    563             return simpleFont;
     563            return simpleFont.release();
    564564        if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfSmCaptionFont, fallbackFontName))
    565             return simpleFont;
     565            return simpleFont.release();
    566566    }
    567567
     
    577577
    578578        if (procData.m_fontData)
    579             return procData.m_fontData;
     579            return procData.m_fontData.release();
    580580    }
    581581
  • trunk/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp

    r130105 r130160  
    110110}
    111111
    112 PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
     112PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
    113113{
    114114    LOGFONT winFont;
     
    117117    winFont.lfHeight = -lroundf(scaledSize);
    118118    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) const
     119    return SimpleFontData::create(FontPlatformData(hfont, scaledSize, m_platformData.orientation()), isCustomFont(), false);
     120}
     121
     122PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
    123123{
    124124    if (!m_derivedFontData)
     
    127127        m_derivedFontData->smallCaps = createScaledFontData(fontDescription, .7);
    128128
    129     return m_derivedFontData->smallCaps.get();
    130 }
    131 
    132 SimpleFontData* SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
     129    return m_derivedFontData->smallCaps;
     130}
     131
     132PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
    133133{
    134134    if (!m_derivedFontData)
     
    137137        m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5);
    138138
    139     return m_derivedFontData->emphasisMark.get();
     139    return m_derivedFontData->emphasisMark;
    140140}
    141141
  • trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp

    r130105 r130160  
    8282}
    8383
    84 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
     84PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
    8585{
    8686    RefPtr<FcPattern> pattern = adoptRef(createFontConfigPatternForCharacters(characters, length));
     
    101101}
    102102
    103 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font&)
     103PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font&)
    104104{
    105105    return 0;
    106106}
    107107
    108 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
     108PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
    109109{
    110110    // We want to return a fallback font here, otherwise the logic preventing FontConfig
  • trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp

    r130105 r130160  
    8888}
    8989
    90 PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
     90PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
    9191{
    9292    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()),
    9494                                                        scaleFactor * fontDescription.computedSize(),
    9595                                                        m_platformData.syntheticBold(),
    96                                                         m_platformData.syntheticOblique()),
    97                                        isCustomFont(), false));
     96                                                        m_platformData.syntheticOblique()), isCustomFont(), false);
    9897}
    9998
    100 SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
     99PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
    101100{
    102101    if (!m_derivedFontData)
     
    106105        m_derivedFontData->smallCaps = createScaledFontData(fontDescription, .7);
    107106
    108     return m_derivedFontData->smallCaps.get();
     107    return m_derivedFontData->smallCaps;
    109108}
    110109
    111 SimpleFontData* SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
     110PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
    112111{
    113112    if (!m_derivedFontData)
     
    116115        m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5);
    117116
    118     return m_derivedFontData->emphasisMark.get();
     117    return m_derivedFontData->emphasisMark;
    119118}
    120119
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm

    r130105 r130160  
    283283                        continue;
    284284                    }
    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();
    286286#if !PLATFORM(WX)
    287287                    // Core Text may have used a font that is not known to NSFontManager. In that case, fall back on
     
    289289                    if (!runFontData) {
    290290                        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();
    292292                    }
    293293#else
  • trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm

    r130105 r130160  
    100100}
    101101
    102 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
     102PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
    103103{
    104104    UChar32 character;
     
    173173}
    174174
    175 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
     175PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
    176176{
    177177    // Attempt to find an appropriate font using a match based on
    178178    // the presence of keywords in the the requested names.  For example, we'll
    179179    // match any name that contains "Arabic" to Geeza Pro.
    180     SimpleFontData* simpleFontData = 0;
     180    RefPtr<SimpleFontData> simpleFontData;
    181181    const FontFamily* currFamily = &font.fontDescription().family();
    182182    while (currFamily && !simpleFontData) {
     
    191191    }
    192192
    193     return simpleFontData;
    194 }
    195 
    196 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
     193    return simpleFontData.release();
     194}
     195
     196PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
    197197{
    198198    DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times"));
     
    200200    // FIXME: Would be even better to somehow get the user's default font here.  For now we'll pick
    201201    // 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);
    203203    if (simpleFontData)
    204         return simpleFontData;
     204        return simpleFontData.release();
    205205
    206206    // The Times fallback will almost always work, but in the highly unusual case where
  • trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp

    r130105 r130160  
    190190                if (isCJKIdeographOrSymbol(baseCharacter) && !simpleFontData->hasVerticalGlyphs()) {
    191191                    variant = BrokenIdeographVariant;
    192                     simpleFontData = simpleFontData->brokenIdeographFontData();
     192                    simpleFontData = simpleFontData->brokenIdeographFontData().get();
    193193                } else if (m_fontDescription.textOrientation() == TextOrientationVerticalRight) {
    194                     SimpleFontData* verticalRightFontData = simpleFontData->verticalRightOrientationFontData();
     194                    SimpleFontData* verticalRightFontData = simpleFontData->verticalRightOrientationFontData().get();
    195195                    Glyph verticalRightGlyph = verticalRightFontData->glyphForCharacter(baseCharacter);
    196196                    if (verticalRightGlyph == baseCharacterGlyphData.glyph)
    197197                        simpleFontData = verticalRightFontData;
    198198                } else {
    199                     SimpleFontData* uprightFontData = simpleFontData->uprightOrientationFontData();
     199                    SimpleFontData* uprightFontData = simpleFontData->uprightOrientationFontData().get();
    200200                    Glyph uprightGlyph = uprightFontData->glyphForCharacter(baseCharacter);
    201201                    if (uprightGlyph != baseCharacterGlyphData.glyph)
     
    204204            }
    205205        } else {
    206             if (const SimpleFontData* variantFontData = simpleFontData->variantFontData(m_fontDescription, variant))
     206            if (const SimpleFontData* variantFontData = simpleFontData->variantFontData(m_fontDescription, variant).get())
    207207                simpleFontData = variantFontData;
    208208        }
  • trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm

    r130105 r130160  
    309309        // These come from the cache.
    310310        if (m_derivedFontData->smallCaps)
    311             fontCache()->releaseFontData(m_derivedFontData->smallCaps.leakPtr());
     311            fontCache()->releaseFontData(m_derivedFontData->smallCaps.get());
    312312
    313313        if (m_derivedFontData->emphasisMark)
    314             fontCache()->releaseFontData(m_derivedFontData->emphasisMark.leakPtr());
    315     }
    316 }
    317 
    318 PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
     314            fontCache()->releaseFontData(m_derivedFontData->emphasisMark.get());
     315    }
     316}
     317
     318PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
    319319{
    320320    if (isCustomFont()) {
    321321        FontPlatformData scaledFontData(m_platformData);
    322322        scaledFontData.m_size = scaledFontData.m_size * scaleFactor;
    323         return adoptPtr(new SimpleFontData(scaledFontData, true, false));
     323        return SimpleFontData::create(scaledFontData, true, false);
    324324    }
    325325
     
    346346
    347347        // SimpleFontData::platformDestroy() takes care of not deleting the cached font data twice.
    348         return adoptPtr(fontCache()->getCachedFontData(&scaledFontData));
     348        return fontCache()->getCachedFontData(&scaledFontData);
    349349    }
    350350    END_BLOCK_OBJC_EXCEPTIONS;
    351351
    352     return nullptr;
    353 }
    354 
    355 SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
     352    return 0;
     353}
     354
     355PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
    356356{
    357357    if (!m_derivedFontData)
     
    360360        m_derivedFontData->smallCaps = createScaledFontData(fontDescription, smallCapsFontSizeMultiplier);
    361361
    362     return m_derivedFontData->smallCaps.get();
    363 }
    364 
    365 SimpleFontData* SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
     362    return m_derivedFontData->smallCaps;
     363}
     364
     365PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
    366366{
    367367    if (!m_derivedFontData)
     
    370370        m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5f);
    371371
    372     return m_derivedFontData->emphasisMark.get();
     372    return m_derivedFontData->emphasisMark;
    373373}
    374374
  • trunk/Source/WebCore/platform/graphics/pango/FontCachePango.cpp

    r130105 r130160  
    3636}
    3737
    38 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
     38PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
    3939{
    4040    return 0;
    4141}
    4242
    43 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
     43PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
    4444{
    4545    return 0;
    4646}
    4747
    48 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
     48PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
    4949{
    5050    // FIXME: Would be even better to somehow get the user's default font here.
  • trunk/Source/WebCore/platform/graphics/pango/SimpleFontDataPango.cpp

    r130105 r130160  
    8585}
    8686
    87 PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
     87PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
    8888{
    8989    FontDescription desc = FontDescription(fontDescription);
    9090    desc.setSpecifiedSize(scaleFactor * fontDescription.computedSize());
    9191    FontPlatformData platformData(desc, desc.family().family());
    92     return adoptPtr(new SimpleFontData(platformData));
     92    return SimpleFontData::create(platformData);
    9393}
    9494
    95 SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
     95PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
    9696{
    9797    if (!m_derivedFontData)
     
    100100        m_derivedFontData->smallCaps = createScaledFontData(fontDescription, .7);
    101101
    102     return m_derivedFontData->smallCaps.get();
     102    return m_derivedFontData->smallCaps;
    103103}
    104104
    105 SimpleFontData* SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
     105PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
    106106{
    107107    if (!m_derivedFontData)
     
    110110        m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5);
    111111
    112     return m_derivedFontData->emphasisMark.get();
     112    return m_derivedFontData->emphasisMark;
    113113}
    114114
  • trunk/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp

    r130105 r130160  
    6464}
    6565
    66 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
     66PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
    6767{
    6868    QString qstring = QString::fromRawData(reinterpret_cast<const QChar*>(characters), length);
     
    7474}
    7575
    76 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
     76PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
    7777{
    7878    return 0;
    7979}
    8080
    81 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
     81PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
    8282{
    8383    const AtomicString fallbackFamily = QFont(fontDescription.family().family()).lastResortFamily();
  • trunk/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp

    r130105 r130160  
    6262}
    6363
    64 PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
     64PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
    6565{
    6666    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);
    6868}
    6969
    70 SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
     70PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
    7171{
    7272    if (!m_derivedFontData)
     
    7575        m_derivedFontData->smallCaps = createScaledFontData(fontDescription, smallCapsFraction);
    7676
    77     return m_derivedFontData->smallCaps.get();
     77    return m_derivedFontData->smallCaps;
    7878}
    7979
    80 SimpleFontData* SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
     80PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
    8181{
    8282    if (!m_derivedFontData)
     
    8585        m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, emphasisMarkFraction);
    8686
    87     return m_derivedFontData->emphasisMark.get();
     87    return m_derivedFontData->emphasisMark;
    8888}
    8989
  • trunk/Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp

    r130105 r130160  
    5252}
    5353
    54 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font,
    55                                                           const UChar* characters,
    56                                                           int length)
     54PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
    5755{
    5856    icu::Locale locale = icu::Locale::getDefault();
     
    9189}
    9290
    93 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
     91PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
    9492{
    9593    return 0;
    9694}
    9795
    98 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)
     96PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)
    9997{
    10098    DEFINE_STATIC_LOCAL(const AtomicString, sansStr, ("Sans"));
  • trunk/Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp

    r130105 r130160  
    171171}
    172172
    173 PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
     173PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
    174174{
    175175    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) const
     176    return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize), isCustomFont(), false);
     177}
     178
     179PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
    180180{
    181181    if (!m_derivedFontData)
     
    184184        m_derivedFontData->smallCaps = createScaledFontData(fontDescription, smallCapsFraction);
    185185
    186     return m_derivedFontData->smallCaps.get();
    187 }
    188 
    189 SimpleFontData* SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
     186    return m_derivedFontData->smallCaps;
     187}
     188
     189PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
    190190{
    191191    if (!m_derivedFontData)
     
    194194        m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, emphasisMarkFraction);
    195195
    196     return m_derivedFontData->emphasisMark.get();
     196    return m_derivedFontData->emphasisMark;
    197197}
    198198
  • trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp

    r130105 r130160  
    187187}
    188188
    189 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
     189PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
    190190{
    191191    UChar character = characters[0];
    192     SimpleFontData* fontData = 0;
     192    RefPtr<SimpleFontData> fontData;
    193193    HWndDC hdc(0);
    194194    HFONT primaryFont = font.primaryFont()->fontDataForCharacter(character)->platformData().hfont();
     
    294294    }
    295295
    296     return fontData;
    297 }
    298 
    299 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
     296    return fontData.release();
     297}
     298
     299PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
    300300{
    301301    return 0;
    302302}
    303303
    304 SimpleFontData* FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, ShouldRetain shouldRetain, const LOGFONT& font, AtomicString& outFontFamilyName)
     304PassRefPtr<SimpleFontData> FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, ShouldRetain shouldRetain, const LOGFONT& font, AtomicString& outFontFamilyName)
    305305{
    306306    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);
    308308    if (fontData)
    309309        outFontFamilyName = familyName;
    310     return fontData;
    311 }
    312 
    313 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
     310    return fontData.release();
     311}
     312
     313PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
    314314{
    315315    DEFINE_STATIC_LOCAL(AtomicString, fallbackFontName, ());
     
    330330        AtomicString("Arial")
    331331    };
    332     SimpleFontData* simpleFont;
     332    RefPtr<SimpleFontData> simpleFont;
    333333    for (size_t i = 0; i < WTF_ARRAY_LENGTH(fallbackFonts); ++i) {
    334334        if (simpleFont = getCachedFontData(fontDescription, fallbackFonts[i], false, shouldRetain)) {
    335335            fallbackFontName = fallbackFonts[i];
    336             return simpleFont;
     336            return simpleFont.release();
    337337        }
    338338    }
     
    343343        GetObject(defaultGUIFont, sizeof(defaultGUILogFont), &defaultGUILogFont);
    344344        if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, defaultGUILogFont, fallbackFontName))
    345             return simpleFont;
     345            return simpleFont.release();
    346346    }
    347347
     
    351351    if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nonClientMetrics), &nonClientMetrics, 0)) {
    352352        if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfMessageFont, fallbackFontName))
    353             return simpleFont;
     353            return simpleFont.release();
    354354        if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfMenuFont, fallbackFontName))
    355             return simpleFont;
     355            return simpleFont.release();
    356356        if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfStatusFont, fallbackFontName))
    357             return simpleFont;
     357            return simpleFont.release();
    358358        if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfCaptionFont, fallbackFontName))
    359             return simpleFont;
     359            return simpleFont.release();
    360360        if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfSmCaptionFont, fallbackFontName))
    361             return simpleFont;
     361            return simpleFont.release();
    362362    }
    363363   
  • trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp

    r130105 r130160  
    133133}
    134134
    135 PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
     135PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
    136136{
    137137    float scaledSize = scaleFactor * m_platformData.size();
     
    139139        FontPlatformData scaledFont(m_platformData);
    140140        scaledFont.setSize(scaledSize);
    141         return adoptPtr(new SimpleFontData(scaledFont, true, false));
     141        return SimpleFontData::create(scaledFont, true, false);
    142142    }
    143143
     
    146146    winfont.lfHeight = -lroundf(scaledSize * (m_platformData.useGDI() ? 1 : 32));
    147147    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) const
     148    return SimpleFontData::create(FontPlatformData(hfont, scaledSize, m_platformData.syntheticBold(), m_platformData.syntheticOblique(), m_platformData.useGDI()), isCustomFont(), false);
     149}
     150
     151PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
    152152{
    153153    if (!m_derivedFontData)
     
    156156        m_derivedFontData->smallCaps = createScaledFontData(fontDescription, cSmallCapsFontSizeMultiplier);
    157157
    158     return m_derivedFontData->smallCaps.get();
    159 }
    160 
    161 SimpleFontData* SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
     158    return m_derivedFontData->smallCaps;
     159}
     160
     161PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
    162162{
    163163    if (!m_derivedFontData)
     
    166166        m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5);
    167167
    168     return m_derivedFontData->emphasisMark.get();
     168    return m_derivedFontData->emphasisMark;
    169169}
    170170
  • trunk/Source/WebCore/platform/graphics/wince/FontCacheWinCE.cpp

    r130105 r130160  
    226226}
    227227
    228 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
     228PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
    229229{
    230230    String familyName;
     
    236236
    237237#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    {
    242243        HGDIOBJ oldFont = GetCurrentObject(g_screenDC, OBJ_FONT);
    243244        HFONT hfont = 0;
     
    268269                    // returned by MLang, so the font might not contain the character.
    269270#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                    {
    274276                        SelectObject(g_screenDC, oldFont);
    275277                        langFontLink->ReleaseFont(hfont);
     
    309311        FontPlatformData* result = getCachedFontPlatformData(fontDescription, familyName);
    310312        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();
    313315        }
    314316    }
     
    317319}
    318320
    319 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
     321PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font&)
    320322{
    321323    return 0;
    322324}
    323325
    324 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDesc, ShouldRetain shouldRetain)
     326PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDesc, ShouldRetain shouldRetain)
    325327{
    326328    // 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  
    6464}
    6565
    66 PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
     66PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
    6767{
    6868    FontDescription fontDesc(fontDescription);
     
    7272    FontPlatformData* result = fontCache()->getCachedFontPlatformData(fontDesc, m_platformData.family());
    7373    if (!result)
    74         return nullptr;
    75     return adoptPtr(new SimpleFontData(*result));
     74        return 0;
     75    return SimpleFontData::create(*result);
    7676}
    7777
    78 SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
     78PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
    7979{
    8080    if (!m_derivedFontData)
     
    8383        m_derivedFontData->smallCaps = createScaledFontData(fontDescription, .7);
    8484
    85     return m_derivedFontData->smallCaps.get();
     85    return m_derivedFontData->smallCaps;
    8686}
    8787
    88 SimpleFontData* SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
     88PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
    8989{
    9090    if (!m_derivedFontData)
     
    9393        m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5);
    9494
    95     return m_derivedFontData->emphasisMark.get();
     95    return m_derivedFontData->emphasisMark;
    9696}
    9797
  • trunk/Source/WebCore/platform/graphics/wx/FontCacheWx.cpp

    r130105 r130160  
    4444}
    4545
    46 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
     46PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
    4747{
    48     SimpleFontData* fontData = 0;
     48    RefPtr<SimpleFontData> fontData = 0;
    4949    fontData = getCachedFontData(font.fontDescription(), font.family().family(), false, DoNotRetain);
    5050    if (!fontData->containsCharacters(characters, length))
     
    5454
    5555    ASSERT(fontData);
    56     return fontData;
     56    return fontData.release();
    5757}
    5858
    59 SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
     59PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
    6060{
    61     SimpleFontData* simpleFontData = 0;
     61    RefPtr<SimpleFontData> simpleFontData = 0;
    6262#if OS(DARWIN)
    6363    // Attempt to find an appropriate font using a match based on
     
    7979        simpleFontData = getCachedFontData(font.fontDescription(), font.family().family());
    8080
    81     return simpleFontData;
     81    return simpleFontData.release();
    8282}
    8383
    84 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
     84PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
    8585{
    8686    // FIXME: Would be even better to somehow get the user's default font here.  For now we'll pick
    8787    // the default that the user would get without changing any prefs.
    88     SimpleFontData* fallback = 0;
     88    RefPtr<SimpleFontData> fallback = 0;
    8989#if OS(WINDOWS)
    9090    static AtomicString fallbackName("Arial Unicode MS");
     
    9595    ASSERT(fallback);
    9696   
    97     return fallback;
     97    return fallback.release();
    9898}
    9999
  • trunk/Source/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp

    r130105 r130160  
    9191}
    9292
    93 PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
     93PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
    9494{
    9595    FontDescription desc = FontDescription(fontDescription);
    9696    desc.setSpecifiedSize(scaleFactor * fontDescription.computedSize());
    9797    FontPlatformData platformData(desc, desc.family().family());
    98     return adoptPtr(new SimpleFontData(platformData, isCustomFont(), false));
    99 }
    100 
    101 SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
     98    return SimpleFontData::create(platformData, isCustomFont(), false);
     99}
     100
     101PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
    102102{
    103103    if (!m_derivedFontData)
     
    106106        m_derivedFontData->smallCaps = createScaledFontData(fontDescription, .7);
    107107
    108     return m_derivedFontData->smallCaps.get();
    109 }
    110 
    111 SimpleFontData* SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
     108    return m_derivedFontData->smallCaps;
     109}
     110
     111PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescription& fontDescription) const
    112112{
    113113    if (!m_derivedFontData)
     
    116116        m_derivedFontData->emphasisMark = createScaledFontData(fontDescription, .5);
    117117
    118     return m_derivedFontData->emphasisMark.get();
     118    return m_derivedFontData->emphasisMark;
    119119}
    120120
Note: See TracChangeset for help on using the changeset viewer.