| Index: Source/core/css/CSSPrimitiveValue.cpp
|
| diff --git a/Source/core/css/CSSPrimitiveValue.cpp b/Source/core/css/CSSPrimitiveValue.cpp
|
| index 2e0f2f04a920e990172d3ef652fd0a0584da416d..f5ea90eb86e9ddbf5de35b1ff58a49cfeaa32721 100644
|
| --- a/Source/core/css/CSSPrimitiveValue.cpp
|
| +++ b/Source/core/css/CSSPrimitiveValue.cpp
|
| @@ -168,13 +168,16 @@ static CSSTextCache& cssTextCache()
|
|
|
| CSSPrimitiveValue::UnitType CSSPrimitiveValue::primitiveType() const
|
| {
|
| - if (type() == CSS_PROPERTY_ID || type() == CSS_VALUE_ID)
|
| + CSSPrimitiveValue::UnitType unitType = type();
|
| +
|
| + if (unitType == CSS_PROPERTY_ID || unitType == CSS_VALUE_ID)
|
| return CSS_IDENT;
|
|
|
| - if (type() != CSS_CALC)
|
| - return type();
|
| + if (unitType != CSS_CALC)
|
| + return unitType;
|
|
|
| - switch (value().calc->category()) {
|
| + ASSERT(!isTaggedPtr());
|
| + switch (m_value.calc->category()) {
|
| case CalcAngle:
|
| return CSS_DEG;
|
| case CalcFrequency:
|
| @@ -406,7 +409,7 @@ void CSSPrimitiveValue::cleanup()
|
| if (isTaggedPtr())
|
| return;
|
|
|
| - switch (type()) {
|
| + switch (m_primitiveUnitType) {
|
| case CSS_CUSTOM_IDENT:
|
| case CSS_STRING:
|
| case CSS_URI:
|
| @@ -569,8 +572,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 (type() == CSS_CALC)
|
| - return value().calc->computeLengthPx(conversionData);
|
| + if (!isTaggedPtr() && m_primitiveUnitType == CSS_CALC)
|
| + return m_value.calc->computeLengthPx(conversionData);
|
|
|
| double factor;
|
|
|
| @@ -640,14 +643,15 @@ void CSSPrimitiveValue::accumulateLengthArray(CSSLengthArray& lengthArray, CSSLe
|
| {
|
| ASSERT(lengthArray.size() == LengthUnitTypeCount);
|
|
|
| - if (type() == CSS_CALC) {
|
| + if (!isTaggedPtr() && m_primitiveUnitType == CSS_CALC) {
|
| cssCalcValue()->accumulateLengthArray(lengthArray, lengthTypeArray, multiplier);
|
| return;
|
| }
|
|
|
| LengthUnitType lengthType;
|
| - if (unitTypeToLengthUnitType(type(), lengthType)) {
|
| - lengthArray.at(lengthType) += value().num * conversionToCanonicalUnitsScaleFactor(type()) * multiplier;
|
| + CSSPrimitiveValue::UnitType unitType = type();
|
| + if (unitTypeToLengthUnitType(unitType, lengthType)) {
|
| + lengthArray.at(lengthType) += numValue() * conversionToCanonicalUnitsScaleFactor(unitType) * multiplier;
|
| lengthTypeArray.set(lengthType);
|
| }
|
| }
|
| @@ -727,7 +731,7 @@ double CSSPrimitiveValue::getCalcDoubleValue() const
|
| {
|
| ASSERT(!isTaggedPtr());
|
| ASSERT(m_primitiveUnitType == CSS_CALC);
|
| - return value().calc->doubleValue();
|
| + return m_value.calc->doubleValue();
|
| }
|
|
|
| CSSPrimitiveValue::UnitType CSSPrimitiveValue::canonicalUnitTypeForCategory(UnitCategory category)
|
| @@ -834,11 +838,11 @@ String CSSPrimitiveValue::getStringValue() const
|
| case CSS_STRING:
|
| case CSS_ATTR:
|
| case CSS_URI:
|
| - return value().string;
|
| + return m_value.string;
|
| case CSS_VALUE_ID:
|
| - return valueName(value().valueID);
|
| + return valueName(valueIDValue());
|
| case CSS_PROPERTY_ID:
|
| - return propertyName(value().propertyID);
|
| + return propertyName(propertyIDValue());
|
| default:
|
| break;
|
| }
|
| @@ -965,7 +969,8 @@ String CSSPrimitiveValue::customCSSText() const
|
| }
|
|
|
| String text;
|
| - switch (type()) {
|
| + CSSPrimitiveValue::UnitType unitType = type();
|
| + switch (unitType) {
|
| case CSS_UNKNOWN:
|
| // FIXME
|
| break;
|
| @@ -1000,29 +1005,29 @@ String CSSPrimitiveValue::customCSSText() const
|
| case CSS_VH:
|
| case CSS_VMIN:
|
| case CSS_VMAX:
|
| - text = formatNumber(value().num, unitTypeToString(type()));
|
| + text = formatNumber(numValue(), unitTypeToString(unitType));
|
| break;
|
| case CSS_CUSTOM_IDENT:
|
| - text = quoteCSSStringIfNeeded(value().string);
|
| + text = quoteCSSStringIfNeeded(m_value.string);
|
| break;
|
| case CSS_STRING: {
|
| - text = serializeString(value().string);
|
| + text = serializeString(m_value.string);
|
| break;
|
| }
|
| case CSS_URI:
|
| - text = "url(" + quoteCSSURLIfNeeded(value().string) + ")";
|
| + text = "url(" + quoteCSSURLIfNeeded(m_value.string) + ")";
|
| break;
|
| case CSS_VALUE_ID:
|
| - text = valueName(value().valueID);
|
| + text = valueName(valueIDValue());
|
| break;
|
| case CSS_PROPERTY_ID:
|
| - text = propertyName(value().propertyID);
|
| + text = propertyName(propertyIDValue());
|
| break;
|
| case CSS_ATTR: {
|
| StringBuilder result;
|
| - result.reserveCapacity(6 + value().string->length());
|
| + result.reserveCapacity(6 + m_value.string->length());
|
| result.appendLiteral("attr(");
|
| - result.append(value().string);
|
| + result.append(m_value.string);
|
| result.append(')');
|
|
|
| text = result.toString();
|
| @@ -1030,19 +1035,19 @@ String CSSPrimitiveValue::customCSSText() const
|
| }
|
| case CSS_COUNTER: {
|
| StringBuilder result;
|
| - String separator = value().counter->separator();
|
| + String separator = m_value.counter->separator();
|
| if (separator.isEmpty())
|
| result.appendLiteral("counter(");
|
| else
|
| result.appendLiteral("counters(");
|
|
|
| - result.append(value().counter->identifier());
|
| + result.append(m_value.counter->identifier());
|
| if (!separator.isEmpty()) {
|
| result.appendLiteral(", ");
|
| result.append(serializeString(separator));
|
| }
|
| - String listStyle = value().counter->listStyle();
|
| - bool isDefaultListStyle = value().counter->listStyleIdent() == CSSValueDecimal;
|
| + String listStyle = m_value.counter->listStyle();
|
| + bool isDefaultListStyle = m_value.counter->listStyleIdent() == CSSValueDecimal;
|
| if (!listStyle.isEmpty() && !isDefaultListStyle) {
|
| result.appendLiteral(", ");
|
| result.append(listStyle);
|
| @@ -1059,17 +1064,17 @@ String CSSPrimitiveValue::customCSSText() const
|
| text = getQuadValue()->cssText();
|
| break;
|
| case CSS_RGBCOLOR: {
|
| - text = Color(value().rgbcolor).serializedAsCSSComponentValue();
|
| + text = Color(rgbcolorValue()).serializedAsCSSComponentValue();
|
| break;
|
| }
|
| case CSS_PAIR:
|
| text = getPairValue()->cssText();
|
| break;
|
| case CSS_CALC:
|
| - text = value().calc->cssText();
|
| + text = m_value.calc->cssText();
|
| break;
|
| case CSS_SHAPE:
|
| - text = value().shape->cssText();
|
| + text = m_value.shape->cssText();
|
| break;
|
| case CSS_IDENT:
|
| case CSS_CALC_PERCENTAGE_WITH_NUMBER:
|
| @@ -1087,10 +1092,16 @@ String CSSPrimitiveValue::customCSSText() const
|
|
|
| bool CSSPrimitiveValue::equals(const CSSPrimitiveValue& other) const
|
| {
|
| - if (type() != other.type())
|
| + if (isTaggedPtr() && other.isTaggedPtr())
|
| + return this == &other;
|
| +
|
| + CSSPrimitiveValue::UnitType thisType = type();
|
| + CSSPrimitiveValue::UnitType otherType = other.type();
|
| +
|
| + if (thisType != otherType)
|
| return false;
|
|
|
| - switch (type()) {
|
| + switch (thisType) {
|
| case CSS_UNKNOWN:
|
| return false;
|
| case CSS_NUMBER:
|
| @@ -1120,30 +1131,30 @@ bool CSSPrimitiveValue::equals(const CSSPrimitiveValue& other) const
|
| case CSS_VMIN:
|
| case CSS_VMAX:
|
| case CSS_FR:
|
| - return value().num == other.value().num;
|
| + return numValue() == other.numValue();
|
| case CSS_PROPERTY_ID:
|
| - return value().propertyID == other.value().propertyID;
|
| + return propertyIDValue() == other.propertyIDValue();
|
| case CSS_VALUE_ID:
|
| - return value().valueID == other.value().valueID;
|
| + return valueIDValue() == other.valueIDValue();
|
| case CSS_CUSTOM_IDENT:
|
| case CSS_STRING:
|
| case CSS_URI:
|
| case CSS_ATTR:
|
| - return equal(value().string, other.value().string);
|
| + return equal(m_value.string, other.m_value.string);
|
| case CSS_COUNTER:
|
| - return value().counter && other.value().counter && value().counter->equals(*other.value().counter);
|
| + return m_value.counter && other.m_value.counter && m_value.counter->equals(*other.m_value.counter);
|
| case CSS_RECT:
|
| - return value().rect && other.value().rect && value().rect->equals(*other.value().rect);
|
| + return m_value.pair && other.m_value.pair && m_value.pair->equals(*other.m_value.pair);
|
| case CSS_QUAD:
|
| - return value().quad && other.value().quad && value().quad->equals(*other.value().quad);
|
| + return m_value.quad && other.m_value.quad && m_value.quad->equals(*other.m_value.quad);
|
| case CSS_RGBCOLOR:
|
| - return value().rgbcolor == other.value().rgbcolor;
|
| + return rgbcolorValue() == other.rgbcolorValue();
|
| case CSS_PAIR:
|
| - return value().pair && other.value().pair && value().pair->equals(*other.value().pair);
|
| + return m_value.pair && other.m_value.pair && m_value.pair->equals(*other.m_value.pair);
|
| case CSS_CALC:
|
| - return value().calc && other.value().calc && value().calc->equals(*other.value().calc);
|
| + return m_value.calc && other.m_value.calc && m_value.calc->equals(*other.m_value.calc);
|
| case CSS_SHAPE:
|
| - return value().shape && other.value().shape && value().shape->equals(*other.value().shape);
|
| + return m_value.shape && other.m_value.shape && m_value.shape->equals(*other.m_value.shape);
|
| case CSS_IDENT:
|
| case CSS_INTEGER:
|
| case CSS_CHS:
|
| @@ -1158,27 +1169,29 @@ bool CSSPrimitiveValue::equals(const CSSPrimitiveValue& other) const
|
| DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue)
|
| {
|
| #if ENABLE(OILPAN)
|
| - switch (type()) {
|
| - case CSS_COUNTER:
|
| - visitor->trace(value().counter);
|
| - break;
|
| - case CSS_RECT:
|
| - visitor->trace(value().rect);
|
| - break;
|
| - case CSS_QUAD:
|
| - visitor->trace(value().quad);
|
| - break;
|
| - case CSS_PAIR:
|
| - visitor->trace(value().pair);
|
| - break;
|
| - case CSS_CALC:
|
| - visitor->trace(value().calc);
|
| - break;
|
| - case CSS_SHAPE:
|
| - visitor->trace(value().shape);
|
| - break;
|
| - default:
|
| - break;
|
| + if (!isTaggedPtr()) {
|
| + switch (m_type) {
|
| + case CSS_COUNTER:
|
| + visitor->trace(m_value.counter);
|
| + break;
|
| + case CSS_RECT:
|
| + visitor->trace(m_value.pair);
|
| + break;
|
| + case CSS_QUAD:
|
| + visitor->trace(m_value.quad);
|
| + break;
|
| + case CSS_PAIR:
|
| + visitor->trace(m_value.pair);
|
| + break;
|
| + case CSS_CALC:
|
| + visitor->trace(m_value.calc);
|
| + break;
|
| + case CSS_SHAPE:
|
| + visitor->trace(m_value.shape);
|
| + break;
|
| + default:
|
| + break;
|
| + }
|
| }
|
| #endif
|
| CSSValue::traceAfterDispatch(visitor);
|
|
|