Ignore:
Timestamp:
Sep 22, 2013, 6:20:19 PM (12 years ago)
Author:
[email protected]
Message:

Introduce CSS_VALUE_TYPE_CASTS macro in order to cast CSSValue type
https://bugs.webkit.org/show_bug.cgi?id=121462

Reviewed by Andreas Kling.

As r155429 introduced ELEMENT_TYPE_CASTS, CSS_VALUE_TYPE_CASTS can be used
by css value type casting as well. This type cast macros will help to detect
bad-cast bugs as well as improve a code readibility.

This patch adds the following methods,

  • CSSFooValue* toCSSFooValue(CSSValue*)
  • const CSSFooValue* toCSSFooValue(const CSSValue*)

To be consistent with other is*Value() naming style, isCSSLineBoxContainValue() and isCalculationValue()
are changed with isLineBoxContainValue() and isCalcValue().

FontValue, FontFeatureValue, ShadowValue have a manual type case function because of different
class naming style. So, toFontValue(), toFontFeatureValue() and toShadowValue() are added manually.

This patch removes unnecessary local variables.

No new tests, no behavior change.

  • css/CSSAspectRatioValue.h:
  • css/CSSBorderImageSliceValue.h:
  • css/CSSCalculationValue.cpp:

(WebCore::CSSCalcExpressionNodeParser::parseValue):

  • css/CSSCalculationValue.h:
  • css/CSSCrossfadeValue.cpp:

(WebCore::subimageKnownToBeOpaque):

  • css/CSSCrossfadeValue.h:
  • css/CSSCursorImageValue.cpp:

(WebCore::CSSCursorImageValue::~CSSCursorImageValue):
(WebCore::CSSCursorImageValue::updateIfSVGCursorIsUsed):
(WebCore::CSSCursorImageValue::cachedImage):
(WebCore::CSSCursorImageValue::cachedOrPendingImage):
(WebCore::CSSCursorImageValue::isSVGCursor):

  • css/CSSCursorImageValue.h:
  • css/CSSFilterImageValue.h:
  • css/CSSFontSelector.cpp:

(WebCore::CSSFontSelector::addFontFaceRule):

  • css/CSSGradientValue.h:
  • css/CSSImageGeneratorValue.cpp:

(WebCore::CSSImageGeneratorValue::image):
(WebCore::CSSImageGeneratorValue::fixedSize):
(WebCore::CSSImageGeneratorValue::loadSubimages):
(WebCore::CSSImageGeneratorValue::subimageIsPending):
(WebCore::CSSImageGeneratorValue::cachedImageForCSSValue):

  • css/CSSImageGeneratorValue.h:
  • css/CSSImageSetValue.cpp:

(WebCore::CSSImageSetValue::fillImageSet):

  • css/CSSImageSetValue.h:
  • css/CSSImageValue.h:
  • css/CSSInheritedValue.h:
  • css/CSSInitialValue.h:
  • css/CSSLineBoxContainValue.h:
  • 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/CSSReflectValue.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::mapNinePieceImageSlice):
(WebCore::CSSToStyleMap::mapNinePieceImageQuad):
(WebCore::CSSToStyleMap::mapNinePieceImageRepeat):

  • css/CSSValue.cpp:

(WebCore::CSSValue::destroy):

  • css/CSSValue.h:

(WebCore::CSSValue::isLineBoxContainValue):
(WebCore::CSSValue::isCalcValue):

  • css/CSSValueList.h:
  • css/CSSVariableValue.h:
  • 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::ApplyPropertyAspectRatio::applyValue):
(WebCore::ApplyPropertyZoom::applyValue):
(WebCore::ApplyPropertyDisplay::applyValue):
(WebCore::ApplyPropertyClipPath::applyValue):
(WebCore::ApplyPropertyShape::applyValue):
(WebCore::ApplyPropertyImageResolution::applyValue):
(WebCore::ApplyPropertyTextIndent::applyValue):

  • css/FontFeatureValue.h:

(WebCore::toFontFeatureValue):

  • css/FontValue.h:

(WebCore::toFontValue):

  • css/MediaList.cpp:

(WebCore::reportMediaQueryWarningIfNeeded):

  • css/MediaQueryEvaluator.cpp:

(WebCore::compareAspectRatioValue):
(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/ShadowValue.h:

(WebCore::toShadowValue):

  • css/StylePropertySet.cpp:

(WebCore::StylePropertySet::getLayeredShorthandValue):

  • css/StyleResolver.cpp:

(WebCore::createGridTrackSize):
(WebCore::createGridTrackList):
(WebCore::createGridPosition):
(WebCore::hasVariableReference):
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::styleImage):
(WebCore::StyleResolver::generatedOrPendingFromValue):
(WebCore::StyleResolver::styleShader):
(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):

  • css/WebKitCSSShaderValue.h:

(WebCore::toWebKitCSSShaderValue):

  • 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):

  • page/PageSerializer.cpp:

(WebCore::PageSerializer::retrieveResourcesForProperties):

  • rendering/style/StylePendingImage.h:

(WebCore::StylePendingImage::data):
(WebCore::StylePendingImage::cssImageValue):
(WebCore::StylePendingImage::cssImageGeneratorValue):
(WebCore::StylePendingImage::cssCursorImageValue):
(WebCore::StylePendingImage::cssImageSetValue):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSParser.cpp

    r156222 r156253  
    13901390        return false;
    13911391
    1392     CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     1392    CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
    13931393    if (!primitiveValue->isRGBColor())
    13941394        return false;
     
    15881588    if (!m_currentShorthand
    15891589#if ENABLE(CSS_VARIABLES)
    1590         || (value->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(value.get())->isVariableName())
     1590        || (value->isPrimitiveValue() && toCSSPrimitiveValue(value.get())->isVariableName())
    15911591#endif
    15921592        ) {
     
    41194119
    41204120#ifndef NDEBUG
    4121     CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(value1.get());
    4122     CSSPrimitiveValue* second = static_cast<CSSPrimitiveValue*>(value2.get());
     4121    CSSPrimitiveValue* first = toCSSPrimitiveValue(value1.get());
     4122    CSSPrimitiveValue* second = toCSSPrimitiveValue(value2.get());
    41234123    ident1 = first->getPairValue()->first()->getValueID();
    41244124    ident2 = second->getPairValue()->first()->getValueID();
     
    41804180    }
    41814181
    4182     RefPtr<CSSPrimitiveValue> parsedValue1 = static_cast<CSSPrimitiveValue*>(value1.get());
    4183     RefPtr<CSSPrimitiveValue> parsedValue2 = static_cast<CSSPrimitiveValue*>(value2.get());
     4182    RefPtr<CSSPrimitiveValue> parsedValue1 = toCSSPrimitiveValue(value1.get());
     4183    RefPtr<CSSPrimitiveValue> parsedValue2 = toCSSPrimitiveValue(value2.get());
    41844184
    41854185    value1.clear();
     
    42784278    // If only one value was specified, value2 is the same as value1.
    42794279    m_implicitShorthand = true;
    4280     value2 = cssValuePool().createIdentifierValue(static_cast<CSSPrimitiveValue*>(value1.get())->getValueID());
     4280    value2 = cssValuePool().createIdentifierValue(toCSSPrimitiveValue(value1.get())->getValueID());
    42814281}
    42824282
     
    77037703    ASSERT(!centerY || centerY->isPrimitiveValue());
    77047704
    7705     result->setFirstX(static_cast<CSSPrimitiveValue*>(centerX.get()));
    7706     result->setSecondX(static_cast<CSSPrimitiveValue*>(centerX.get()));
     7705    result->setFirstX(toCSSPrimitiveValue(centerX.get()));
     7706    result->setSecondX(toCSSPrimitiveValue(centerX.get()));
    77077707    // CSS3 radial gradients always share the same start and end point.
    7708     result->setFirstY(static_cast<CSSPrimitiveValue*>(centerY.get()));
    7709     result->setSecondY(static_cast<CSSPrimitiveValue*>(centerY.get()));
     7708    result->setFirstY(toCSSPrimitiveValue(centerY.get()));
     7709    result->setSecondY(toCSSPrimitiveValue(centerY.get()));
    77107710
    77117711    RefPtr<CSSPrimitiveValue> shapeValue;
     
    79677967        if (!a)
    79687968            return false;
    7969         result->setFirstX(static_cast<CSSPrimitiveValue*>(centerX.get()));
    7970         result->setFirstY(static_cast<CSSPrimitiveValue*>(centerY.get()));
     7969        result->setFirstX(toCSSPrimitiveValue(centerX.get()));
     7970        result->setFirstY(toCSSPrimitiveValue(centerY.get()));
    79717971        // Right now, CSS radial gradients have the same start and end centers.
    7972         result->setSecondX(static_cast<CSSPrimitiveValue*>(centerX.get()));
    7973         result->setSecondY(static_cast<CSSPrimitiveValue*>(centerY.get()));
     7972        result->setSecondX(toCSSPrimitiveValue(centerX.get()));
     7973        result->setSecondY(toCSSPrimitiveValue(centerY.get()));
    79747974    }
    79757975
Note: See TracChangeset for help on using the changeset viewer.