diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-24 16:36:50 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-24 16:36:50 +0100 |
commit | ad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (patch) | |
tree | b34b0daceb7c8e7fdde4b4ec43650ab7caadb0a9 /Source/WebCore/css/CSSValuePool.cpp | |
parent | 03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (diff) | |
download | qtwebkit-ad0d549d4cc13433f77c1ac8f0ab379c83d93f28.tar.gz |
Imported WebKit commit bb52bf3c0119e8a128cd93afe5572413a8617de9 (http://svn.webkit.org/repository/webkit/trunk@108790)
Diffstat (limited to 'Source/WebCore/css/CSSValuePool.cpp')
-rw-r--r-- | Source/WebCore/css/CSSValuePool.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Source/WebCore/css/CSSValuePool.cpp b/Source/WebCore/css/CSSValuePool.cpp index 3d8893ea8..c46c7047c 100644 --- a/Source/WebCore/css/CSSValuePool.cpp +++ b/Source/WebCore/css/CSSValuePool.cpp @@ -25,7 +25,10 @@ #include "config.h" #include "CSSValuePool.h" + +#include "CSSParser.h" #include "CSSValueKeywords.h" +#include "CSSValueList.h" namespace WebCore { @@ -120,4 +123,25 @@ PassRefPtr<CSSPrimitiveValue> CSSValuePool::createValue(double value, CSSPrimiti return entry.first->second; } +PassRefPtr<CSSPrimitiveValue> CSSValuePool::createFontFamilyValue(const String& familyName) +{ + RefPtr<CSSPrimitiveValue>& value = m_fontFamilyValueCache.add(familyName, 0).first->second; + if (!value) + value = CSSPrimitiveValue::create(familyName, CSSPrimitiveValue::CSS_STRING); + return value; +} + +PassRefPtr<CSSValueList> CSSValuePool::createFontFaceValue(const AtomicString& string, CSSStyleSheet* contextStyleSheet) +{ + // Just wipe out the cache and start rebuilding if it gets too big. + const int maximumFontFaceCacheSize = 128; + if (m_fontFaceValueCache.size() > maximumFontFaceCacheSize) + m_fontFaceValueCache.clear(); + + RefPtr<CSSValueList>& value = m_fontFaceValueCache.add(string, 0).first->second; + if (!value) + value = CSSParser::parseFontFaceValue(string, contextStyleSheet); + return value; +} + } |