diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/css/CSSValuePool.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/css/CSSValuePool.h')
-rw-r--r-- | Source/WebCore/css/CSSValuePool.h | 83 |
1 files changed, 46 insertions, 37 deletions
diff --git a/Source/WebCore/css/CSSValuePool.h b/Source/WebCore/css/CSSValuePool.h index 44b00a9c7..c5d2d8bda 100644 --- a/Source/WebCore/css/CSSValuePool.h +++ b/Source/WebCore/css/CSSValuePool.h @@ -23,15 +23,20 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef CSSValuePool_h -#define CSSValuePool_h +#pragma once +#include "CSSFontFamily.h" #include "CSSInheritedValue.h" #include "CSSInitialValue.h" #include "CSSPrimitiveValue.h" #include "CSSPropertyNames.h" +#include "CSSRevertValue.h" +#include "CSSUnsetValue.h" #include "CSSValueKeywords.h" +#include "ColorHash.h" +#include <utility> #include <wtf/HashMap.h> +#include <wtf/NeverDestroyed.h> #include <wtf/RefPtr.h> #include <wtf/text/AtomicStringHash.h> @@ -39,57 +44,61 @@ namespace WebCore { class CSSValueList; +enum class FromSystemFontID { No, Yes }; + class CSSValuePool { WTF_MAKE_FAST_ALLOCATED; public: - PassRefPtr<CSSValueList> createFontFaceValue(const AtomicString&); - PassRef<CSSPrimitiveValue> createFontFamilyValue(const String&); - PassRef<CSSInheritedValue> createInheritedValue() { return m_inheritedValue.get(); } - PassRef<CSSInitialValue> createImplicitInitialValue() { return m_implicitInitialValue.get(); } - PassRef<CSSInitialValue> createExplicitInitialValue() { return m_explicitInitialValue.get(); } - PassRef<CSSPrimitiveValue> createIdentifierValue(CSSValueID identifier); - PassRef<CSSPrimitiveValue> createIdentifierValue(CSSPropertyID identifier); - PassRef<CSSPrimitiveValue> createColorValue(unsigned rgbValue); - PassRef<CSSPrimitiveValue> createValue(double value, CSSPrimitiveValue::UnitTypes); - PassRef<CSSPrimitiveValue> createValue(const String& value, CSSPrimitiveValue::UnitTypes type) { return CSSPrimitiveValue::create(value, type); } - PassRef<CSSPrimitiveValue> createValue(const Length& value, const RenderStyle* style) { return CSSPrimitiveValue::create(value, style); } - PassRef<CSSPrimitiveValue> createValue(const LengthSize& value) { return CSSPrimitiveValue::create(value); } - template<typename T> static PassRef<CSSPrimitiveValue> createValue(T value) { return CSSPrimitiveValue::create(value); } + static CSSValuePool& singleton(); + + RefPtr<CSSValueList> createFontFaceValue(const AtomicString&); + Ref<CSSPrimitiveValue> createFontFamilyValue(const String&, FromSystemFontID = FromSystemFontID::No); + Ref<CSSInheritedValue> createInheritedValue() { return m_inheritedValue.get(); } + Ref<CSSInitialValue> createImplicitInitialValue() { return m_implicitInitialValue.get(); } + Ref<CSSInitialValue> createExplicitInitialValue() { return m_explicitInitialValue.get(); } + Ref<CSSUnsetValue> createUnsetValue() { return m_unsetValue.get(); } + Ref<CSSRevertValue> createRevertValue() { return m_revertValue.get(); } + Ref<CSSPrimitiveValue> createIdentifierValue(CSSValueID identifier); + Ref<CSSPrimitiveValue> createIdentifierValue(CSSPropertyID identifier); + Ref<CSSPrimitiveValue> createColorValue(const Color&); + Ref<CSSPrimitiveValue> createValue(double value, CSSPrimitiveValue::UnitType); + Ref<CSSPrimitiveValue> createValue(const String& value, CSSPrimitiveValue::UnitType type) { return CSSPrimitiveValue::create(value, type); } + Ref<CSSPrimitiveValue> createValue(const Length& value, const RenderStyle& style) { return CSSPrimitiveValue::create(value, style); } + Ref<CSSPrimitiveValue> createValue(const LengthSize& value, const RenderStyle& style) { return CSSPrimitiveValue::create(value, style); } + template<typename T> static Ref<CSSPrimitiveValue> createValue(T&& value) { return CSSPrimitiveValue::create(std::forward<T>(value)); } void drain(); private: CSSValuePool(); - Ref<CSSInheritedValue> m_inheritedValue; - Ref<CSSInitialValue> m_implicitInitialValue; - Ref<CSSInitialValue> m_explicitInitialValue; - - RefPtr<CSSPrimitiveValue> m_identifierValueCache[numCSSValueKeywords]; - - typedef HashMap<unsigned, RefPtr<CSSPrimitiveValue>> ColorValueCache; + typedef HashMap<Color, RefPtr<CSSPrimitiveValue>> ColorValueCache; ColorValueCache m_colorValueCache; - Ref<CSSPrimitiveValue> m_colorTransparent; - Ref<CSSPrimitiveValue> m_colorWhite; - Ref<CSSPrimitiveValue> m_colorBlack; - - static const int maximumCacheableIntegerValue = 255; - - RefPtr<CSSPrimitiveValue> m_pixelValueCache[maximumCacheableIntegerValue + 1]; - RefPtr<CSSPrimitiveValue> m_percentValueCache[maximumCacheableIntegerValue + 1]; - RefPtr<CSSPrimitiveValue> m_numberValueCache[maximumCacheableIntegerValue + 1]; typedef HashMap<AtomicString, RefPtr<CSSValueList>> FontFaceValueCache; FontFaceValueCache m_fontFaceValueCache; - typedef HashMap<String, RefPtr<CSSPrimitiveValue>> FontFamilyValueCache; + typedef HashMap<std::pair<String, bool>, RefPtr<CSSPrimitiveValue>> FontFamilyValueCache; FontFamilyValueCache m_fontFamilyValueCache; - friend CSSValuePool& cssValuePool(); -}; + friend class WTF::NeverDestroyed<CSSValuePool>; + + LazyNeverDestroyed<CSSInheritedValue> m_inheritedValue; + LazyNeverDestroyed<CSSInitialValue> m_implicitInitialValue; + LazyNeverDestroyed<CSSInitialValue> m_explicitInitialValue; + LazyNeverDestroyed<CSSUnsetValue> m_unsetValue; + LazyNeverDestroyed<CSSRevertValue> m_revertValue; -CSSValuePool& cssValuePool() PURE_FUNCTION; + LazyNeverDestroyed<CSSPrimitiveValue> m_transparentColor; + LazyNeverDestroyed<CSSPrimitiveValue> m_whiteColor; + LazyNeverDestroyed<CSSPrimitiveValue> m_blackColor; -} + static const int maximumCacheableIntegerValue = 255; + + LazyNeverDestroyed<CSSPrimitiveValue> m_pixelValues[maximumCacheableIntegerValue + 1]; + LazyNeverDestroyed<CSSPrimitiveValue> m_percentValues[maximumCacheableIntegerValue + 1]; + LazyNeverDestroyed<CSSPrimitiveValue> m_numberValues[maximumCacheableIntegerValue + 1]; + LazyNeverDestroyed<CSSPrimitiveValue> m_identifierValues[numCSSValueKeywords]; +}; -#endif +} // namespace WebCore |