diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-07-31 11:52:57 +1000 |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-07-31 11:52:57 +1000 |
commit | aa9cf406d62004519ad54596e1c391f9a6439210 (patch) | |
tree | dd562b9c296981f2761b76623911be8496c7af84 /src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp | |
parent | 987aec28b950e1c9817a20a9dd71afc071cd93ea (diff) | |
parent | 56b6a5924008ab5cdbae36e9662eddba923acd5e (diff) |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp')
-rw-r--r-- | src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp index 29e77189f..c29fd56f3 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp @@ -25,6 +25,7 @@ #include "FontFallbackList.h" #include "Font.h" +#include "FontCache.h" #include "SegmentedFontData.h" #include <QDebug> @@ -58,9 +59,15 @@ void FontFallbackList::invalidate(WTF::PassRefPtr<WebCore::FontSelector> fontSel void FontFallbackList::releaseFontData() { - if (m_fontList.size()) - delete m_fontList[0].first; - m_fontList.clear(); + unsigned numFonts = m_fontList.size(); + for (unsigned i = 0; i < numFonts; ++i) { + if (m_fontList[i].second) + delete m_fontList[i].first; + else { + ASSERT(!m_fontList[i].first->isSegmented()); + fontCache()->releaseFontData(static_cast<const SimpleFontData*>(m_fontList[i].first)); + } + } } void FontFallbackList::determinePitch(const WebCore::Font* font) const @@ -83,6 +90,14 @@ const FontData* FontFallbackList::fontDataAt(const WebCore::Font* _font, unsigne if (index != 0) return 0; + // Search for the WebCore font that is already in the list + for (int i = m_fontList.size() - 1; i >= 0; --i) { + pair<const FontData*, bool> item = m_fontList[i]; + // item.second means that the item was created locally or not + if (!item.second) + return item.first; + } + // Use the FontSelector to get a WebCore font and then fallback to Qt const FontDescription& description = _font->fontDescription(); const FontFamily* family = &description.family(); @@ -92,6 +107,10 @@ const FontData* FontFallbackList::fontDataAt(const WebCore::Font* _font, unsigne if (data) { if (data->isLoading()) m_loadingCustomFonts = true; + if (!data->isCustomFont()) { + // Custom fonts can be freed anytime so we must not hold them + m_fontList.append(pair<const FontData*, bool>(data, false)); + } return data; } } @@ -101,8 +120,8 @@ const FontData* FontFallbackList::fontDataAt(const WebCore::Font* _font, unsigne if (m_fontList.size()) return m_fontList[0].first; - const FontData* result = new SimpleFontData(FontPlatformData(description), _font->wordSpacing(), _font->letterSpacing()); - m_fontList.append(pair<const FontData*, bool>(result, result->isCustomFont())); + const FontData* result = new SimpleFontData(FontPlatformData(description, _font->wordSpacing(), _font->letterSpacing()), true); + m_fontList.append(pair<const FontData*, bool>(result, true)); return result; } |