⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 99409 in webkit


Ignore:
Timestamp:
Nov 7, 2011, 5:31:31 AM (15 years ago)
Author:
andreas.kling@nokia.com
Message:

CSSValue: Devirtualize cssValueType().
<http://webkit.org/b/71667>

Reviewed by Antti Koivisto.

Keep the cssValueType in a CSSValue member instead of using
virtual functions.

This is part of a project to completely devirtualize CSSValue
<http://webkit.org/b/71666> and will incur a temporary object
size regression for CSSValue while the work is ongoing.

  • css/CSSInheritedValue.cpp:
  • css/CSSInheritedValue.h:

(WebCore::CSSInheritedValue::CSSInheritedValue):

  • css/CSSInitialValue.cpp:
  • css/CSSInitialValue.h:

(WebCore::CSSInitialValue::CSSInitialValue):

  • css/CSSPrimitiveValue.cpp:

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):

  • css/CSSPrimitiveValue.h:
  • css/CSSValue.h:

(WebCore::CSSValue::cssValueType):
(WebCore::CSSValue::CSSValue):

  • css/CSSValueList.cpp:

(WebCore::CSSValueList::CSSValueList):

  • css/CSSValueList.h:
Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r99408 r99409  
     12011-11-06  Andreas Kling  <kling@webkit.org>
     2
     3        CSSValue: Devirtualize cssValueType().
     4        <http://webkit.org/b/71667>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Keep the cssValueType in a CSSValue member instead of using
     9        virtual functions.
     10
     11        This is part of a project to completely devirtualize CSSValue
     12        <http://webkit.org/b/71666> and will incur a temporary object
     13        size regression for CSSValue while the work is ongoing.
     14
     15        * css/CSSInheritedValue.cpp:
     16        * css/CSSInheritedValue.h:
     17        (WebCore::CSSInheritedValue::CSSInheritedValue):
     18        * css/CSSInitialValue.cpp:
     19        * css/CSSInitialValue.h:
     20        (WebCore::CSSInitialValue::CSSInitialValue):
     21        * css/CSSPrimitiveValue.cpp:
     22        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
     23        * css/CSSPrimitiveValue.h:
     24        * css/CSSValue.h:
     25        (WebCore::CSSValue::cssValueType):
     26        (WebCore::CSSValue::CSSValue):
     27        * css/CSSValueList.cpp:
     28        (WebCore::CSSValueList::CSSValueList):
     29        * css/CSSValueList.h:
     30
    1312011-11-07  Pavel Feldman  <pfeldman@chromium.org>
    232
  • trunk/Source/WebCore/css/CSSInheritedValue.cpp

    r50583 r99409  
    2626namespace WebCore {
    2727
    28 unsigned short CSSInheritedValue::cssValueType() const
    29 {
    30     return CSS_INHERIT;
    31 }
    32 
    3328String CSSInheritedValue::cssText() const
    3429{
  • trunk/Source/WebCore/css/CSSInheritedValue.h

    r34627 r99409  
    3737
    3838private:
    39     CSSInheritedValue() { }
    40     virtual unsigned short cssValueType() const;
     39    CSSInheritedValue()
     40        : CSSValue(CSS_INHERIT)
     41    {
     42    }
    4143};
    4244
  • trunk/Source/WebCore/css/CSSInitialValue.cpp

    r97854 r99409  
    2626namespace WebCore {
    2727
    28 unsigned short CSSInitialValue::cssValueType() const
    29 {
    30     return CSS_INITIAL;
    31 }
    32 
    3328String CSSInitialValue::cssText() const
    3429{
  • trunk/Source/WebCore/css/CSSInitialValue.h

    r97854 r99409  
    4444private:
    4545    CSSInitialValue(bool implicit)
    46         : m_implicit(implicit)
     46        : CSSValue(CSS_INITIAL)
     47        , m_implicit(implicit)
    4748    {
    4849    }
     
    5354    }
    5455
    55     virtual unsigned short cssValueType() const;
    5656    virtual bool isImplicitInitialValue() const { return m_implicit; }
    5757
  • trunk/Source/WebCore/css/CSSPrimitiveValue.cpp

    r97854 r99409  
    165165
    166166CSSPrimitiveValue::CSSPrimitiveValue()
    167     : m_type(0)
     167    : CSSValue(CSS_PRIMITIVE_VALUE)
     168    , m_type(0)
    168169    , m_hasCachedCSSText(false)
    169170    , m_isQuirkValue(false)
     
    172173
    173174CSSPrimitiveValue::CSSPrimitiveValue(int ident)
    174     : m_type(CSS_IDENT)
     175    : CSSValue(CSS_PRIMITIVE_VALUE)
     176    , m_type(CSS_IDENT)
    175177    , m_hasCachedCSSText(false)
    176178    , m_isQuirkValue(false)
     
    180182
    181183CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitTypes type)
    182     : m_type(type)
     184    : CSSValue(CSS_PRIMITIVE_VALUE)
     185    , m_type(type)
    183186    , m_hasCachedCSSText(false)
    184187    , m_isQuirkValue(false)
     
    189192
    190193CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitTypes type)
    191     : m_type(type)
     194    : CSSValue(CSS_PRIMITIVE_VALUE)
     195    , m_type(type)
    192196    , m_hasCachedCSSText(false)
    193197    , m_isQuirkValue(false)
     
    198202
    199203CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color)
    200     : m_type(CSS_RGBCOLOR)
     204    : CSSValue(CSS_PRIMITIVE_VALUE)
     205    , m_type(CSS_RGBCOLOR)
    201206    , m_hasCachedCSSText(false)
    202207    , m_isQuirkValue(false)
     
    206211
    207212CSSPrimitiveValue::CSSPrimitiveValue(const Length& length)
    208     : m_hasCachedCSSText(false)
     213    : CSSValue(CSS_PRIMITIVE_VALUE)
     214    , m_hasCachedCSSText(false)
    209215    , m_isQuirkValue(false)
    210216{
     
    663669
    664670    return m_value.pair;
    665 }
    666 
    667 unsigned short CSSPrimitiveValue::cssValueType() const
    668 {
    669     return CSS_PRIMITIVE_VALUE;
    670671}
    671672
  • trunk/Source/WebCore/css/CSSPrimitiveValue.h

    r97854 r99409  
    253253    virtual bool isPrimitiveValue() const { return true; }
    254254
    255     virtual unsigned short cssValueType() const;
    256 
    257255    signed m_type : UnitTypesBits;
    258256    mutable unsigned m_hasCachedCSSText : 1;
  • trunk/Source/WebCore/css/CSSValue.h

    r98316 r99409  
    3535class CSSValue : public RefCounted<CSSValue> {
    3636public:
    37     // FIXME: Change name to Type.
    38     enum UnitTypes {
     37    enum Type {
    3938        CSS_INHERIT = 0,
    4039        CSS_PRIMITIVE_VALUE = 1,
     
    4645    virtual ~CSSValue() { }
    4746
    48     // FIXME: Change this to return UnitTypes.
    49     virtual unsigned short cssValueType() const { return CSS_CUSTOM; }
     47    Type cssValueType() const { return static_cast<Type>(m_type); }
    5048
    5149    virtual String cssText() const = 0;
     
    8280
    8381    virtual void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*) { }
     82
     83protected:
     84    CSSValue(Type type = CSS_CUSTOM)
     85        : m_type(type)
     86    {
     87    }
     88
     89private:
     90    // FIXME: This class is currently a little bloated, but that will change.
     91    //        See <http://webkit.org/b/71666> for more information.
     92    unsigned m_type : 3; // Type
    8493};
    8594
  • trunk/Source/WebCore/css/CSSValueList.cpp

    r97854 r99409  
    2929
    3030CSSValueList::CSSValueList(bool isSpaceSeparated)
    31     : m_isSpaceSeparated(isSpaceSeparated)
     31    : CSSValue(CSS_VALUE_LIST)
     32    , m_isSpaceSeparated(isSpaceSeparated)
    3233{
    3334}
    3435
    3536CSSValueList::CSSValueList(CSSParserValueList* list)
    36     : m_isSpaceSeparated(true)
     37    : CSSValue(CSS_VALUE_LIST)
     38    , m_isSpaceSeparated(true)
    3739{
    3840    if (list) {
     
    4547CSSValueList::~CSSValueList()
    4648{
    47 }
    48 
    49 unsigned short CSSValueList::cssValueType() const
    50 {
    51     return CSS_VALUE_LIST;
    5249}
    5350
  • trunk/Source/WebCore/css/CSSValueList.h

    r96870 r99409  
    6868    virtual bool isValueList() const { return true; }
    6969
    70     virtual unsigned short cssValueType() const;
    71 
    7270    Vector<RefPtr<CSSValue> > m_values;
    7371    bool m_isSpaceSeparated;
Note: See TracChangeset for help on using the changeset viewer.