#ifndef CSSValue_h
#define CSSValue_h
#include "ExceptionCode.h"
#include "KURLHash.h"
#include <wtf/ListHashSet.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class StyleSheetInternal;
class CSSValue : public RefCounted<CSSValue> {
public:
enum Type {
CSS_INHERIT = 0,
CSS_PRIMITIVE_VALUE = 1,
CSS_VALUE_LIST = 2,
CSS_CUSTOM = 3,
CSS_INITIAL = 4
};
void deref()
{
if (derefBase())
destroy();
}
Type cssValueType() const;
String cssText() const;
void setCssText(const String&, ExceptionCode&) { }
bool isPrimitiveValue() const { return m_classType == PrimitiveClass; }
bool isValueList() const { return m_classType >= ValueListClass; }
bool isAspectRatioValue() const { return m_classType == AspectRatioClass; }
bool isBorderImageSliceValue() const { return m_classType == BorderImageSliceClass; }
bool isCursorImageValue() const { return m_classType == CursorImageClass; }
bool isFontFeatureValue() const { return m_classType == FontFeatureClass; }
bool isFontValue() const { return m_classType == FontClass; }
bool isImageGeneratorValue() const { return m_classType >= CanvasClass && m_classType <= RadialGradientClass; }
#if ENABLE(CSS_IMAGE_SET)
bool isImageSetValue() const { return m_classType == ImageSetClass; }
#endif
bool isImageValue() const { return m_classType == ImageClass || m_classType == CursorImageClass; }
bool isImplicitInitialValue() const;
bool isInheritedValue() const { return m_classType == InheritedClass; }
bool isInitialValue() const { return m_classType == InitialClass; }
bool isReflectValue() const { return m_classType == ReflectClass; }
bool isShadowValue() const { return m_classType == ShadowClass; }
bool isCubicBezierTimingFunctionValue() const { return m_classType == CubicBezierTimingFunctionClass; }
bool isLinearTimingFunctionValue() const { return m_classType == LinearTimingFunctionClass; }
bool isStepsTimingFunctionValue() const { return m_classType == StepsTimingFunctionClass; }
bool isWebKitCSSTransformValue() const { return m_classType == WebKitCSSTransformClass; }
bool isCSSLineBoxContainValue() const { return m_classType == LineBoxContainClass; }
bool isCalculationValue() const {return m_classType == CalculationClass; }
#if ENABLE(CSS_FILTERS)
bool isWebKitCSSFilterValue() const { return m_classType == WebKitCSSFilterClass; }
#if ENABLE(CSS_SHADERS)
bool isWebKitCSSShaderValue() const { return m_classType == WebKitCSSShaderClass; }
#endif
#endif // ENABLE(CSS_FILTERS)
#if ENABLE(SVG)
bool isSVGColor() const { return m_classType == SVGColorClass || m_classType == SVGPaintClass; }
bool isSVGPaint() const { return m_classType == SVGPaintClass; }
#endif
bool isCSSOMSafe() const { return m_isCSSOMSafe; }
bool isSubtypeExposedToCSSOM() const
{
return isPrimitiveValue()
#if ENABLE(SVG)
|| isSVGColor()
#endif
|| isValueList();
}
PassRefPtr<CSSValue> cloneForCSSOM() const;
void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetInternal*);
bool hasFailedOrCanceledSubresources() const;
protected:
static const size_t ClassTypeBits = 5;
enum ClassType {
PrimitiveClass,
ImageClass,
CursorImageClass,
CanvasClass,
CrossfadeClass,
LinearGradientClass,
RadialGradientClass,
CubicBezierTimingFunctionClass,
LinearTimingFunctionClass,
StepsTimingFunctionClass,
AspectRatioClass,
BorderImageSliceClass,
FontFeatureClass,
FontClass,
FontFaceSrcClass,
FunctionClass,
InheritedClass,
InitialClass,
ReflectClass,
ShadowClass,
UnicodeRangeClass,
LineBoxContainClass,
CalculationClass,
#if ENABLE(CSS_FILTERS) && ENABLE(CSS_SHADERS)
WebKitCSSShaderClass,
#endif
#if ENABLE(SVG)
SVGColorClass,
SVGPaintClass,
#endif
ValueListClass,
#if ENABLE(CSS_IMAGE_SET)
ImageSetClass,
#endif
#if ENABLE(CSS_FILTERS)
WebKitCSSFilterClass,
#endif
WebKitCSSTransformClass,
};
static const size_t ValueListSeparatorBits = 2;
enum ValueListSeparator {
SpaceSeparator,
CommaSeparator,
SlashSeparator
};
ClassType classType() const { return static_cast<ClassType>(m_classType); }
explicit CSSValue(ClassType classType, bool isCSSOMSafe = false)
: m_isCSSOMSafe(isCSSOMSafe)
, m_isTextClone(false)
, m_primitiveUnitType(0)
, m_hasCachedCSSText(false)
, m_isQuirkValue(false)
, m_valueListSeparator(SpaceSeparator)
, m_classType(classType)
{
}
~CSSValue() { }
private:
void destroy();
protected:
unsigned m_isCSSOMSafe : 1;
unsigned m_isTextClone : 1;
unsigned m_primitiveUnitType : 7; mutable unsigned m_hasCachedCSSText : 1;
unsigned m_isQuirkValue : 1;
unsigned m_valueListSeparator : ValueListSeparatorBits;
private:
unsigned m_classType : ClassTypeBits; };
}
#endif // CSSValue_h