Index: Source/core/css/StylePropertySerializer.cpp |
diff --git a/Source/core/css/StylePropertySerializer.cpp b/Source/core/css/StylePropertySerializer.cpp |
index 9e68e609c48ccba72814a3820b38d1edf3e04bdb..5b5a459a5efcd4206d47933aaaddec447a9fdca9 100644 |
--- a/Source/core/css/StylePropertySerializer.cpp |
+++ b/Source/core/css/StylePropertySerializer.cpp |
@@ -55,7 +55,7 @@ StylePropertySerializer::StylePropertySetForSerializer::StylePropertySetForSeria |
continue; |
if (static_cast<unsigned>(m_allIndex) >= i) |
continue; |
- if (property.value()->equals(*allProperty.value()) |
+ if (property.value().equals(allProperty.value()) |
&& property.isImportant() == allProperty.isImportant()) |
continue; |
m_needToExpandAll = true; |
@@ -128,11 +128,11 @@ int StylePropertySerializer::StylePropertySetForSerializer::findPropertyIndex(CS |
return propertyID - firstCSSProperty; |
} |
-const CSSValue* StylePropertySerializer::StylePropertySetForSerializer::getPropertyCSSValue(CSSPropertyID propertyID) const |
+const NullableCSSValue StylePropertySerializer::StylePropertySetForSerializer::getPropertyCSSValue(CSSPropertyID propertyID) const |
{ |
int index = findPropertyIndex(propertyID); |
if (index == -1) |
- return 0; |
+ return nullptr; |
StylePropertySerializer::PropertyValueForSerializer value = propertyAt(index); |
return value.value(); |
} |
@@ -142,7 +142,7 @@ String StylePropertySerializer::StylePropertySetForSerializer::getPropertyValue( |
if (!hasExpandedAllProperty()) |
return m_propertySet.getPropertyValue(propertyID); |
- const CSSValue* value = getPropertyCSSValue(propertyID); |
+ const NullableCSSValue value = getPropertyCSSValue(propertyID); |
if (!value) |
return String(); |
return value->cssText(); |
@@ -338,7 +338,7 @@ String StylePropertySerializer::asText() const |
shorthandPropertyID = CSSPropertyWebkitMask; |
break; |
case CSSPropertyAll: |
- result.append(getPropertyText(propertyID, property.value()->cssText(), property.isImportant(), numDecls++)); |
+ result.append(getPropertyText(propertyID, property.value().cssText(), property.isImportant(), numDecls++)); |
continue; |
default: |
break; |
@@ -361,9 +361,9 @@ String StylePropertySerializer::asText() const |
} else { |
// We should not show "initial" when the "initial" is implicit. |
// If explicit "initial", we need to show. |
- if (property.value()->isImplicitInitialValue()) |
+ if (property.value().isImplicitInitialValue()) |
continue; |
- value = property.value()->cssText(); |
+ value = property.value().cssText(); |
} |
result.append(getPropertyText(propertyID, value, property.isImportant(), numDecls++)); |
@@ -449,7 +449,7 @@ String StylePropertySerializer::getPropertyValue(CSSPropertyID propertyID) const |
case CSSPropertyWebkitTextStroke: |
return getShorthandValue(webkitTextStrokeShorthand()); |
case CSSPropertyMarker: { |
- if (const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropertyMarkerStart)) |
+ if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSPropertyMarkerStart)) |
return value->cssText(); |
return String(); |
} |
@@ -462,8 +462,8 @@ String StylePropertySerializer::getPropertyValue(CSSPropertyID propertyID) const |
String StylePropertySerializer::borderSpacingValue(const StylePropertyShorthand& shorthand) const |
{ |
- const CSSValue* horizontalValue = m_propertySet.getPropertyCSSValue(shorthand.properties()[0]); |
- const CSSValue* verticalValue = m_propertySet.getPropertyCSSValue(shorthand.properties()[1]); |
+ const NullableCSSValue horizontalValue = m_propertySet.getPropertyCSSValue(shorthand.properties()[0]); |
+ const NullableCSSValue verticalValue = m_propertySet.getPropertyCSSValue(shorthand.properties()[1]); |
// While standard border-spacing property does not allow specifying border-spacing-vertical without |
// specifying border-spacing-horizontal <http://www.w3.org/TR/CSS21/tables.html#separated-borders>, |
@@ -484,8 +484,8 @@ void StylePropertySerializer::appendFontLonghandValueIfNotNormal(CSSPropertyID p |
if (foundPropertyIndex == -1) |
return; |
- const CSSValue* val = m_propertySet.propertyAt(foundPropertyIndex).value(); |
- if (val->isPrimitiveValue() && toCSSPrimitiveValue(val)->getValueID() == CSSValueNormal) { |
+ const CSSValue val = m_propertySet.propertyAt(foundPropertyIndex).value(); |
+ if (val.isPrimitiveValue() && toCSSPrimitiveValue(val).getValueID() == CSSValueNormal) { |
commonValue = String(); |
return; |
} |
@@ -509,7 +509,7 @@ void StylePropertySerializer::appendFontLonghandValueIfNotNormal(CSSPropertyID p |
if (prefix && !result.isEmpty()) |
result.append(prefix); |
- String value = m_propertySet.propertyAt(foundPropertyIndex).value()->cssText(); |
+ String value = m_propertySet.propertyAt(foundPropertyIndex).value().cssText(); |
result.append(value); |
if (!commonValue.isNull() && commonValue != value) |
commonValue = String(); |
@@ -525,7 +525,7 @@ String StylePropertySerializer::fontValue() const |
PropertyValueForSerializer fontSizeProperty = m_propertySet.propertyAt(fontSizePropertyIndex); |
PropertyValueForSerializer fontFamilyProperty = m_propertySet.propertyAt(fontFamilyPropertyIndex); |
- String commonValue = fontSizeProperty.value()->cssText(); |
+ String commonValue = fontSizeProperty.value().cssText(); |
StringBuilder result; |
appendFontLonghandValueIfNotNormal(CSSPropertyFontStyle, result, commonValue); |
appendFontLonghandValueIfNotNormal(CSSPropertyFontVariant, result, commonValue); |
@@ -533,11 +533,11 @@ String StylePropertySerializer::fontValue() const |
appendFontLonghandValueIfNotNormal(CSSPropertyFontStretch, result, commonValue); |
if (!result.isEmpty()) |
result.append(' '); |
- result.append(fontSizeProperty.value()->cssText()); |
+ result.append(fontSizeProperty.value().cssText()); |
appendFontLonghandValueIfNotNormal(CSSPropertyLineHeight, result, commonValue); |
if (!result.isEmpty()) |
result.append(' '); |
- result.append(fontFamilyProperty.value()->cssText()); |
+ result.append(fontFamilyProperty.value().cssText()); |
if (isInitialOrInherit(commonValue)) |
return commonValue; |
return result.toString(); |
@@ -559,39 +559,35 @@ String StylePropertySerializer::get4Values(const StylePropertyShorthand& shortha |
PropertyValueForSerializer bottom = m_propertySet.propertyAt(bottomValueIndex); |
PropertyValueForSerializer left = m_propertySet.propertyAt(leftValueIndex); |
- // All 4 properties must be specified. |
- if (!top.value() || !right.value() || !bottom.value() || !left.value()) |
- return String(); |
- |
if (top.isImportant() != right.isImportant() || right.isImportant() != bottom.isImportant() || bottom.isImportant() != left.isImportant()) |
return String(); |
if (top.isInherited() && right.isInherited() && bottom.isInherited() && left.isInherited()) |
return getValueName(CSSValueInherit); |
- unsigned numInitial = top.value()->isInitialValue() + right.value()->isInitialValue() + bottom.value()->isInitialValue() + left.value()->isInitialValue(); |
+ unsigned numInitial = top.value().isInitialValue() + right.value().isInitialValue() + bottom.value().isInitialValue() + left.value().isInitialValue(); |
if (numInitial == 4) |
return getValueName(CSSValueInitial); |
if (numInitial > 0) |
return String(); |
- bool showLeft = !right.value()->equals(*left.value()); |
- bool showBottom = !top.value()->equals(*bottom.value()) || showLeft; |
- bool showRight = !top.value()->equals(*right.value()) || showBottom; |
+ bool showLeft = !right.value().equals(left.value()); |
+ bool showBottom = !top.value().equals(bottom.value()) || showLeft; |
+ bool showRight = !top.value().equals(right.value()) || showBottom; |
StringBuilder result; |
- result.append(top.value()->cssText()); |
+ result.append(top.value().cssText()); |
if (showRight) { |
result.append(' '); |
- result.append(right.value()->cssText()); |
+ result.append(right.value().cssText()); |
} |
if (showBottom) { |
result.append(' '); |
- result.append(bottom.value()->cssText()); |
+ result.append(bottom.value().cssText()); |
} |
if (showLeft) { |
result.append(' '); |
- result.append(left.value()->cssText()); |
+ result.append(left.value().cssText()); |
} |
return result.toString(); |
} |
@@ -601,7 +597,7 @@ String StylePropertySerializer::getLayeredShorthandValue(const StylePropertyShor |
const unsigned size = shorthand.length(); |
// Begin by collecting the properties into a vector. |
- WillBeHeapVector<const CSSValue*> values(size); |
+ WillBeHeapVector<NullableCSSValue> values(size); |
// If the below loop succeeds, there should always be at minimum 1 layer. |
size_t numLayers = 1U; |
@@ -620,7 +616,7 @@ String StylePropertySerializer::getLayeredShorthandValue(const StylePropertyShor |
// Tracks whether or not all the values are initial or all the values are inherit. |
// Start out assuming there is a common value. It will get set to false below if there isn't one. |
bool hasCommonValue = true; |
- const CSSValue* commonValue = nullptr; |
+ NullableCSSValue commonValue = nullptr; |
// Now stitch the properties together. Implicit initial values are flagged as such and |
// can safely be omitted. |
@@ -632,7 +628,7 @@ String StylePropertySerializer::getLayeredShorthandValue(const StylePropertyShor |
bool foundPositionYCSSProperty = false; |
for (unsigned propertyIndex = 0; propertyIndex < size; propertyIndex++) { |
- const CSSValue* value = nullptr; |
+ NullableCSSValue value = nullptr; |
CSSPropertyID property = shorthand.properties()[propertyIndex]; |
// Get a CSSValue for this property and layer. |
@@ -653,7 +649,7 @@ String StylePropertySerializer::getLayeredShorthandValue(const StylePropertyShor |
&& (property == CSSPropertyBackgroundRepeatX || property == CSSPropertyWebkitMaskRepeatX)) { |
ASSERT(shorthand.properties()[propertyIndex + 1] == CSSPropertyBackgroundRepeatY |
|| shorthand.properties()[propertyIndex + 1] == CSSPropertyWebkitMaskRepeatY); |
- const CSSValue* yValue = values[propertyIndex + 1]->isValueList() ? |
+ NullableCSSValue yValue = values[propertyIndex + 1]->isValueList() ? |
toCSSValueList(values[propertyIndex + 1])->item(layer) : values[propertyIndex + 1]; |
@@ -731,7 +727,7 @@ String StylePropertySerializer::getShorthandValue(const StylePropertyShorthand& |
String commonValue; |
StringBuilder result; |
for (unsigned i = 0; i < shorthand.length(); ++i) { |
- const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]); |
+ const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]); |
if (!value) |
return String(); |
String valueText = value->cssText(); |
@@ -756,7 +752,7 @@ String StylePropertySerializer::getCommonValue(const StylePropertyShorthand& sho |
String res; |
bool lastPropertyWasImportant = false; |
for (unsigned i = 0; i < shorthand.length(); ++i) { |
- const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]); |
+ const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]); |
// FIXME: CSSInitialValue::cssText should generate the right value. |
if (!value) |
return String(); |
@@ -827,8 +823,8 @@ static void appendBackgroundRepeatValue(StringBuilder& builder, const CSSValue& |
String StylePropertySerializer::backgroundRepeatPropertyValue() const |
{ |
- const CSSValue* repeatX = m_propertySet.getPropertyCSSValue(CSSPropertyBackgroundRepeatX); |
- const CSSValue* repeatY = m_propertySet.getPropertyCSSValue(CSSPropertyBackgroundRepeatY); |
+ const NullableCSSValue repeatX = m_propertySet.getPropertyCSSValue(CSSPropertyBackgroundRepeatX); |
+ const NullableCSSValue repeatY = m_propertySet.getPropertyCSSValue(CSSPropertyBackgroundRepeatY); |
if (!repeatX || !repeatY) |
return String(); |
if (m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX) != m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatY)) |
@@ -860,9 +856,9 @@ String StylePropertySerializer::backgroundRepeatPropertyValue() const |
if (i) |
builder.appendLiteral(", "); |
- const CSSValue* xValue = repeatXList ? repeatXList->item(i % repeatXList->length()) : repeatX; |
- const CSSValue* yValue = repeatYList ? repeatYList->item(i % repeatYList->length()) : repeatY; |
- appendBackgroundRepeatValue(builder, *xValue, *yValue); |
+ const CSSValue xValue = repeatXList ? repeatXList->item(i % repeatXList->length()) : *repeatX; |
+ const CSSValue yValue = repeatYList ? repeatYList->item(i % repeatYList->length()) : *repeatY; |
+ appendBackgroundRepeatValue(builder, xValue, yValue); |
} |
return builder.toString(); |
} |
@@ -876,7 +872,8 @@ void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu |
return; |
} |
if (shorthandHasOnlyInitialOrInheritedValue(backgroundShorthand())) { |
- const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropertyBackgroundImage); |
+ const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSPropertyBackgroundImage); |
+ ASSERT(value); |
bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgroundImage); |
result.append(getPropertyText(CSSPropertyBackground, value->cssText(), isImportant, numDecls++)); |
return; |
@@ -894,7 +891,7 @@ void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu |
for (unsigned i = 0; i < WTF_ARRAY_LENGTH(backgroundPropertyIds); ++i) { |
CSSPropertyID propertyID = backgroundPropertyIds[i]; |
- const CSSValue* value = m_propertySet.getPropertyCSSValue(propertyID); |
+ const NullableCSSValue value = m_propertySet.getPropertyCSSValue(propertyID); |
if (!value) |
continue; |
result.append(getPropertyText(propertyID, value->cssText(), m_propertySet.propertyIsImportant(propertyID), numDecls++)); |
@@ -905,7 +902,8 @@ void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu |
// would not work in Firefox (<rdar://problem/5143183>) |
// It would be a better solution if background-position was CSS_PAIR. |
if (shorthandHasOnlyInitialOrInheritedValue(backgroundPositionShorthand())) { |
- const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropertyBackgroundPositionX); |
+ const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSPropertyBackgroundPositionX); |
+ ASSERT(value); |
bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgroundPositionX); |
result.append(getPropertyText(CSSPropertyBackgroundPosition, value->cssText(), isImportant, numDecls++)); |
} else if (isPropertyShorthandAvailable(backgroundPositionShorthand())) { |
@@ -915,14 +913,14 @@ void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu |
result.append(getPropertyText(CSSPropertyBackgroundPosition, positionValue, isImportant, numDecls++)); |
} else { |
// should check background-position-x or background-position-y. |
- if (const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropertyBackgroundPositionX)) { |
- if (!value->isImplicitInitialValue()) { |
+ if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSPropertyBackgroundPositionX)) { |
+ if (value && !value->isImplicitInitialValue()) { |
bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgroundPositionX); |
result.append(getPropertyText(CSSPropertyBackgroundPositionX, value->cssText(), isImportant, numDecls++)); |
} |
} |
- if (const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropertyBackgroundPositionY)) { |
- if (!value->isImplicitInitialValue()) { |
+ if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSPropertyBackgroundPositionY)) { |
+ if (value && !value->isImplicitInitialValue()) { |
bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgroundPositionY); |
result.append(getPropertyText(CSSPropertyBackgroundPositionY, value->cssText(), isImportant, numDecls++)); |
} |
@@ -940,7 +938,7 @@ bool StylePropertySerializer::isPropertyShorthandAvailable(const StylePropertySh |
bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[0]); |
for (unsigned i = 0; i < shorthand.length(); ++i) { |
- const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]); |
+ const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]); |
if (!value || (value->isInitialValue() && !value->isImplicitInitialValue()) || value->isInheritedValue()) |
return false; |
if (isImportant != m_propertySet.propertyIsImportant(shorthand.properties()[i])) |
@@ -956,7 +954,7 @@ bool StylePropertySerializer::shorthandHasOnlyInitialOrInheritedValue(const Styl |
bool isInitialValue = true; |
bool isInheritedValue = true; |
for (unsigned i = 0; i < shorthand.length(); ++i) { |
- const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]); |
+ const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]); |
if (!value) |
return false; |
if (!value->isInitialValue()) |