Diff
Modified: trunk/Source/WebCore/ChangeLog (99408 => 99409)
--- trunk/Source/WebCore/ChangeLog 2011-11-07 13:22:09 UTC (rev 99408)
+++ trunk/Source/WebCore/ChangeLog 2011-11-07 13:31:31 UTC (rev 99409)
@@ -1,3 +1,33 @@
+2011-11-06 Andreas Kling <kl...@webkit.org>
+
+ 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:
+
2011-11-07 Pavel Feldman <pfeld...@chromium.org>
Web Inspector: introduce UserAgent override setting.
Modified: trunk/Source/WebCore/css/CSSInheritedValue.cpp (99408 => 99409)
--- trunk/Source/WebCore/css/CSSInheritedValue.cpp 2011-11-07 13:22:09 UTC (rev 99408)
+++ trunk/Source/WebCore/css/CSSInheritedValue.cpp 2011-11-07 13:31:31 UTC (rev 99409)
@@ -25,11 +25,6 @@
namespace WebCore {
-unsigned short CSSInheritedValue::cssValueType() const
-{
- return CSS_INHERIT;
-}
-
String CSSInheritedValue::cssText() const
{
return "inherit";
Modified: trunk/Source/WebCore/css/CSSInheritedValue.h (99408 => 99409)
--- trunk/Source/WebCore/css/CSSInheritedValue.h 2011-11-07 13:22:09 UTC (rev 99408)
+++ trunk/Source/WebCore/css/CSSInheritedValue.h 2011-11-07 13:31:31 UTC (rev 99409)
@@ -36,8 +36,10 @@
virtual String cssText() const;
private:
- CSSInheritedValue() { }
- virtual unsigned short cssValueType() const;
+ CSSInheritedValue()
+ : CSSValue(CSS_INHERIT)
+ {
+ }
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/CSSInitialValue.cpp (99408 => 99409)
--- trunk/Source/WebCore/css/CSSInitialValue.cpp 2011-11-07 13:22:09 UTC (rev 99408)
+++ trunk/Source/WebCore/css/CSSInitialValue.cpp 2011-11-07 13:31:31 UTC (rev 99409)
@@ -25,11 +25,6 @@
namespace WebCore {
-unsigned short CSSInitialValue::cssValueType() const
-{
- return CSS_INITIAL;
-}
-
String CSSInitialValue::cssText() const
{
return "initial";
Modified: trunk/Source/WebCore/css/CSSInitialValue.h (99408 => 99409)
--- trunk/Source/WebCore/css/CSSInitialValue.h 2011-11-07 13:22:09 UTC (rev 99408)
+++ trunk/Source/WebCore/css/CSSInitialValue.h 2011-11-07 13:31:31 UTC (rev 99409)
@@ -43,7 +43,8 @@
private:
CSSInitialValue(bool implicit)
- : m_implicit(implicit)
+ : CSSValue(CSS_INITIAL)
+ , m_implicit(implicit)
{
}
@@ -52,7 +53,6 @@
return adoptRef(new CSSInitialValue(implicit));
}
- virtual unsigned short cssValueType() const;
virtual bool isImplicitInitialValue() const { return m_implicit; }
bool m_implicit;
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (99408 => 99409)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2011-11-07 13:22:09 UTC (rev 99408)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2011-11-07 13:31:31 UTC (rev 99409)
@@ -164,14 +164,16 @@
}
CSSPrimitiveValue::CSSPrimitiveValue()
- : m_type(0)
+ : CSSValue(CSS_PRIMITIVE_VALUE)
+ , m_type(0)
, m_hasCachedCSSText(false)
, m_isQuirkValue(false)
{
}
CSSPrimitiveValue::CSSPrimitiveValue(int ident)
- : m_type(CSS_IDENT)
+ : CSSValue(CSS_PRIMITIVE_VALUE)
+ , m_type(CSS_IDENT)
, m_hasCachedCSSText(false)
, m_isQuirkValue(false)
{
@@ -179,7 +181,8 @@
}
CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitTypes type)
- : m_type(type)
+ : CSSValue(CSS_PRIMITIVE_VALUE)
+ , m_type(type)
, m_hasCachedCSSText(false)
, m_isQuirkValue(false)
{
@@ -188,7 +191,8 @@
}
CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitTypes type)
- : m_type(type)
+ : CSSValue(CSS_PRIMITIVE_VALUE)
+ , m_type(type)
, m_hasCachedCSSText(false)
, m_isQuirkValue(false)
{
@@ -197,7 +201,8 @@
}
CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color)
- : m_type(CSS_RGBCOLOR)
+ : CSSValue(CSS_PRIMITIVE_VALUE)
+ , m_type(CSS_RGBCOLOR)
, m_hasCachedCSSText(false)
, m_isQuirkValue(false)
{
@@ -205,7 +210,8 @@
}
CSSPrimitiveValue::CSSPrimitiveValue(const Length& length)
- : m_hasCachedCSSText(false)
+ : CSSValue(CSS_PRIMITIVE_VALUE)
+ , m_hasCachedCSSText(false)
, m_isQuirkValue(false)
{
switch (length.type()) {
@@ -664,11 +670,6 @@
return m_value.pair;
}
-unsigned short CSSPrimitiveValue::cssValueType() const
-{
- return CSS_PRIMITIVE_VALUE;
-}
-
bool CSSPrimitiveValue::parseString(const String& /*string*/, bool /*strict*/)
{
// FIXME
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (99408 => 99409)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.h 2011-11-07 13:22:09 UTC (rev 99408)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h 2011-11-07 13:31:31 UTC (rev 99409)
@@ -252,8 +252,6 @@
virtual bool isPrimitiveValue() const { return true; }
- virtual unsigned short cssValueType() const;
-
signed m_type : UnitTypesBits;
mutable unsigned m_hasCachedCSSText : 1;
unsigned m_isQuirkValue : 1;
Modified: trunk/Source/WebCore/css/CSSValue.h (99408 => 99409)
--- trunk/Source/WebCore/css/CSSValue.h 2011-11-07 13:22:09 UTC (rev 99408)
+++ trunk/Source/WebCore/css/CSSValue.h 2011-11-07 13:31:31 UTC (rev 99409)
@@ -34,8 +34,7 @@
class CSSValue : public RefCounted<CSSValue> {
public:
- // FIXME: Change name to Type.
- enum UnitTypes {
+ enum Type {
CSS_INHERIT = 0,
CSS_PRIMITIVE_VALUE = 1,
CSS_VALUE_LIST = 2,
@@ -45,8 +44,7 @@
virtual ~CSSValue() { }
- // FIXME: Change this to return UnitTypes.
- virtual unsigned short cssValueType() const { return CSS_CUSTOM; }
+ Type cssValueType() const { return static_cast<Type>(m_type); }
virtual String cssText() const = 0;
void setCssText(const String&, ExceptionCode&) { } // FIXME: Not implemented.
@@ -81,6 +79,17 @@
#endif
virtual void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*) { }
+
+protected:
+ CSSValue(Type type = CSS_CUSTOM)
+ : m_type(type)
+ {
+ }
+
+private:
+ // FIXME: This class is currently a little bloated, but that will change.
+ // See <http://webkit.org/b/71666> for more information.
+ unsigned m_type : 3; // Type
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/CSSValueList.cpp (99408 => 99409)
--- trunk/Source/WebCore/css/CSSValueList.cpp 2011-11-07 13:22:09 UTC (rev 99408)
+++ trunk/Source/WebCore/css/CSSValueList.cpp 2011-11-07 13:31:31 UTC (rev 99409)
@@ -28,12 +28,14 @@
namespace WebCore {
CSSValueList::CSSValueList(bool isSpaceSeparated)
- : m_isSpaceSeparated(isSpaceSeparated)
+ : CSSValue(CSS_VALUE_LIST)
+ , m_isSpaceSeparated(isSpaceSeparated)
{
}
CSSValueList::CSSValueList(CSSParserValueList* list)
- : m_isSpaceSeparated(true)
+ : CSSValue(CSS_VALUE_LIST)
+ , m_isSpaceSeparated(true)
{
if (list) {
size_t size = list->size();
@@ -46,11 +48,6 @@
{
}
-unsigned short CSSValueList::cssValueType() const
-{
- return CSS_VALUE_LIST;
-}
-
void CSSValueList::append(PassRefPtr<CSSValue> val)
{
m_values.append(val);
Modified: trunk/Source/WebCore/css/CSSValueList.h (99408 => 99409)
--- trunk/Source/WebCore/css/CSSValueList.h 2011-11-07 13:22:09 UTC (rev 99408)
+++ trunk/Source/WebCore/css/CSSValueList.h 2011-11-07 13:31:31 UTC (rev 99409)
@@ -67,8 +67,6 @@
private:
virtual bool isValueList() const { return true; }
- virtual unsigned short cssValueType() const;
-
Vector<RefPtr<CSSValue> > m_values;
bool m_isSpaceSeparated;
};