From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/css/CSSValuePool.h | 83 ++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 37 deletions(-) (limited to 'Source/WebCore/css/CSSValuePool.h') 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 #include +#include #include #include @@ -39,57 +44,61 @@ namespace WebCore { class CSSValueList; +enum class FromSystemFontID { No, Yes }; + class CSSValuePool { WTF_MAKE_FAST_ALLOCATED; public: - PassRefPtr createFontFaceValue(const AtomicString&); - PassRef createFontFamilyValue(const String&); - PassRef createInheritedValue() { return m_inheritedValue.get(); } - PassRef createImplicitInitialValue() { return m_implicitInitialValue.get(); } - PassRef createExplicitInitialValue() { return m_explicitInitialValue.get(); } - PassRef createIdentifierValue(CSSValueID identifier); - PassRef createIdentifierValue(CSSPropertyID identifier); - PassRef createColorValue(unsigned rgbValue); - PassRef createValue(double value, CSSPrimitiveValue::UnitTypes); - PassRef createValue(const String& value, CSSPrimitiveValue::UnitTypes type) { return CSSPrimitiveValue::create(value, type); } - PassRef createValue(const Length& value, const RenderStyle* style) { return CSSPrimitiveValue::create(value, style); } - PassRef createValue(const LengthSize& value) { return CSSPrimitiveValue::create(value); } - template static PassRef createValue(T value) { return CSSPrimitiveValue::create(value); } + static CSSValuePool& singleton(); + + RefPtr createFontFaceValue(const AtomicString&); + Ref createFontFamilyValue(const String&, FromSystemFontID = FromSystemFontID::No); + Ref createInheritedValue() { return m_inheritedValue.get(); } + Ref createImplicitInitialValue() { return m_implicitInitialValue.get(); } + Ref createExplicitInitialValue() { return m_explicitInitialValue.get(); } + Ref createUnsetValue() { return m_unsetValue.get(); } + Ref createRevertValue() { return m_revertValue.get(); } + Ref createIdentifierValue(CSSValueID identifier); + Ref createIdentifierValue(CSSPropertyID identifier); + Ref createColorValue(const Color&); + Ref createValue(double value, CSSPrimitiveValue::UnitType); + Ref createValue(const String& value, CSSPrimitiveValue::UnitType type) { return CSSPrimitiveValue::create(value, type); } + Ref createValue(const Length& value, const RenderStyle& style) { return CSSPrimitiveValue::create(value, style); } + Ref createValue(const LengthSize& value, const RenderStyle& style) { return CSSPrimitiveValue::create(value, style); } + template static Ref createValue(T&& value) { return CSSPrimitiveValue::create(std::forward(value)); } void drain(); private: CSSValuePool(); - Ref m_inheritedValue; - Ref m_implicitInitialValue; - Ref m_explicitInitialValue; - - RefPtr m_identifierValueCache[numCSSValueKeywords]; - - typedef HashMap> ColorValueCache; + typedef HashMap> ColorValueCache; ColorValueCache m_colorValueCache; - Ref m_colorTransparent; - Ref m_colorWhite; - Ref m_colorBlack; - - static const int maximumCacheableIntegerValue = 255; - - RefPtr m_pixelValueCache[maximumCacheableIntegerValue + 1]; - RefPtr m_percentValueCache[maximumCacheableIntegerValue + 1]; - RefPtr m_numberValueCache[maximumCacheableIntegerValue + 1]; typedef HashMap> FontFaceValueCache; FontFaceValueCache m_fontFaceValueCache; - typedef HashMap> FontFamilyValueCache; + typedef HashMap, RefPtr> FontFamilyValueCache; FontFamilyValueCache m_fontFamilyValueCache; - friend CSSValuePool& cssValuePool(); -}; + friend class WTF::NeverDestroyed; + + LazyNeverDestroyed m_inheritedValue; + LazyNeverDestroyed m_implicitInitialValue; + LazyNeverDestroyed m_explicitInitialValue; + LazyNeverDestroyed m_unsetValue; + LazyNeverDestroyed m_revertValue; -CSSValuePool& cssValuePool() PURE_FUNCTION; + LazyNeverDestroyed m_transparentColor; + LazyNeverDestroyed m_whiteColor; + LazyNeverDestroyed m_blackColor; -} + static const int maximumCacheableIntegerValue = 255; + + LazyNeverDestroyed m_pixelValues[maximumCacheableIntegerValue + 1]; + LazyNeverDestroyed m_percentValues[maximumCacheableIntegerValue + 1]; + LazyNeverDestroyed m_numberValues[maximumCacheableIntegerValue + 1]; + LazyNeverDestroyed m_identifierValues[numCSSValueKeywords]; +}; -#endif +} // namespace WebCore -- cgit v1.2.1