Index: Source/core/css/CSSPrimitiveValue.cpp |
diff --git a/Source/core/css/CSSPrimitiveValue.cpp b/Source/core/css/CSSPrimitiveValue.cpp |
index e92fcc2ec47a90603c443cb09080623d94076123..ac92c915ed05ef33572861d7d0da2fd0d5f943c0 100644 |
--- a/Source/core/css/CSSPrimitiveValue.cpp |
+++ b/Source/core/css/CSSPrimitiveValue.cpp |
@@ -159,7 +159,7 @@ bool CSSPrimitiveValue::colorIsDerivedFromElement() const |
} |
} |
-typedef HashMap<const CSSPrimitiveValue*, String> CSSTextCache; |
+typedef HashMap<const CSSPrimitiveValue::CSSLargePrimitiveValue*, String> CSSTextCache; |
static CSSTextCache& cssTextCache() |
{ |
AtomicallyInitializedStaticReference(ThreadSpecific<CSSTextCache>, cache, new ThreadSpecific<CSSTextCache>()); |
@@ -168,13 +168,13 @@ static CSSTextCache& cssTextCache() |
CSSPrimitiveValue::UnitType CSSPrimitiveValue::primitiveType() const |
{ |
- if (m_primitiveUnitType == CSS_PROPERTY_ID || m_primitiveUnitType == CSS_VALUE_ID) |
+ if (type() == CSS_PROPERTY_ID || type() == CSS_VALUE_ID) |
return CSS_IDENT; |
- if (m_primitiveUnitType != CSS_CALC) |
- return static_cast<UnitType>(m_primitiveUnitType); |
+ if (type() != CSS_CALC) |
+ return type(); |
- switch (m_value.calc->category()) { |
+ switch (value().calc->category()) { |
case CalcAngle: |
return CSS_DEG; |
case CalcFrequency: |
@@ -217,21 +217,21 @@ static const AtomicString& valueName(CSSValueID valueID) |
return keywordString; |
} |
-CSSPrimitiveValue::CSSPrimitiveValue(CSSValueID valueID) |
+CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(CSSValueID valueID) |
: CSSValueObject(PrimitiveClass) |
{ |
m_primitiveUnitType = CSS_VALUE_ID; |
m_value.valueID = valueID; |
} |
-CSSPrimitiveValue::CSSPrimitiveValue(CSSPropertyID propertyID) |
+CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(CSSPropertyID propertyID) |
: CSSValueObject(PrimitiveClass) |
{ |
m_primitiveUnitType = CSS_PROPERTY_ID; |
m_value.propertyID = propertyID; |
} |
-CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitType type) |
+CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(double num, UnitType type) |
: CSSValueObject(PrimitiveClass) |
{ |
m_primitiveUnitType = type; |
@@ -239,7 +239,16 @@ CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitType type) |
m_value.num = num; |
} |
-CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitType type) |
+CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(double num, UnitType type, bool isQuirkValue) |
+ : CSSValueObject(PrimitiveClass) |
+{ |
+ m_primitiveUnitType = type; |
+ m_isQuirkValue = true; |
+ ASSERT(std::isfinite(num)); |
+ m_value.num = num; |
+} |
+ |
+CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(const String& str, UnitType type) |
: CSSValueObject(PrimitiveClass) |
{ |
m_primitiveUnitType = type; |
@@ -248,20 +257,20 @@ CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitType type) |
m_value.string->ref(); |
} |
-CSSPrimitiveValue::CSSPrimitiveValue(const LengthSize& lengthSize, const ComputedStyle& style) |
+CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(const LengthSize& lengthSize, const ComputedStyle& style) |
: CSSValueObject(PrimitiveClass) |
{ |
init(lengthSize, style); |
} |
-CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color) |
+CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(RGBA32 color) |
: CSSValueObject(PrimitiveClass) |
{ |
m_primitiveUnitType = CSS_RGBCOLOR; |
m_value.rgbcolor = color; |
} |
-CSSPrimitiveValue::CSSPrimitiveValue(const Length& length, float zoom) |
+CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(const Length& length, float zoom) |
: CSSValueObject(PrimitiveClass) |
{ |
switch (length.type()) { |
@@ -333,63 +342,63 @@ CSSPrimitiveValue::CSSPrimitiveValue(const Length& length, float zoom) |
} |
} |
-void CSSPrimitiveValue::init(const LengthSize& lengthSize, const ComputedStyle& style) |
+void CSSPrimitiveValue::CSSLargePrimitiveValue::init(const LengthSize& lengthSize, const ComputedStyle& style) |
{ |
m_primitiveUnitType = CSS_PAIR; |
m_hasCachedCSSText = false; |
m_value.pair = Pair::create(create(lengthSize.width(), style.effectiveZoom()), create(lengthSize.height(), style.effectiveZoom()), Pair::KeepIdenticalValues).leakRef(); |
} |
-void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Counter> c) |
+void CSSPrimitiveValue::CSSLargePrimitiveValue::init(PassRefPtrWillBeRawPtr<Counter> c) |
{ |
m_primitiveUnitType = CSS_COUNTER; |
m_hasCachedCSSText = false; |
m_value.counter = c.leakRef(); |
} |
-void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Rect> r) |
+void CSSPrimitiveValue::CSSLargePrimitiveValue::init(PassRefPtrWillBeRawPtr<Rect> r) |
{ |
m_primitiveUnitType = CSS_RECT; |
m_hasCachedCSSText = false; |
m_value.rect = r.leakRef(); |
} |
-void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Quad> quad) |
+void CSSPrimitiveValue::CSSLargePrimitiveValue::init(PassRefPtrWillBeRawPtr<Quad> quad) |
{ |
m_primitiveUnitType = CSS_QUAD; |
m_hasCachedCSSText = false; |
m_value.quad = quad.leakRef(); |
} |
-void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Pair> p) |
+void CSSPrimitiveValue::CSSLargePrimitiveValue::init(PassRefPtrWillBeRawPtr<Pair> p) |
{ |
m_primitiveUnitType = CSS_PAIR; |
m_hasCachedCSSText = false; |
m_value.pair = p.leakRef(); |
} |
-void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSCalcValue> c) |
+void CSSPrimitiveValue::CSSLargePrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSCalcValue> c) |
{ |
m_primitiveUnitType = CSS_CALC; |
m_hasCachedCSSText = false; |
m_value.calc = c.leakRef(); |
} |
-void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSBasicShape> shape) |
+void CSSPrimitiveValue::CSSLargePrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSBasicShape> shape) |
{ |
m_primitiveUnitType = CSS_SHAPE; |
m_hasCachedCSSText = false; |
m_value.shape = shape.leakRef(); |
} |
-CSSPrimitiveValue::~CSSPrimitiveValue() |
+CSSPrimitiveValue::CSSLargePrimitiveValue::~CSSLargePrimitiveValue() |
{ |
cleanup(); |
} |
-void CSSPrimitiveValue::cleanup() |
+void CSSPrimitiveValue::CSSLargePrimitiveValue::cleanup() |
{ |
- switch (static_cast<UnitType>(m_primitiveUnitType)) { |
+ switch (m_primitiveUnitType) { |
case CSS_CUSTOM_IDENT: |
case CSS_STRING: |
case CSS_URI: |
@@ -484,7 +493,7 @@ void CSSPrimitiveValue::cleanup() |
double CSSPrimitiveValue::computeSeconds() |
{ |
ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime)); |
- UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->primitiveType() : static_cast<UnitType>(m_primitiveUnitType); |
+ UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->primitiveType() : type(); |
if (currentType == CSS_S) |
return getDoubleValue(); |
if (currentType == CSS_MS) |
@@ -496,7 +505,7 @@ double CSSPrimitiveValue::computeSeconds() |
double CSSPrimitiveValue::computeDegrees() const |
{ |
ASSERT(isAngle() || (isCalculated() && cssCalcValue()->category() == CalcAngle)); |
- UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->primitiveType() : static_cast<UnitType>(m_primitiveUnitType); |
+ UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->primitiveType() : type(); |
switch (currentType) { |
case CSS_DEG: |
return getDoubleValue(); |
@@ -552,8 +561,8 @@ double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c |
// The logic in this function is duplicated in MediaValues::computeLength |
// because MediaValues::computeLength needs nearly identical logic, but we haven't found a way to make |
// CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases) without hurting performance. |
- if (m_primitiveUnitType == CSS_CALC) |
- return m_value.calc->computeLengthPx(conversionData); |
+ if (type() == CSS_CALC) |
+ return value().calc->computeLengthPx(conversionData); |
double factor; |
@@ -623,14 +632,14 @@ void CSSPrimitiveValue::accumulateLengthArray(CSSLengthArray& lengthArray, CSSLe |
{ |
ASSERT(lengthArray.size() == LengthUnitTypeCount); |
- if (m_primitiveUnitType == CSS_CALC) { |
+ if (type() == CSS_CALC) { |
cssCalcValue()->accumulateLengthArray(lengthArray, lengthTypeArray, multiplier); |
return; |
} |
LengthUnitType lengthType; |
- if (unitTypeToLengthUnitType(static_cast<UnitType>(m_primitiveUnitType), lengthType)) { |
- lengthArray.at(lengthType) += m_value.num * conversionToCanonicalUnitsScaleFactor(static_cast<UnitType>(m_primitiveUnitType)) * multiplier; |
+ if (unitTypeToLengthUnitType(type(), lengthType)) { |
+ lengthArray.at(lengthType) += value().num * conversionToCanonicalUnitsScaleFactor(type()) * multiplier; |
lengthTypeArray.set(lengthType); |
} |
} |
@@ -708,7 +717,7 @@ Length CSSPrimitiveValue::convertToLength(const CSSToLengthConversionData& conve |
double CSSPrimitiveValue::getDoubleValue() const |
{ |
- return m_primitiveUnitType != CSS_CALC ? m_value.num : m_value.calc->doubleValue(); |
+ return type() != CSS_CALC ? value().num : value().calc->doubleValue(); |
} |
CSSPrimitiveValue::UnitType CSSPrimitiveValue::canonicalUnitTypeForCategory(UnitCategory category) |
@@ -810,16 +819,16 @@ CSSPrimitiveValue::UnitType CSSPrimitiveValue::lengthUnitTypeToUnitType(LengthUn |
String CSSPrimitiveValue::getStringValue() const |
{ |
- switch (m_primitiveUnitType) { |
+ switch (type()) { |
case CSS_CUSTOM_IDENT: |
case CSS_STRING: |
case CSS_ATTR: |
case CSS_URI: |
- return m_value.string; |
+ return value().string; |
case CSS_VALUE_ID: |
- return valueName(m_value.valueID); |
+ return valueName(value().valueID); |
case CSS_PROPERTY_ID: |
- return propertyName(m_value.propertyID); |
+ return propertyName(value().propertyID); |
default: |
break; |
} |
@@ -937,13 +946,13 @@ const char* CSSPrimitiveValue::unitTypeToString(UnitType type) |
String CSSPrimitiveValue::customCSSText() const |
{ |
- if (m_hasCachedCSSText) { |
- ASSERT(cssTextCache().contains(this)); |
- return cssTextCache().get(this); |
+ if (hasCachedCSSText()) { |
+ ASSERT(cssTextCache().contains(m_rawValue)); |
+ return cssTextCache().get(m_rawValue); |
} |
String text; |
- switch (m_primitiveUnitType) { |
+ switch (type()) { |
case CSS_UNKNOWN: |
// FIXME |
break; |
@@ -978,29 +987,29 @@ String CSSPrimitiveValue::customCSSText() const |
case CSS_VH: |
case CSS_VMIN: |
case CSS_VMAX: |
- text = formatNumber(m_value.num, unitTypeToString((UnitType)m_primitiveUnitType)); |
+ text = formatNumber(value().num, unitTypeToString((UnitType)type())); |
break; |
case CSS_CUSTOM_IDENT: |
- text = quoteCSSStringIfNeeded(m_value.string); |
+ text = quoteCSSStringIfNeeded(value().string); |
break; |
case CSS_STRING: { |
- text = serializeString(m_value.string); |
+ text = serializeString(value().string); |
break; |
} |
case CSS_URI: |
- text = "url(" + quoteCSSURLIfNeeded(m_value.string) + ")"; |
+ text = "url(" + quoteCSSURLIfNeeded(value().string) + ")"; |
break; |
case CSS_VALUE_ID: |
- text = valueName(m_value.valueID); |
+ text = valueName(value().valueID); |
break; |
case CSS_PROPERTY_ID: |
- text = propertyName(m_value.propertyID); |
+ text = propertyName(value().propertyID); |
break; |
case CSS_ATTR: { |
StringBuilder result; |
- result.reserveCapacity(6 + m_value.string->length()); |
+ result.reserveCapacity(6 + value().string->length()); |
result.appendLiteral("attr("); |
- result.append(m_value.string); |
+ result.append(value().string); |
result.append(')'); |
text = result.toString(); |
@@ -1008,19 +1017,19 @@ String CSSPrimitiveValue::customCSSText() const |
} |
case CSS_COUNTER: { |
StringBuilder result; |
- String separator = m_value.counter->separator(); |
+ String separator = value().counter->separator(); |
if (separator.isEmpty()) |
result.appendLiteral("counter("); |
else |
result.appendLiteral("counters("); |
- result.append(m_value.counter->identifier()); |
+ result.append(value().counter->identifier()); |
if (!separator.isEmpty()) { |
result.appendLiteral(", "); |
result.append(serializeString(separator)); |
} |
- String listStyle = m_value.counter->listStyle(); |
- bool isDefaultListStyle = m_value.counter->listStyleIdent() == CSSValueDecimal; |
+ String listStyle = value().counter->listStyle(); |
+ bool isDefaultListStyle = value().counter->listStyleIdent() == CSSValueDecimal; |
if (!listStyle.isEmpty() && !isDefaultListStyle) { |
result.appendLiteral(", "); |
result.append(listStyle); |
@@ -1037,32 +1046,34 @@ String CSSPrimitiveValue::customCSSText() const |
text = getQuadValue()->cssText(); |
break; |
case CSS_RGBCOLOR: { |
- text = Color(m_value.rgbcolor).serializedAsCSSComponentValue(); |
+ text = Color(value().rgbcolor).serializedAsCSSComponentValue(); |
break; |
} |
case CSS_PAIR: |
text = getPairValue()->cssText(); |
break; |
case CSS_CALC: |
- text = m_value.calc->cssText(); |
+ text = value().calc->cssText(); |
break; |
case CSS_SHAPE: |
- text = m_value.shape->cssText(); |
+ text = value().shape->cssText(); |
+ break; |
+ default: |
break; |
} |
- ASSERT(!cssTextCache().contains(this)); |
- cssTextCache().set(this, text); |
- m_hasCachedCSSText = true; |
+ ASSERT(!cssTextCache().contains(m_rawValue)); |
+ cssTextCache().set(m_rawValue, text); |
+ setHasCachedCSSText(true); |
return text; |
} |
-bool CSSPrimitiveValue::equals(const CSSPrimitiveValue& other) const |
+bool CSSPrimitiveValue::equals(const CSSPrimitiveValue other) const |
{ |
- if (m_primitiveUnitType != other.m_primitiveUnitType) |
+ if (type() != other.type()) |
return false; |
- switch (m_primitiveUnitType) { |
+ switch (type()) { |
case CSS_UNKNOWN: |
return false; |
case CSS_NUMBER: |
@@ -1092,35 +1103,37 @@ bool CSSPrimitiveValue::equals(const CSSPrimitiveValue& other) const |
case CSS_VMIN: |
case CSS_VMAX: |
case CSS_FR: |
- return m_value.num == other.m_value.num; |
+ return value().num == other.value().num; |
case CSS_PROPERTY_ID: |
- return m_value.propertyID == other.m_value.propertyID; |
+ return value().propertyID == other.value().propertyID; |
case CSS_VALUE_ID: |
- return m_value.valueID == other.m_value.valueID; |
+ return value().valueID == other.value().valueID; |
case CSS_CUSTOM_IDENT: |
case CSS_STRING: |
case CSS_URI: |
case CSS_ATTR: |
- return equal(m_value.string, other.m_value.string); |
+ return equal(value().string, other.value().string); |
case CSS_COUNTER: |
- return m_value.counter && other.m_value.counter && m_value.counter->equals(*other.m_value.counter); |
+ return value().counter && other.value().counter && value().counter->equals(*other.value().counter); |
case CSS_RECT: |
- return m_value.rect && other.m_value.rect && m_value.rect->equals(*other.m_value.rect); |
+ return value().rect && other.value().rect && value().rect->equals(*other.value().rect); |
case CSS_QUAD: |
- return m_value.quad && other.m_value.quad && m_value.quad->equals(*other.m_value.quad); |
+ return value().quad && other.value().quad && value().quad->equals(*other.value().quad); |
case CSS_RGBCOLOR: |
- return m_value.rgbcolor == other.m_value.rgbcolor; |
+ return value().rgbcolor == other.value().rgbcolor; |
case CSS_PAIR: |
- return m_value.pair && other.m_value.pair && m_value.pair->equals(*other.m_value.pair); |
+ return value().pair && other.value().pair && value().pair->equals(*other.value().pair); |
case CSS_CALC: |
- return m_value.calc && other.m_value.calc && m_value.calc->equals(*other.m_value.calc); |
+ return value().calc && other.value().calc && value().calc->equals(*other.value().calc); |
case CSS_SHAPE: |
- return m_value.shape && other.m_value.shape && m_value.shape->equals(*other.m_value.shape); |
+ return value().shape && other.value().shape && value().shape->equals(*other.value().shape); |
+ default: |
+ break; |
} |
return false; |
} |
-DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) |
+DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue::CSSLargePrimitiveValue) |
{ |
#if ENABLE(OILPAN) |
switch (m_primitiveUnitType) { |