Changeset 252785 in webkit


Ignore:
Timestamp:
Nov 22, 2019 11:00:32 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Make CSSValuePool constructable
https://bugs.webkit.org/show_bug.cgi?id=204520

Patch by Chris Lord <Chris Lord> on 2019-11-22
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:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r252784 r252785  
     12019-11-22  Chris Lord  <clord@igalia.com>
     2
     3        Make CSSValuePool constructable
     4        https://bugs.webkit.org/show_bug.cgi?id=204520
     5
     6        Reviewed by Antti Koivisto.
     7
     8        No new tests, no new functionality.
     9
     10        * css/CSSInheritedValue.h:
     11        * css/CSSRevertValue.h:
     12        * css/CSSUnsetValue.h:
     13        * css/CSSValuePool.cpp:
     14        (WebCore::CSSValuePool::singleton):
     15        (WebCore::CSSValuePool::CSSValuePool):
     16        * css/CSSValuePool.h:
     17
    1182019-11-22  Antti Koivisto  <antti@apple.com>
    219
  • trunk/Source/WebCore/css/CSSInheritedValue.h

    r235986 r252785  
    2727class CSSInheritedValue final : public CSSValue {
    2828public:
     29    static Ref<CSSInheritedValue> create() { return adoptRef(*new CSSInheritedValue()); }
     30
    2931    String customCSSText() const;
    3032
     
    3234
    3335private:
    34     friend LazyNeverDestroyed<CSSInheritedValue>;
    3536    CSSInheritedValue()
    3637        : CSSValue(InheritedClass)
  • trunk/Source/WebCore/css/CSSRevertValue.h

    r235986 r252785  
    3232class CSSRevertValue final : public CSSValue {
    3333public:
     34    static Ref<CSSRevertValue> create() { return adoptRef(*new CSSRevertValue()); }
     35
    3436    String customCSSText() const;
    3537
     
    3739
    3840private:
    39     friend LazyNeverDestroyed<CSSRevertValue>;
    4041    CSSRevertValue()
    4142        : CSSValue(RevertClass)
  • trunk/Source/WebCore/css/CSSUnsetValue.h

    r235986 r252785  
    3232class CSSUnsetValue final : public CSSValue {
    3333public:
     34    static Ref<CSSUnsetValue> create() { return adoptRef(*new CSSUnsetValue()); }
     35
    3436    String customCSSText() const;
    3537
     
    3739
    3840private:
    39     friend LazyNeverDestroyed<CSSUnsetValue>;
    4041    CSSUnsetValue()
    4142        : CSSValue(UnsetClass)
  • trunk/Source/WebCore/css/CSSValuePool.cpp

    r252392 r252785  
    3636CSSValuePool& CSSValuePool::singleton()
    3737{
     38    ASSERT(isMainThread());
    3839    static NeverDestroyed<CSSValuePool> pool;
    3940    return pool;
     
    4142
    4243CSSValuePool::CSSValuePool()
     44    : m_inheritedValue(CSSInheritedValue::create())
     45    , m_implicitInitialValue(CSSInitialValue::createImplicit())
     46    , m_explicitInitialValue(CSSInitialValue::createExplicit())
     47    , m_unsetValue(CSSUnsetValue::create())
     48    , m_revertValue(CSSRevertValue::create())
     49    , m_transparentColor(CSSPrimitiveValue::create(Color(Color::transparent)))
     50    , m_whiteColor(CSSPrimitiveValue::create(Color(Color::white)))
     51    , m_blackColor(CSSPrimitiveValue::create(Color(Color::black)))
    4352{
    44     m_inheritedValue.construct();
    45     m_implicitInitialValue.construct(true);
    46     m_explicitInitialValue.construct(false);
    47     m_unsetValue.construct();
    48     m_revertValue.construct();
     53    m_identifierValues.reserveInitialCapacity(numCSSValueKeywords);
     54    for (unsigned i = 0; i < numCSSValueKeywords; ++i)
     55        m_identifierValues.uncheckedAppend(CSSPrimitiveValue::create(static_cast<CSSValueID>(i)));
    4956
    50     m_transparentColor.construct(Color(Color::transparent));
    51     m_whiteColor.construct(Color(Color::white));
    52     m_blackColor.construct(Color(Color::black));
    53 
    54     for (unsigned i = firstCSSValueKeyword; i <= lastCSSValueKeyword; ++i)
    55         m_identifierValues[i].construct(static_cast<CSSValueID>(i));
    56 
     57    m_pixelValues.reserveInitialCapacity(maximumCacheableIntegerValue + 1);
     58    m_percentValues.reserveInitialCapacity(maximumCacheableIntegerValue + 1);
     59    m_numberValues.reserveInitialCapacity(maximumCacheableIntegerValue + 1);
    5760    for (unsigned i = 0; i < (maximumCacheableIntegerValue + 1); ++i) {
    58         m_pixelValues[i].construct(i, CSSUnitType::CSS_PX);
    59         m_percentValues[i].construct(i, CSSUnitType::CSS_PERCENTAGE);
    60         m_numberValues[i].construct(i, CSSUnitType::CSS_NUMBER);
     61        m_pixelValues.uncheckedAppend(CSSPrimitiveValue::create(i, CSSUnitType::CSS_PX));
     62        m_percentValues.uncheckedAppend(CSSPrimitiveValue::create(i, CSSUnitType::CSS_PERCENTAGE));
     63        m_numberValues.uncheckedAppend(CSSPrimitiveValue::create(i, CSSUnitType::CSS_NUMBER));
    6164    }
    6265}
  • trunk/Source/WebCore/css/CSSValuePool.h

    r252392 r252785  
    3838#include <wtf/NeverDestroyed.h>
    3939#include <wtf/RefPtr.h>
     40#include <wtf/Vector.h>
    4041#include <wtf/text/AtomStringHash.h>
    4142
     
    4950    WTF_MAKE_FAST_ALLOCATED;
    5051public:
     52    CSSValuePool();
     53
    5154    static CSSValuePool& singleton();
    5255
     
    7073
    7174private:
    72     CSSValuePool();
    73 
    7475    typedef HashMap<Color, RefPtr<CSSPrimitiveValue>> ColorValueCache;
    7576    ColorValueCache m_colorValueCache;
     
    8384    friend class WTF::NeverDestroyed<CSSValuePool>;
    8485
    85     LazyNeverDestroyed<CSSInheritedValue> m_inheritedValue;
    86     LazyNeverDestroyed<CSSInitialValue> m_implicitInitialValue;
    87     LazyNeverDestroyed<CSSInitialValue> m_explicitInitialValue;
    88     LazyNeverDestroyed<CSSUnsetValue> m_unsetValue;
    89     LazyNeverDestroyed<CSSRevertValue> m_revertValue;
     86    Ref<CSSInheritedValue> m_inheritedValue;
     87    Ref<CSSInitialValue> m_implicitInitialValue;
     88    Ref<CSSInitialValue> m_explicitInitialValue;
     89    Ref<CSSUnsetValue> m_unsetValue;
     90    Ref<CSSRevertValue> m_revertValue;
    9091
    91     LazyNeverDestroyed<CSSPrimitiveValue> m_transparentColor;
    92     LazyNeverDestroyed<CSSPrimitiveValue> m_whiteColor;
    93     LazyNeverDestroyed<CSSPrimitiveValue> m_blackColor;
     92    Ref<CSSPrimitiveValue> m_transparentColor;
     93    Ref<CSSPrimitiveValue> m_whiteColor;
     94    Ref<CSSPrimitiveValue> m_blackColor;
    9495
    9596    static const int maximumCacheableIntegerValue = 255;
    9697
    97     LazyNeverDestroyed<CSSPrimitiveValue> m_pixelValues[maximumCacheableIntegerValue + 1];
    98     LazyNeverDestroyed<CSSPrimitiveValue> m_percentValues[maximumCacheableIntegerValue + 1];
    99     LazyNeverDestroyed<CSSPrimitiveValue> m_numberValues[maximumCacheableIntegerValue + 1];
    100     LazyNeverDestroyed<CSSPrimitiveValue> m_identifierValues[numCSSValueKeywords];
     98    Vector<Ref<CSSPrimitiveValue>> m_pixelValues;
     99    Vector<Ref<CSSPrimitiveValue>> m_percentValues;
     100    Vector<Ref<CSSPrimitiveValue>> m_numberValues;
     101    Vector<Ref<CSSPrimitiveValue>> m_identifierValues;
    101102};
    102103
Note: See TracChangeset for help on using the changeset viewer.