summaryrefslogtreecommitdiffstats
path: root/WebCore/css/CSSPrimitiveValue.h
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/css/CSSPrimitiveValue.h')
-rw-r--r--WebCore/css/CSSPrimitiveValue.h39
1 files changed, 25 insertions, 14 deletions
diff --git a/WebCore/css/CSSPrimitiveValue.h b/WebCore/css/CSSPrimitiveValue.h
index bb3ea70..e12cd4c 100644
--- a/WebCore/css/CSSPrimitiveValue.h
+++ b/WebCore/css/CSSPrimitiveValue.h
@@ -83,17 +83,27 @@ public:
// These next types are just used internally to allow us to translate back and forth from CSSPrimitiveValues to CSSParserValues.
CSS_PARSER_OPERATOR = 103,
CSS_PARSER_INTEGER = 104,
- CSS_PARSER_VARIABLE_FUNCTION_SYNTAX = 105,
- CSS_PARSER_HEXCOLOR = 106,
+ CSS_PARSER_HEXCOLOR = 105,
// This is used internally for unknown identifiers
- CSS_PARSER_IDENTIFIER = 107,
+ CSS_PARSER_IDENTIFIER = 106,
// These are from CSS3 Values and Units, but that isn't a finished standard yet
- CSS_TURN = 108,
- CSS_REMS = 109
+ CSS_TURN = 107,
+ CSS_REMS = 108
};
+ // This enum follows the CSSParser::Units enum augmented with UNIT_FREQUENCY for frequencies.
+ enum UnitCategory {
+ UNumber,
+ UPercent,
+ ULength,
+ UAngle,
+ UTime,
+ UFrequency,
+ UOther
+ };
+
static bool isUnitTypeLength(int type) { return (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) ||
type == CSSPrimitiveValue::CSS_REMS; }
@@ -113,8 +123,6 @@ public:
unsigned short primitiveType() const { return m_type; }
- bool isVariable() const { return m_type == CSS_PARSER_VARIABLE_FUNCTION_SYNTAX; }
-
/*
* computes a length in pixels out of the given CSSValue. Need the RenderStyle to get
* the fontinfo in case val is defined in em or ex.
@@ -138,17 +146,17 @@ public:
// use with care!!!
void setPrimitiveType(unsigned short type) { m_type = type; }
- double getDoubleValue(unsigned short unitType, ExceptionCode&);
- double getDoubleValue(unsigned short unitType);
+ double getDoubleValue(unsigned short unitType, ExceptionCode&) const;
+ double getDoubleValue(unsigned short unitType) const;
double getDoubleValue() const { return m_value.num; }
void setFloatValue(unsigned short unitType, double floatValue, ExceptionCode&);
- float getFloatValue(unsigned short unitType, ExceptionCode& ec) { return static_cast<float>(getDoubleValue(unitType, ec)); }
- float getFloatValue(unsigned short unitType) { return static_cast<float>(getDoubleValue(unitType)); }
+ float getFloatValue(unsigned short unitType, ExceptionCode& ec) const { return static_cast<float>(getDoubleValue(unitType, ec)); }
+ float getFloatValue(unsigned short unitType) const { return static_cast<float>(getDoubleValue(unitType)); }
float getFloatValue() const { return static_cast<float>(m_value.num); }
- int getIntValue(unsigned short unitType, ExceptionCode& ec) { return static_cast<int>(getDoubleValue(unitType, ec)); }
- int getIntValue(unsigned short unitType) { return static_cast<int>(getDoubleValue(unitType)); }
+ int getIntValue(unsigned short unitType, ExceptionCode& ec) const { return static_cast<int>(getDoubleValue(unitType, ec)); }
+ int getIntValue(unsigned short unitType) const { return static_cast<int>(getDoubleValue(unitType)); }
int getIntValue() const { return static_cast<int>(m_value.num); }
void setStringValue(unsigned short stringType, const String& stringValue, ExceptionCode&);
@@ -169,7 +177,7 @@ public:
DashboardRegion* getDashboardRegionValue() const { return m_type != CSS_DASHBOARD_REGION ? 0 : m_value.region; }
- int getIdent();
+ int getIdent() const;
template<typename T> inline operator T() const; // Defined in CSSPrimitiveValueMappings.h
virtual bool parseString(const String&, bool = false);
@@ -204,10 +212,13 @@ private:
static PassRefPtr<CSSPrimitiveValue> createUncachedColor(unsigned rgbValue);
static PassRefPtr<CSSPrimitiveValue> createUncached(double value, UnitTypes type);
+ static UnitTypes canonicalUnitTypeForCategory(UnitCategory category);
+
void init(PassRefPtr<Counter>);
void init(PassRefPtr<Rect>);
void init(PassRefPtr<Pair>);
void init(PassRefPtr<DashboardRegion>); // FIXME: Dashboard region should not be a primitive value.
+ bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const;
virtual bool isPrimitiveValue() const { return true; }