Diff
Modified: trunk/Source/WebCore/ChangeLog (252784 => 252785)
--- trunk/Source/WebCore/ChangeLog 2019-11-22 19:00:04 UTC (rev 252784)
+++ trunk/Source/WebCore/ChangeLog 2019-11-22 19:00:32 UTC (rev 252785)
@@ -1,3 +1,20 @@
+2019-11-22 Chris Lord <[email protected]>
+
+ Make CSSValuePool constructable
+ https://bugs.webkit.org/show_bug.cgi?id=204520
+
+ Reviewed by Antti Koivisto.
+
+ No new tests, no new functionality.
+
+ * css/CSSInheritedValue.h:
+ * css/CSSRevertValue.h:
+ * css/CSSUnsetValue.h:
+ * css/CSSValuePool.cpp:
+ (WebCore::CSSValuePool::singleton):
+ (WebCore::CSSValuePool::CSSValuePool):
+ * css/CSSValuePool.h:
+
2019-11-22 Antti Koivisto <[email protected]>
Try to fix build on an old MacOS version
Modified: trunk/Source/WebCore/css/CSSInheritedValue.h (252784 => 252785)
--- trunk/Source/WebCore/css/CSSInheritedValue.h 2019-11-22 19:00:04 UTC (rev 252784)
+++ trunk/Source/WebCore/css/CSSInheritedValue.h 2019-11-22 19:00:32 UTC (rev 252785)
@@ -26,12 +26,13 @@
class CSSInheritedValue final : public CSSValue {
public:
+ static Ref<CSSInheritedValue> create() { return adoptRef(*new CSSInheritedValue()); }
+
String customCSSText() const;
bool equals(const CSSInheritedValue&) const { return true; }
private:
- friend LazyNeverDestroyed<CSSInheritedValue>;
CSSInheritedValue()
: CSSValue(InheritedClass)
{
Modified: trunk/Source/WebCore/css/CSSRevertValue.h (252784 => 252785)
--- trunk/Source/WebCore/css/CSSRevertValue.h 2019-11-22 19:00:04 UTC (rev 252784)
+++ trunk/Source/WebCore/css/CSSRevertValue.h 2019-11-22 19:00:32 UTC (rev 252785)
@@ -31,12 +31,13 @@
class CSSRevertValue final : public CSSValue {
public:
+ static Ref<CSSRevertValue> create() { return adoptRef(*new CSSRevertValue()); }
+
String customCSSText() const;
bool equals(const CSSRevertValue&) const { return true; }
private:
- friend LazyNeverDestroyed<CSSRevertValue>;
CSSRevertValue()
: CSSValue(RevertClass)
{
Modified: trunk/Source/WebCore/css/CSSUnsetValue.h (252784 => 252785)
--- trunk/Source/WebCore/css/CSSUnsetValue.h 2019-11-22 19:00:04 UTC (rev 252784)
+++ trunk/Source/WebCore/css/CSSUnsetValue.h 2019-11-22 19:00:32 UTC (rev 252785)
@@ -31,12 +31,13 @@
class CSSUnsetValue final : public CSSValue {
public:
+ static Ref<CSSUnsetValue> create() { return adoptRef(*new CSSUnsetValue()); }
+
String customCSSText() const;
bool equals(const CSSUnsetValue&) const { return true; }
private:
- friend LazyNeverDestroyed<CSSUnsetValue>;
CSSUnsetValue()
: CSSValue(UnsetClass)
{
Modified: trunk/Source/WebCore/css/CSSValuePool.cpp (252784 => 252785)
--- trunk/Source/WebCore/css/CSSValuePool.cpp 2019-11-22 19:00:04 UTC (rev 252784)
+++ trunk/Source/WebCore/css/CSSValuePool.cpp 2019-11-22 19:00:32 UTC (rev 252785)
@@ -35,29 +35,32 @@
CSSValuePool& CSSValuePool::singleton()
{
+ ASSERT(isMainThread());
static NeverDestroyed<CSSValuePool> pool;
return pool;
}
CSSValuePool::CSSValuePool()
+ : m_inheritedValue(CSSInheritedValue::create())
+ , m_implicitInitialValue(CSSInitialValue::createImplicit())
+ , m_explicitInitialValue(CSSInitialValue::createExplicit())
+ , m_unsetValue(CSSUnsetValue::create())
+ , m_revertValue(CSSRevertValue::create())
+ , m_transparentColor(CSSPrimitiveValue::create(Color(Color::transparent)))
+ , m_whiteColor(CSSPrimitiveValue::create(Color(Color::white)))
+ , m_blackColor(CSSPrimitiveValue::create(Color(Color::black)))
{
- m_inheritedValue.construct();
- m_implicitInitialValue.construct(true);
- m_explicitInitialValue.construct(false);
- m_unsetValue.construct();
- m_revertValue.construct();
+ m_identifierValues.reserveInitialCapacity(numCSSValueKeywords);
+ for (unsigned i = 0; i < numCSSValueKeywords; ++i)
+ m_identifierValues.uncheckedAppend(CSSPrimitiveValue::create(static_cast<CSSValueID>(i)));
- m_transparentColor.construct(Color(Color::transparent));
- m_whiteColor.construct(Color(Color::white));
- m_blackColor.construct(Color(Color::black));
-
- for (unsigned i = firstCSSValueKeyword; i <= lastCSSValueKeyword; ++i)
- m_identifierValues[i].construct(static_cast<CSSValueID>(i));
-
+ m_pixelValues.reserveInitialCapacity(maximumCacheableIntegerValue + 1);
+ m_percentValues.reserveInitialCapacity(maximumCacheableIntegerValue + 1);
+ m_numberValues.reserveInitialCapacity(maximumCacheableIntegerValue + 1);
for (unsigned i = 0; i < (maximumCacheableIntegerValue + 1); ++i) {
- m_pixelValues[i].construct(i, CSSUnitType::CSS_PX);
- m_percentValues[i].construct(i, CSSUnitType::CSS_PERCENTAGE);
- m_numberValues[i].construct(i, CSSUnitType::CSS_NUMBER);
+ m_pixelValues.uncheckedAppend(CSSPrimitiveValue::create(i, CSSUnitType::CSS_PX));
+ m_percentValues.uncheckedAppend(CSSPrimitiveValue::create(i, CSSUnitType::CSS_PERCENTAGE));
+ m_numberValues.uncheckedAppend(CSSPrimitiveValue::create(i, CSSUnitType::CSS_NUMBER));
}
}
Modified: trunk/Source/WebCore/css/CSSValuePool.h (252784 => 252785)
--- trunk/Source/WebCore/css/CSSValuePool.h 2019-11-22 19:00:04 UTC (rev 252784)
+++ trunk/Source/WebCore/css/CSSValuePool.h 2019-11-22 19:00:32 UTC (rev 252785)
@@ -37,6 +37,7 @@
#include <wtf/HashMap.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
#include <wtf/text/AtomStringHash.h>
namespace WebCore {
@@ -48,6 +49,8 @@
class CSSValuePool {
WTF_MAKE_FAST_ALLOCATED;
public:
+ CSSValuePool();
+
static CSSValuePool& singleton();
RefPtr<CSSValueList> createFontFaceValue(const AtomString&);
@@ -69,8 +72,6 @@
void drain();
private:
- CSSValuePool();
-
typedef HashMap<Color, RefPtr<CSSPrimitiveValue>> ColorValueCache;
ColorValueCache m_colorValueCache;
@@ -82,22 +83,22 @@
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;
+ Ref<CSSInheritedValue> m_inheritedValue;
+ Ref<CSSInitialValue> m_implicitInitialValue;
+ Ref<CSSInitialValue> m_explicitInitialValue;
+ Ref<CSSUnsetValue> m_unsetValue;
+ Ref<CSSRevertValue> m_revertValue;
- LazyNeverDestroyed<CSSPrimitiveValue> m_transparentColor;
- LazyNeverDestroyed<CSSPrimitiveValue> m_whiteColor;
- LazyNeverDestroyed<CSSPrimitiveValue> m_blackColor;
+ Ref<CSSPrimitiveValue> m_transparentColor;
+ Ref<CSSPrimitiveValue> m_whiteColor;
+ Ref<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];
+ Vector<Ref<CSSPrimitiveValue>> m_pixelValues;
+ Vector<Ref<CSSPrimitiveValue>> m_percentValues;
+ Vector<Ref<CSSPrimitiveValue>> m_numberValues;
+ Vector<Ref<CSSPrimitiveValue>> m_identifierValues;
};
} // namespace WebCore