Generate toCSSFooValue for CSSPrimitiveValue

https://bugs.webkit.org/show_bug.cgi?id=122101

Reviewed by Antti Koivisto.

As a step of clean-up static_cast<> in CSSValues, this patch generates
toCSSFooPrimitiveValue() in order to detect bad casts as well as improves
code readability.

No new tests, no behavior changes.

* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule):
* css/CSSImageGeneratorValue.cpp:
(WebCore::CSSImageGeneratorValue::subimageIsPending):
(WebCore::CSSImageGeneratorValue::cachedImageForCSSValue):
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::fillImageSet):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseColor):
(WebCore::CSSParser::addProperty):
(WebCore::CSSParser::parse3ValuesFillPosition):
(WebCore::CSSParser::parseFillPosition):
(WebCore::CSSParser::parseFillRepeat):
(WebCore::CSSParser::parseDeprecatedRadialGradient):
(WebCore::CSSParser::parseRadialGradient):
* css/CSSPrimitiveValue.h:
* css/CSSToStyleMap.cpp:
(WebCore::CSSToStyleMap::mapFillAttachment):
(WebCore::CSSToStyleMap::mapFillClip):
(WebCore::CSSToStyleMap::mapFillComposite):
(WebCore::CSSToStyleMap::mapFillBlendMode):
(WebCore::CSSToStyleMap::mapFillOrigin):
(WebCore::CSSToStyleMap::mapFillRepeatX):
(WebCore::CSSToStyleMap::mapFillRepeatY):
(WebCore::CSSToStyleMap::mapFillSize):
(WebCore::CSSToStyleMap::mapFillXPosition):
(WebCore::CSSToStyleMap::mapFillYPosition):
(WebCore::CSSToStyleMap::mapFillMaskSourceType):
(WebCore::CSSToStyleMap::mapAnimationDelay):
(WebCore::CSSToStyleMap::mapAnimationDirection):
(WebCore::CSSToStyleMap::mapAnimationDuration):
(WebCore::CSSToStyleMap::mapAnimationFillMode):
(WebCore::CSSToStyleMap::mapAnimationIterationCount):
(WebCore::CSSToStyleMap::mapAnimationName):
(WebCore::CSSToStyleMap::mapAnimationPlayState):
(WebCore::CSSToStyleMap::mapAnimationProperty):
(WebCore::CSSToStyleMap::mapAnimationTimingFunction):
(WebCore::CSSToStyleMap::mapNinePieceImageQuad):
(WebCore::CSSToStyleMap::mapNinePieceImageRepeat):
* css/CSSValue.cpp:
(WebCore::CSSValue::destroy):
* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyDefault::applyValue):
(WebCore::ApplyPropertyNumber::applyValue):
(WebCore::ApplyPropertyAuto::applyValue):
(WebCore::ApplyPropertyClip::applyValue):
(WebCore::ApplyPropertyColor::applyValue):
(WebCore::ApplyPropertyLength::applyValue):
(WebCore::ApplyPropertyString::applyValue):
(WebCore::ApplyPropertyBorderRadius::applyValue):
(WebCore::ApplyPropertyComputeLength::applyValue):
(WebCore::ApplyPropertyFont::applyValue):
(WebCore::ApplyPropertyFontFamily::applyValue):
(WebCore::ApplyPropertyFontSize::applyValue):
(WebCore::ApplyPropertyFontWeight::applyValue):
(WebCore::ApplyPropertyFontVariantLigatures::applyValue):
(WebCore::ApplyPropertyCounter::applyValue):
(WebCore::ApplyPropertyCursor::applyValue):
(WebCore::ApplyPropertyTextAlign::applyValue):
(WebCore::ApplyPropertyTextDecoration::applyValue):
(WebCore::ApplyPropertyMarqueeIncrement::applyValue):
(WebCore::ApplyPropertyMarqueeRepetition::applyValue):
(WebCore::ApplyPropertyMarqueeSpeed::applyValue):
(WebCore::ApplyPropertyTextUnderlinePosition::applyValue):
(WebCore::ApplyPropertyLineHeight::applyValue):
(WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue):
(WebCore::ApplyPropertyPageSize::applyValue):
(WebCore::ApplyPropertyTextEmphasisStyle::applyValue):
(WebCore::ApplyPropertyResize::applyValue):
(WebCore::ApplyPropertyVerticalAlign::applyValue):
(WebCore::ApplyPropertyZoom::applyValue):
(WebCore::ApplyPropertyDisplay::applyValue):
(WebCore::ApplyPropertyClipPath::applyValue):
(WebCore::ApplyPropertyShape::applyValue):
(WebCore::ApplyPropertyImageResolution::applyValue):
(WebCore::ApplyPropertyTextIndent::applyValue):
* css/MediaList.cpp:
(WebCore::reportMediaQueryWarningIfNeeded):
* css/MediaQueryEvaluator.cpp:
(WebCore::numberValue):
(WebCore::orientationMediaFeatureEval):
(WebCore::evalResolution):
(WebCore::device_pixel_ratioMediaFeatureEval):
(WebCore::resolutionMediaFeatureEval):
(WebCore::computeLength):
(WebCore::view_modeMediaFeatureEval):
(WebCore::pointerMediaFeatureEval):
* css/SVGCSSStyleSelector.cpp:
(WebCore::StyleResolver::applySVGProperty):
* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::getLayeredShorthandValue):
* css/StyleResolver.cpp:
(WebCore::createGridTrackSize):
(WebCore::createGridTrackList):
(WebCore::createGridPosition):
(WebCore::hasVariableReference):
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::parseCustomFilterArrayParameter):
(WebCore::StyleResolver::parseCustomFilterColorParameter):
(WebCore::StyleResolver::parseCustomFilterNumberParameter):
(WebCore::StyleResolver::parseCustomFilterParameter):
(WebCore::StyleResolver::parseCustomFilterParameterList):
(WebCore::StyleResolver::createCustomFilterOperationWithInlineSyntax):
(WebCore::StyleResolver::createFilterOperations):
* css/TransformFunctions.cpp:
(WebCore::transformsForValue):
* css/ViewportStyleResolver.cpp:
(WebCore::ViewportStyleResolver::getViewportArgumentValue):
* css/WebKitCSSMatrix.cpp:
(WebCore::WebKitCSSMatrix::setMatrixValue):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::computedFontSize):
* editing/EditingStyle.cpp:
(WebCore::identifierForStyleProperty):
(WebCore::HTMLElementEquivalent::valueIsPresentInStyle):
(WebCore::cssValueToRGBA):
(WebCore::EditingStyle::extractFontSizeDelta):
(WebCore::EditingStyle::textDirection):
(WebCore::EditingStyle::prepareToApplyAt):
(WebCore::EditingStyle::mergeStyleFromRulesForSerialization):
(WebCore::EditingStyle::legacyFontSize):
(WebCore::EditingStyle::textDirectionForSelection):
(WebCore::StyleChange::extractTextStyles):
(WebCore::fontWeightIsBold):
(WebCore::isTransparentColorValue):
* editing/markup.cpp:
(WebCore::propertyMissingOrEqualToNone):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156705 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bf3cc985
2013-10-01 Gyuyoung Kim <gyuyoung.kim@samsung.com>
Generate toCSSFooValue for CSSPrimitiveValue
https://bugs.webkit.org/show_bug.cgi?id=122101
Reviewed by Antti Koivisto.
As a step of clean-up static_cast<> in CSSValues, this patch generates
toCSSFooPrimitiveValue() in order to detect bad casts as well as improves
code readability.
No new tests, no behavior changes.
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule):
* css/CSSImageGeneratorValue.cpp:
(WebCore::CSSImageGeneratorValue::subimageIsPending):
(WebCore::CSSImageGeneratorValue::cachedImageForCSSValue):
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::fillImageSet):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseColor):
(WebCore::CSSParser::addProperty):
(WebCore::CSSParser::parse3ValuesFillPosition):
(WebCore::CSSParser::parseFillPosition):
(WebCore::CSSParser::parseFillRepeat):
(WebCore::CSSParser::parseDeprecatedRadialGradient):
(WebCore::CSSParser::parseRadialGradient):
* css/CSSPrimitiveValue.h:
* css/CSSToStyleMap.cpp:
(WebCore::CSSToStyleMap::mapFillAttachment):
(WebCore::CSSToStyleMap::mapFillClip):
(WebCore::CSSToStyleMap::mapFillComposite):
(WebCore::CSSToStyleMap::mapFillBlendMode):
(WebCore::CSSToStyleMap::mapFillOrigin):
(WebCore::CSSToStyleMap::mapFillRepeatX):
(WebCore::CSSToStyleMap::mapFillRepeatY):
(WebCore::CSSToStyleMap::mapFillSize):
(WebCore::CSSToStyleMap::mapFillXPosition):
(WebCore::CSSToStyleMap::mapFillYPosition):
(WebCore::CSSToStyleMap::mapFillMaskSourceType):
(WebCore::CSSToStyleMap::mapAnimationDelay):
(WebCore::CSSToStyleMap::mapAnimationDirection):
(WebCore::CSSToStyleMap::mapAnimationDuration):
(WebCore::CSSToStyleMap::mapAnimationFillMode):
(WebCore::CSSToStyleMap::mapAnimationIterationCount):
(WebCore::CSSToStyleMap::mapAnimationName):
(WebCore::CSSToStyleMap::mapAnimationPlayState):
(WebCore::CSSToStyleMap::mapAnimationProperty):
(WebCore::CSSToStyleMap::mapAnimationTimingFunction):
(WebCore::CSSToStyleMap::mapNinePieceImageQuad):
(WebCore::CSSToStyleMap::mapNinePieceImageRepeat):
* css/CSSValue.cpp:
(WebCore::CSSValue::destroy):
* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyDefault::applyValue):
(WebCore::ApplyPropertyNumber::applyValue):
(WebCore::ApplyPropertyAuto::applyValue):
(WebCore::ApplyPropertyClip::applyValue):
(WebCore::ApplyPropertyColor::applyValue):
(WebCore::ApplyPropertyLength::applyValue):
(WebCore::ApplyPropertyString::applyValue):
(WebCore::ApplyPropertyBorderRadius::applyValue):
(WebCore::ApplyPropertyComputeLength::applyValue):
(WebCore::ApplyPropertyFont::applyValue):
(WebCore::ApplyPropertyFontFamily::applyValue):
(WebCore::ApplyPropertyFontSize::applyValue):
(WebCore::ApplyPropertyFontWeight::applyValue):
(WebCore::ApplyPropertyFontVariantLigatures::applyValue):
(WebCore::ApplyPropertyCounter::applyValue):
(WebCore::ApplyPropertyCursor::applyValue):
(WebCore::ApplyPropertyTextAlign::applyValue):
(WebCore::ApplyPropertyTextDecoration::applyValue):
(WebCore::ApplyPropertyMarqueeIncrement::applyValue):
(WebCore::ApplyPropertyMarqueeRepetition::applyValue):
(WebCore::ApplyPropertyMarqueeSpeed::applyValue):
(WebCore::ApplyPropertyTextUnderlinePosition::applyValue):
(WebCore::ApplyPropertyLineHeight::applyValue):
(WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue):
(WebCore::ApplyPropertyPageSize::applyValue):
(WebCore::ApplyPropertyTextEmphasisStyle::applyValue):
(WebCore::ApplyPropertyResize::applyValue):
(WebCore::ApplyPropertyVerticalAlign::applyValue):
(WebCore::ApplyPropertyZoom::applyValue):
(WebCore::ApplyPropertyDisplay::applyValue):
(WebCore::ApplyPropertyClipPath::applyValue):
(WebCore::ApplyPropertyShape::applyValue):
(WebCore::ApplyPropertyImageResolution::applyValue):
(WebCore::ApplyPropertyTextIndent::applyValue):
* css/MediaList.cpp:
(WebCore::reportMediaQueryWarningIfNeeded):
* css/MediaQueryEvaluator.cpp:
(WebCore::numberValue):
(WebCore::orientationMediaFeatureEval):
(WebCore::evalResolution):
(WebCore::device_pixel_ratioMediaFeatureEval):
(WebCore::resolutionMediaFeatureEval):
(WebCore::computeLength):
(WebCore::view_modeMediaFeatureEval):
(WebCore::pointerMediaFeatureEval):
* css/SVGCSSStyleSelector.cpp:
(WebCore::StyleResolver::applySVGProperty):
* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::getLayeredShorthandValue):
* css/StyleResolver.cpp:
(WebCore::createGridTrackSize):
(WebCore::createGridTrackList):
(WebCore::createGridPosition):
(WebCore::hasVariableReference):
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::parseCustomFilterArrayParameter):
(WebCore::StyleResolver::parseCustomFilterColorParameter):
(WebCore::StyleResolver::parseCustomFilterNumberParameter):
(WebCore::StyleResolver::parseCustomFilterParameter):
(WebCore::StyleResolver::parseCustomFilterParameterList):
(WebCore::StyleResolver::createCustomFilterOperationWithInlineSyntax):
(WebCore::StyleResolver::createFilterOperations):
* css/TransformFunctions.cpp:
(WebCore::transformsForValue):
* css/ViewportStyleResolver.cpp:
(WebCore::ViewportStyleResolver::getViewportArgumentValue):
* css/WebKitCSSMatrix.cpp:
(WebCore::WebKitCSSMatrix::setMatrixValue):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::computedFontSize):
* editing/EditingStyle.cpp:
(WebCore::identifierForStyleProperty):
(WebCore::HTMLElementEquivalent::valueIsPresentInStyle):
(WebCore::cssValueToRGBA):
(WebCore::EditingStyle::extractFontSizeDelta):
(WebCore::EditingStyle::textDirection):
(WebCore::EditingStyle::prepareToApplyAt):
(WebCore::EditingStyle::mergeStyleFromRulesForSerialization):
(WebCore::EditingStyle::legacyFontSize):
(WebCore::EditingStyle::textDirectionForSelection):
(WebCore::StyleChange::extractTextStyles):
(WebCore::fontWeightIsBold):
(WebCore::isTransparentColorValue):
* editing/markup.cpp:
(WebCore::propertyMissingOrEqualToNone):
2013-10-01 Darin Adler <darin@apple.com>
Try to fix AVFoundation crashes seen on Lion bot.
......@@ -115,7 +115,7 @@ void CSSFontSelector::addFontFaceRule(const StyleRuleFontFace* fontFaceRule)
if (!fontStyle->isPrimitiveValue())
return;
switch (static_cast<CSSPrimitiveValue*>(fontStyle.get())->getValueID()) {
switch (toCSSPrimitiveValue(fontStyle.get())->getValueID()) {
case CSSValueNormal:
traitsMask |= FontStyleNormalMask;
break;
......@@ -133,7 +133,7 @@ void CSSFontSelector::addFontFaceRule(const StyleRuleFontFace* fontFaceRule)
if (!fontWeight->isPrimitiveValue())
return;
switch (static_cast<CSSPrimitiveValue*>(fontWeight.get())->getValueID()) {
switch (toCSSPrimitiveValue(fontWeight.get())->getValueID()) {
case CSSValueBold:
case CSSValue700:
traitsMask |= FontWeight700Mask;
......@@ -184,7 +184,7 @@ void CSSFontSelector::addFontFaceRule(const StyleRuleFontFace* fontFaceRule)
return;
for (unsigned i = 0; i < numVariants; ++i) {
switch (static_cast<CSSPrimitiveValue*>(variantList->itemWithoutBoundsCheck(i))->getValueID()) {
switch (toCSSPrimitiveValue(variantList->itemWithoutBoundsCheck(i))->getValueID()) {
case CSSValueNormal:
traitsMask |= FontVariantNormalMask;
break;
......@@ -264,7 +264,7 @@ void CSSFontSelector::addFontFaceRule(const StyleRuleFontFace* fontFaceRule)
// Hash under every single family name.
int familyLength = familyList->length();
for (int i = 0; i < familyLength; i++) {
CSSPrimitiveValue* item = static_cast<CSSPrimitiveValue*>(familyList->itemWithoutBoundsCheck(i));
CSSPrimitiveValue* item = toCSSPrimitiveValue(familyList->itemWithoutBoundsCheck(i));
String familyName;
if (item->isString()) {
familyName = item->getStringValue();
......
......@@ -62,10 +62,8 @@ PassRefPtr<Image> CSSGradientValue::image(RenderElement* renderer, const IntSize
if (isLinearGradientValue())
gradient = toCSSLinearGradientValue(this)->createGradient(renderer, size);
else {
ASSERT(isRadialGradientValue());
else
gradient = toCSSRadialGradientValue(this)->createGradient(renderer, size);
}
RefPtr<GradientImage> newImage = GradientImage::create(gradient, size);
if (cacheable)
......
......@@ -242,7 +242,7 @@ bool CSSImageGeneratorValue::subimageIsPending(CSSValue* value)
if (value->isImageGeneratorValue())
return static_cast<CSSImageGeneratorValue*>(value)->isPending();
if (value->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(value)->getValueID() == CSSValueNone)
if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNone)
return false;
ASSERT_NOT_REACHED();
......@@ -269,7 +269,7 @@ CachedImage* CSSImageGeneratorValue::cachedImageForCSSValue(CSSValue* value, Cac
return 0;
}
if (value->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(value)->getValueID() == CSSValueNone)
if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNone)
return 0;
ASSERT_NOT_REACHED();
......
......@@ -67,7 +67,7 @@ void CSSImageSetValue::fillImageSet()
ASSERT_WITH_SECURITY_IMPLICATION(i < length);
CSSValue* scaleFactorValue = item(i);
ASSERT_WITH_SECURITY_IMPLICATION(scaleFactorValue->isPrimitiveValue());
float scaleFactor = static_cast<CSSPrimitiveValue*>(scaleFactorValue)->getFloatValue();
float scaleFactor = toCSSPrimitiveValue(scaleFactorValue)->getFloatValue();
ImageWithScale image;
image.imageURL = imageURL;
......
......@@ -1389,7 +1389,7 @@ bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict)
if (!value->isPrimitiveValue())
return false;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (!primitiveValue->isRGBColor())
return false;
......@@ -1587,7 +1587,7 @@ void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bo
// This property doesn't belong to a shorthand or is a CSS variable (which will be resolved later).
if (!m_currentShorthand
#if ENABLE(CSS_VARIABLES)
|| (value->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(value.get())->isVariableName())
|| (value->isPrimitiveValue() && toCSSPrimitiveValue(value.get())->isVariableName())
#endif
) {
m_parsedProperties.append(CSSProperty(propId, value, important, false, CSSPropertyInvalid, m_implicitShorthand || implicit));
......@@ -4126,8 +4126,8 @@ void CSSParser::parse3ValuesFillPosition(CSSParserValueList* valueList, RefPtr<C
value1.swap(value2);
#ifndef NDEBUG
CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(value1.get());
CSSPrimitiveValue* second = static_cast<CSSPrimitiveValue*>(value2.get());
CSSPrimitiveValue* first = toCSSPrimitiveValue(value1.get());
CSSPrimitiveValue* second = toCSSPrimitiveValue(value2.get());
ident1 = first->getPairValue()->first()->getValueID();
ident2 = second->getPairValue()->first()->getValueID();
ASSERT(ident1 == CSSValueLeft || ident1 == CSSValueRight);
......@@ -4187,8 +4187,8 @@ void CSSParser::parseFillPosition(CSSParserValueList* valueList, RefPtr<CSSValue
return;
}
RefPtr<CSSPrimitiveValue> parsedValue1 = static_cast<CSSPrimitiveValue*>(value1.get());
RefPtr<CSSPrimitiveValue> parsedValue2 = static_cast<CSSPrimitiveValue*>(value2.get());
RefPtr<CSSPrimitiveValue> parsedValue1 = toCSSPrimitiveValue(value1.get());
RefPtr<CSSPrimitiveValue> parsedValue2 = toCSSPrimitiveValue(value2.get());
value1.clear();
value2.clear();
......@@ -4285,7 +4285,7 @@ void CSSParser::parseFillRepeat(RefPtr<CSSValue>& value1, RefPtr<CSSValue>& valu
// If only one value was specified, value2 is the same as value1.
m_implicitShorthand = true;
value2 = cssValuePool().createIdentifierValue(static_cast<CSSPrimitiveValue*>(value1.get())->getValueID());
value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1.get())->getValueID());
}
PassRefPtr<CSSValue> CSSParser::parseFillSize(CSSPropertyID propId, bool& allowComma)
......@@ -7709,11 +7709,11 @@ bool CSSParser::parseDeprecatedRadialGradient(CSSParserValueList* valueList, Ref
ASSERT(!centerX || centerX->isPrimitiveValue());
ASSERT(!centerY || centerY->isPrimitiveValue());
result->setFirstX(static_cast<CSSPrimitiveValue*>(centerX.get()));
result->setSecondX(static_cast<CSSPrimitiveValue*>(centerX.get()));
result->setFirstX(toCSSPrimitiveValue(centerX.get()));
result->setSecondX(toCSSPrimitiveValue(centerX.get()));
// CSS3 radial gradients always share the same start and end point.
result->setFirstY(static_cast<CSSPrimitiveValue*>(centerY.get()));
result->setSecondY(static_cast<CSSPrimitiveValue*>(centerY.get()));
result->setFirstY(toCSSPrimitiveValue(centerY.get()));
result->setSecondY(toCSSPrimitiveValue(centerY.get()));
RefPtr<CSSPrimitiveValue> shapeValue;
RefPtr<CSSPrimitiveValue> sizeValue;
......@@ -7973,11 +7973,11 @@ bool CSSParser::parseRadialGradient(CSSParserValueList* valueList, RefPtr<CSSVal
a = args->current();
if (!a)
return false;
result->setFirstX(static_cast<CSSPrimitiveValue*>(centerX.get()));
result->setFirstY(static_cast<CSSPrimitiveValue*>(centerY.get()));
result->setFirstX(toCSSPrimitiveValue(centerX.get()));
result->setFirstY(toCSSPrimitiveValue(centerY.get()));
// Right now, CSS radial gradients have the same start and end centers.
result->setSecondX(static_cast<CSSPrimitiveValue*>(centerX.get()));
result->setSecondY(static_cast<CSSPrimitiveValue*>(centerY.get()));
result->setSecondX(toCSSPrimitiveValue(centerX.get()));
result->setSecondY(toCSSPrimitiveValue(centerY.get()));
}
if (shapeValue || sizeValue || horizontalSize || centerX || centerY)
......
......@@ -401,17 +401,8 @@ private:
} m_value;
};
inline CSSPrimitiveValue* toCSSPrimitiveValue(CSSValue* value)
{
ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isPrimitiveValue());
return static_cast<CSSPrimitiveValue*>(value);
}
CSS_VALUE_TYPE_CASTS(PrimitiveValue)
inline const CSSPrimitiveValue* toCSSPrimitiveValue(const CSSValue* value)
{
ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isPrimitiveValue());
return static_cast<const CSSPrimitiveValue*>(value);
}
} // namespace WebCore
......
......@@ -71,8 +71,7 @@ void CSSToStyleMap::mapFillAttachment(CSSPropertyID, FillLayer* layer, CSSValue*
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
switch (primitiveValue->getValueID()) {
switch (toCSSPrimitiveValue(value)->getValueID()) {
case CSSValueFixed:
layer->setAttachment(FixedBackgroundAttachment);
break;
......@@ -97,7 +96,7 @@ void CSSToStyleMap::mapFillClip(CSSPropertyID, FillLayer* layer, CSSValue* value
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
layer->setClip(*primitiveValue);
}
......@@ -111,7 +110,7 @@ void CSSToStyleMap::mapFillComposite(CSSPropertyID, FillLayer* layer, CSSValue*
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
layer->setComposite(*primitiveValue);
}
......@@ -125,7 +124,7 @@ void CSSToStyleMap::mapFillBlendMode(CSSPropertyID, FillLayer* layer, CSSValue*
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
layer->setBlendMode(*primitiveValue);
}
......@@ -139,7 +138,7 @@ void CSSToStyleMap::mapFillOrigin(CSSPropertyID, FillLayer* layer, CSSValue* val
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
layer->setOrigin(*primitiveValue);
}
......@@ -164,7 +163,7 @@ void CSSToStyleMap::mapFillRepeatX(CSSPropertyID, FillLayer* layer, CSSValue* va
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
layer->setRepeatX(*primitiveValue);
}
......@@ -178,7 +177,7 @@ void CSSToStyleMap::mapFillRepeatY(CSSPropertyID, FillLayer* layer, CSSValue* va
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
layer->setRepeatY(*primitiveValue);
}
......@@ -189,7 +188,7 @@ void CSSToStyleMap::mapFillSize(CSSPropertyID, FillLayer* layer, CSSValue* value
return;
}
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (primitiveValue->getValueID() == CSSValueContain)
layer->setSizeType(Contain);
else if (primitiveValue->getValueID() == CSSValueCover)
......@@ -239,7 +238,7 @@ void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer* layer,
float zoomFactor = style()->effectiveZoom();
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
Pair* pair = primitiveValue->getPairValue();
if (pair) {
ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionX || propertyID == CSSPropertyWebkitMaskPositionX);
......@@ -275,7 +274,7 @@ void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer,
float zoomFactor = style()->effectiveZoom();
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
Pair* pair = primitiveValue->getPairValue();
if (pair) {
ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionY || propertyID == CSSPropertyWebkitMaskPositionY);
......@@ -310,7 +309,7 @@ void CSSToStyleMap::mapFillMaskSourceType(CSSPropertyID, FillLayer* layer, CSSVa
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
switch (primitiveValue->getValueID()) {
case CSSValueAlpha:
type = EMaskSourceType::MaskAlpha;
......@@ -337,7 +336,7 @@ void CSSToStyleMap::mapAnimationDelay(Animation* animation, CSSValue* value)
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
animation->setDelay(primitiveValue->computeTime<double, CSSPrimitiveValue::Seconds>());
}
......@@ -351,7 +350,7 @@ void CSSToStyleMap::mapAnimationDirection(Animation* layer, CSSValue* value)
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
switch (primitiveValue->getValueID()) {
case CSSValueNormal:
layer->setDirection(Animation::AnimationDirectionNormal);
......@@ -380,7 +379,7 @@ void CSSToStyleMap::mapAnimationDuration(Animation* animation, CSSValue* value)
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
animation->setDuration(primitiveValue->computeTime<double, CSSPrimitiveValue::Seconds>());
}
......@@ -394,7 +393,7 @@ void CSSToStyleMap::mapAnimationFillMode(Animation* layer, CSSValue* value)
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
switch (primitiveValue->getValueID()) {
case CSSValueNone:
layer->setFillMode(AnimationFillModeNone);
......@@ -423,7 +422,7 @@ void CSSToStyleMap::mapAnimationIterationCount(Animation* animation, CSSValue* v
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (primitiveValue->getValueID() == CSSValueInfinite)
animation->setIterationCount(Animation::IterationCountInfinite);
else
......@@ -440,7 +439,7 @@ void CSSToStyleMap::mapAnimationName(Animation* layer, CSSValue* value)
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (primitiveValue->getValueID() == CSSValueNone)
layer->setIsNoneAnimation(true);
else
......@@ -457,7 +456,7 @@ void CSSToStyleMap::mapAnimationPlayState(Animation* layer, CSSValue* value)
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
EAnimPlayState playState = (primitiveValue->getValueID() == CSSValuePaused) ? AnimPlayStatePaused : AnimPlayStatePlaying;
layer->setPlayState(playState);
}
......@@ -473,7 +472,7 @@ void CSSToStyleMap::mapAnimationProperty(Animation* animation, CSSValue* value)
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (primitiveValue->getValueID() == CSSValueAll) {
animation->setAnimationMode(Animation::AnimateAll);
animation->setProperty(CSSPropertyInvalid);
......@@ -494,7 +493,7 @@ void CSSToStyleMap::mapAnimationTimingFunction(Animation* animation, CSSValue* v
}
if (value->isPrimitiveValue()) {
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
switch (primitiveValue->getValueID()) {
case CSSValueLinear:
animation->setTimingFunction(LinearTimingFunction::create());
......@@ -637,7 +636,7 @@ LengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value)
float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom();
// Retrieve the primitive value.
CSSPrimitiveValue* borderWidths = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* borderWidths = toCSSPrimitiveValue(value);
// Set up a length box to represent our image slices.
LengthBox box; // Defaults to 'auto' so we don't have to handle that explicitly below.
......@@ -678,7 +677,7 @@ void CSSToStyleMap::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& ima
if (!value || !value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
Pair* pair = primitiveValue->getPairValue();
if (!pair || !pair->first() || !pair->second())
return;
......
......@@ -425,7 +425,7 @@ void CSSValue::destroy()
delete toCSSInitialValue(this);
return;
case PrimitiveClass:
delete static_cast<CSSPrimitiveValue*>(this);
delete toCSSPrimitiveValue(this);
return;
case ReflectClass:
delete toCSSReflectValue(this);
......
......@@ -149,7 +149,7 @@ public:
static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
{
if (value->isPrimitiveValue())
setValue(styleResolver->style(), *static_cast<CSSPrimitiveValue*>(value));
setValue(styleResolver->style(), *toCSSPrimitiveValue(value));
}
static PropertyHandler createHandler()
{
......@@ -167,7 +167,7 @@ public:
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (primitiveValue->getValueID() == idMapsToMinusOne)
setValue(styleResolver->style(), -1);
else
......@@ -215,7 +215,7 @@ public:
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (primitiveValue->getValueID() == autoIdentity)
setAuto(styleResolver->style());
else if (valueType == Number)
......@@ -254,7 +254,7 @@ public:
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (Rect* rect = primitiveValue->getRectValue()) {
Length top = convertToLength(styleResolver, rect->top());
......@@ -300,7 +300,7 @@ public:
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (inheritColorFromParent && primitiveValue->getValueID() == CSSValueCurrentcolor)
applyInheritValue(propertyID, styleResolver);
else {
......@@ -361,7 +361,7 @@ public:
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (noneEnabled && primitiveValue->getValueID() == CSSValueNone) {
if (noneUndefined)
setValue(styleResolver->style(), Length(Undefined));
......@@ -415,7 +415,7 @@ public:
{
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if ((identBehavior == MapNoneToNull && primitiveValue->getValueID() == CSSValueNone)
|| (identBehavior == MapAutoToNull && primitiveValue->getValueID() == CSSValueAuto))
setValue(styleResolver->style(), nullAtom);
......@@ -438,7 +438,7 @@ public:
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
Pair* pair = primitiveValue->getPairValue();
if (!pair || !pair->first() || !pair->second())
return;
......@@ -601,7 +601,7 @@ public:
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
CSSValueID ident = primitiveValue->getValueID();
T length;
......@@ -661,7 +661,7 @@ public:
{
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
FontDescription fontDescription = styleResolver->fontDescription();
(fontDescription.*setterFunction)(*primitiveValue);
styleResolver->setFontDescription(fontDescription);
......@@ -715,7 +715,7 @@ public:
CSSValue* item = i.value();
if (!item->isPrimitiveValue())
continue;
CSSPrimitiveValue* contentValue = static_cast<CSSPrimitiveValue*>(item);
CSSPrimitiveValue* contentValue = toCSSPrimitiveValue(item);
AtomicString face;
if (contentValue->isString())
face = contentValue->getStringValue();
......@@ -825,7 +825,7 @@ public:
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
FontDescription fontDescription = styleResolver->style()->fontDescription();
fontDescription.setKeywordSize(0);
......@@ -899,7 +899,7 @@ public:
{
if (!value->isPrimitiveValue())
return;