diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-10-16 14:56:46 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-10-16 14:57:30 +0200 |
commit | b297e0fa5c217c9467033b7c8b46891a52870120 (patch) | |
tree | 43fc14689295e9e64f2719d05aad94e3049f6cd7 /Source/WebCore/css/CSSFontFaceSource.cpp | |
parent | 69d517dbfa69903d8593cc1737f0474b21e3251e (diff) | |
download | qtwebkit-b297e0fa5c217c9467033b7c8b46891a52870120.tar.gz |
Revert "Imported WebKit commit 0dc6cd75e1d4836eaffbb520be96fac4847cc9d2 (http://svn.webkit.org/repository/webkit/trunk@131300)"
This reverts commit 5466563f4b5b6b86523e3f89bb7f77e5b5270c78.
Caused OOM issues on some CI machines :(
Diffstat (limited to 'Source/WebCore/css/CSSFontFaceSource.cpp')
-rw-r--r-- | Source/WebCore/css/CSSFontFaceSource.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/Source/WebCore/css/CSSFontFaceSource.cpp b/Source/WebCore/css/CSSFontFaceSource.cpp index 5e5289f6d..dd904d37f 100644 --- a/Source/WebCore/css/CSSFontFaceSource.cpp +++ b/Source/WebCore/css/CSSFontFaceSource.cpp @@ -33,6 +33,7 @@ #include "Document.h" #include "FontCache.h" #include "FontDescription.h" +#include "GlyphPageTreeNode.h" #include "SimpleFontData.h" #if ENABLE(SVG_FONTS) @@ -94,7 +95,7 @@ void CSSFontFaceSource::fontLoaded(CachedFont*) m_face->fontLoaded(this); } -PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector) +SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector) { // If the font hasn't loaded or an error occurred, then we've got nothing. if (!isValid()) @@ -113,9 +114,11 @@ PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& unsigned hashKey = (fontDescription.computedPixelSize() + 1) << 6 | fontDescription.widthVariant() << 4 | (fontDescription.textOrientation() == TextOrientationUpright ? 8 : 0) | (fontDescription.orientation() == Vertical ? 4 : 0) | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0); - RefPtr<SimpleFontData>& fontData = m_fontDataTable.add(hashKey, 0).iterator->value; - if (fontData) - return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable. + SimpleFontData*& cachedData = m_fontDataTable.add(hashKey, 0).iterator->second; + if (cachedData) + return cachedData; + + OwnPtr<SimpleFontData> fontData; // If we are still loading, then we let the system pick a font. if (isLoaded()) { @@ -154,7 +157,7 @@ PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& m_svgFontFaceElement = fontFaceElement; } - fontData = SimpleFontData::create(SVGFontData::create(fontFaceElement), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic); + fontData = adoptPtr(new SimpleFontData(SVGFontData::create(fontFaceElement), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic)); } } else #endif @@ -163,14 +166,14 @@ PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& if (!m_font->ensureCustomFontData()) return 0; - fontData = SimpleFontData::create(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, - fontDescription.orientation(), fontDescription.textOrientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false); + fontData = adoptPtr(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.orientation(), + fontDescription.textOrientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false)); } } else { #if ENABLE(SVG_FONTS) // In-Document SVG Fonts if (m_svgFontFaceElement) - fontData = SimpleFontData::create(SVGFontData::create(m_svgFontFaceElement.get()), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic); + fontData = adoptPtr(new SimpleFontData(SVGFontData::create(m_svgFontFaceElement.get()), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic)); #endif } } else { @@ -181,10 +184,15 @@ PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& // This temporary font is not retained and should not be returned. FontCachePurgePreventer fontCachePurgePreventer; SimpleFontData* temporaryFont = fontCache()->getNonRetainedLastResortFallbackFont(fontDescription); - fontData = SimpleFontData::create(temporaryFont->platformData(), true, true); + fontData = adoptPtr(new SimpleFontData(temporaryFont->platformData(), true, true)); + } + + if (Document* document = fontSelector->document()) { + cachedData = fontData.get(); + document->registerCustomFont(fontData.release()); } - return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable. + return cachedData; } #if ENABLE(SVG_FONTS) |