Skip to content

Commit 1860500

Browse files
committed
Clean up / Modernize the CSS Parser
https://bugs.webkit.org/show_bug.cgi?id=157961 Reviewed by Alex Christensen. Clean up / Modernize the CSS Parser. * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::valueForBasicShape): (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSBasicShapes.cpp: (WebCore::CSSBasicShapePolygon::cssText): (WebCore::CSSBasicShapePolygon::equals): * css/CSSBasicShapes.h: * css/CSSComputedStyleDeclaration.cpp: (WebCore::valueForReflection): (WebCore::ComputedStyleExtractor::valueForShadow): (WebCore::specifiedValueForGridTrackSize): * css/CSSCrossfadeValue.cpp: (WebCore::subimageKnownToBeOpaque): (WebCore::CSSCrossfadeValue::fixedSize): (WebCore::CSSCrossfadeValue::isPending): (WebCore::CSSCrossfadeValue::knownToBeOpaque): (WebCore::CSSCrossfadeValue::loadSubimages): (WebCore::CSSCrossfadeValue::image): (WebCore::CSSCrossfadeValue::blend): (WebCore::CSSCrossfadeValue::equals): (WebCore::CSSCrossfadeValue::equalInputImages): * css/CSSCrossfadeValue.h: (WebCore::CSSCrossfadeValue::create): (WebCore::CSSCrossfadeValue::CSSCrossfadeValue): * css/CSSCustomPropertyValue.h: (WebCore::CSSCustomPropertyValue::create): (WebCore::CSSCustomPropertyValue::CSSCustomPropertyValue): * css/CSSFilterImageValue.cpp: (WebCore::CSSFilterImageValue::fixedSize): (WebCore::CSSFilterImageValue::isPending): (WebCore::CSSFilterImageValue::loadSubimages): (WebCore::CSSFilterImageValue::image): (WebCore::CSSFilterImageValue::createFilterOperations): (WebCore::CSSFilterImageValue::equals): (WebCore::CSSFilterImageValue::equalInputImages): * css/CSSFilterImageValue.h: (WebCore::CSSFilterImageValue::CSSFilterImageValue): * css/CSSFontFaceSet.cpp: (WebCore::CSSFontFaceSet::matchingFaces): * css/CSSFunctionValue.cpp: (WebCore::CSSFunctionValue::CSSFunctionValue): * css/CSSFunctionValue.h: (WebCore::CSSFunctionValue::create): * css/CSSGradientValue.h: (WebCore::CSSLinearGradientValue::setAngle): * css/CSSGrammar.y.in: * css/CSSImageGeneratorValue.cpp: (WebCore::CSSImageGeneratorValue::subimageIsPending): (WebCore::CSSImageGeneratorValue::cachedImageForCSSValue): * css/CSSImageGeneratorValue.h: * css/CSSImageValue.cpp: (WebCore::CSSImageValue::cachedOrPendingImage): * css/CSSImageValue.h: * css/CSSKeyframesRule.cpp: (WebCore::StyleRuleKeyframes::StyleRuleKeyframes): (WebCore::StyleRuleKeyframes::parserAppendKeyframe): (WebCore::StyleRuleKeyframes::wrapperAppendKeyframe): (WebCore::CSSKeyframesRule::appendRule): (WebCore::CSSKeyframesRule::findRule): (WebCore::CSSKeyframesRule::item): (WebCore::StyleRuleKeyframes::~StyleRuleKeyframes): Deleted. * css/CSSKeyframesRule.h: (WebCore::StyleRuleKeyframes::keyframes): * css/CSSParser.cpp: (WebCore::parseColorValue): (WebCore::parseSimpleLengthValue): (WebCore::parseKeywordValue): (WebCore::parseTranslateTransformValue): (WebCore::CSSParser::parseFontFaceValue): (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseCustomPropertyValue): (WebCore::CSSParser::parseDeclaration): (WebCore::CSSParser::SourceSize::SourceSize): (WebCore::filterProperties): (WebCore::CSSParser::clearProperties): (WebCore::CSSParser::addExpandedPropertyForValue): (WebCore::CSSParser::parseVariableDependentValue): (WebCore::CSSParser::parseContentDistributionOverflowPosition): (WebCore::CSSParser::parseItemPositionOverflowPosition): (WebCore::CSSParser::parseNonElementSnapPoints): (WebCore::CSSParser::parseScrollSnapDestination): (WebCore::CSSParser::parseScrollSnapCoordinate): (WebCore::CSSParser::parseFillShorthand): (WebCore::CSSParser::addAnimationValue): (WebCore::CSSParser::parseAnimationShorthand): (WebCore::CSSParser::parseColumnWidth): (WebCore::CSSParser::parseColumnCount): (WebCore::CSSParser::parseColumnsShorthand): (WebCore::CSSParser::parseTransitionShorthand): (WebCore::CSSParser::parseSize): (WebCore::CSSParser::parseQuotes): (WebCore::CSSParser::parseAlt): (WebCore::CSSParser::parseCustomPropertyDeclaration): (WebCore::CSSParser::parseContent): (WebCore::CSSParser::parseAttr): (WebCore::CSSParser::parseBackgroundColor): (WebCore::CSSParser::parseFillPositionComponent): (WebCore::CSSParser::parse4ValuesFillPosition): (WebCore::CSSParser::parse3ValuesFillPosition): (WebCore::CSSParser::parseFillPosition): (WebCore::CSSParser::parseFillSize): (WebCore::CSSParser::parseFillProperty): (WebCore::CSSParser::parseAnimationDelay): (WebCore::CSSParser::parseAnimationDirection): (WebCore::CSSParser::parseAnimationDuration): (WebCore::CSSParser::parseAnimationFillMode): (WebCore::CSSParser::parseAnimationIterationCount): (WebCore::CSSParser::parseAnimationName): (WebCore::CSSParser::parseAnimationPlayState): (WebCore::CSSParser::parseAnimationTrigger): (WebCore::CSSParser::parseAnimationProperty): (WebCore::CSSParser::parseKeyframeSelector): (WebCore::CSSParser::parseGridPosition): (WebCore::gridMissingGridPositionValue): (WebCore::CSSParser::parseGridItemPositionShorthand): (WebCore::CSSParser::parseGridGapShorthand): (WebCore::CSSParser::parseGridTemplateRowsAndAreasAndColumns): (WebCore::CSSParser::parseGridTemplateShorthand): (WebCore::CSSParser::parseGridShorthand): (WebCore::CSSParser::parseGridAreaShorthand): (WebCore::CSSParser::parseGridLineNames): (WebCore::CSSParser::parseGridTrackList): (WebCore::CSSParser::parseGridTrackRepeatFunction): (WebCore::CSSParser::parseGridTrackSize): (WebCore::CSSParser::parseGridAutoFlow): (WebCore::skipCommaInDashboardRegion): (WebCore::CSSParser::parseDashboardRegions): (WebCore::parseGridTemplateAreasColumnNames): (WebCore::CSSParser::parseCounterContent): (WebCore::CSSParser::parseClipShape): (WebCore::CSSParser::parseInsetRoundedCorners): (WebCore::CSSParser::parseBasicShapeInset): (WebCore::CSSParser::parseBasicShapeCircle): (WebCore::CSSParser::parseBasicShapeEllipse): (WebCore::CSSParser::parseBasicShapePolygon): (WebCore::CSSParser::parseBasicShapePath): (WebCore::CSSParser::parseBasicShapeAndOrBox): (WebCore::CSSParser::parseFont): (WebCore::CSSParser::parseFontFamily): (WebCore::CSSParser::parseFontSynthesis): (WebCore::CSSParser::parseFontFaceSrcURI): (WebCore::CSSParser::parseFontFaceSrc): (WebCore::CSSParser::parseFontFaceUnicodeRange): (WebCore::parseAlphaValue): (WebCore::ShadowParseContext::commitValue): (WebCore::CSSParser::parseShadow): (WebCore::CSSParser::parseReflect): (WebCore::CSSParser::parseFlex): (WebCore::BorderImageParseContext::commitImage): (WebCore::BorderImageParseContext::commitImageSlice): (WebCore::BorderImageParseContext::commitBorderWidth): (WebCore::BorderImageParseContext::commitBorderOutset): (WebCore::BorderImageParseContext::commitRepeat): (WebCore::BorderImageParseContext::commitWebKitBorderImage): (WebCore::BorderImageParseContext::commitBorderImageProperty): (WebCore::CSSParser::parseBorderImage): (WebCore::CSSParser::parseBorderImageRepeat): (WebCore::BorderImageQuadParseContext::setTop): (WebCore::CSSParser::parseCounter): (WebCore::CSSParser::parseDeprecatedGradient): (WebCore::CSSParser::parseDeprecatedLinearGradient): (WebCore::CSSParser::parseDeprecatedRadialGradient): (WebCore::CSSParser::parseLinearGradient): (WebCore::CSSParser::parseRadialGradient): (WebCore::CSSParser::parseFilterImage): (WebCore::CSSParser::parseCrossfade): (WebCore::CSSParser::parseImageResolution): (WebCore::CSSParser::parseImageSet): (WebCore::CSSParser::parseTransform): (WebCore::CSSParser::parseTransformValue): (WebCore::CSSParser::parseFilter): (WebCore::CSSParser::parseTextDecoration): (WebCore::CSSParser::parseTextEmphasisStyle): (WebCore::CSSParser::parseTextEmphasisPosition): (WebCore::CSSParser::parseTextIndent): (WebCore::CSSParser::parseHangingPunctuation): (WebCore::CSSParser::parseFontFeatureSettings): (WebCore::CSSParser::parseWillChange): (WebCore::CSSParser::createImportRule): (WebCore::CSSParser::createMediaRule): (WebCore::CSSParser::createEmptyMediaRule): (WebCore::CSSParser::createSupportsRule): (WebCore::CSSParser::markSupportsRuleHeaderStart): (WebCore::CSSParser::popSupportsRuleData): (WebCore::CSSParser::processAndAddNewRuleToSourceTreeIfNeeded): (WebCore::CSSParser::addNewRuleToSourceTree): (WebCore::CSSParser::popRuleData): (WebCore::CSSParser::createKeyframesRule): (WebCore::CSSParser::createStyleRule): (WebCore::CSSParser::createFontFaceRule): (WebCore::CSSParser::createPageRule): (WebCore::CSSParser::createRegionRule): (WebCore::CSSParser::endDeclarationsForMarginBox): (WebCore::CSSParser::createKeyframe): (WebCore::CSSParser::updateLastMediaLine): (WebCore::fixUnparsedProperties): (WebCore::CSSParser::fixUnparsedPropertyRanges): (WebCore::CSSParser::parseViewportProperty): (WebCore::cssPropertyNameIOSAliasing): (WebCore::isAppleLegacyCssValueKeyword): (WebCore::quoteCSSString): (WebCore::AnimationParseContext::commitFirstAnimation): Deleted. (WebCore::strictCSSParserContext): Deleted. (WebCore::CSSParser::~CSSParser): Deleted. (WebCore::convertToASCIILowercaseInPlace): Deleted. (WebCore::CSSParserString::convertToASCIILowercaseInPlace): Deleted. (WebCore::CSSParser::setupParser): Deleted. (WebCore::isSimpleLengthPropertyID): Deleted. (WebCore::isValidKeywordPropertyAndValue): Deleted. (WebCore::parseTransformTranslateArguments): Deleted. (WebCore::CSSParser::parseColor): Deleted. (WebCore::CSSParser::parseMediaQuery): Deleted. (WebCore::CSSParser::parseSizesAttribute): Deleted. (WebCore::CSSParser::addProperty): Deleted. (WebCore::CSSParser::validateCalculationUnit): Deleted. (WebCore::isItemPositionKeyword): Deleted. (WebCore::CSSParser::parseShorthand): Deleted. (WebCore::CSSParser::parseSizeParameter): Deleted. (WebCore::CSSParser::parseFillImage): Deleted. (WebCore::CSSParser::parsePositionY): Deleted. (WebCore::CSSParser::parse2ValuesFillPosition): Deleted. (WebCore::CSSParser::parseTransformOriginShorthand): Deleted. (WebCore::CSSParser::parseAnimationTimingFunction): Deleted. (WebCore::CSSParser::parseGridTemplateColumns): Deleted. (WebCore::CSSParser::parseSingleGridAreaLonghand): Deleted. (WebCore::allTracksAreFixedSized): Deleted. (WebCore::CSSParser::parseGridBreadth): Deleted. (WebCore::CSSParser::parseGridTemplateAreasRow): Deleted. (WebCore::completeBorderRadii): Deleted. (WebCore::CSSParser::parseShapeRadius): Deleted. (WebCore::isBoxValue): Deleted. (WebCore::CSSParser::parseShapeProperty): Deleted. (WebCore::CSSParser::parseClipPath): Deleted. (WebCore::CSSParser::parseBasicShape): Deleted. (WebCore::FontFamilyValueBuilder::commit): Deleted. (WebCore::CSSParser::parseFontWeight): Deleted. (WebCore::CSSParser::parseFontFaceSrcLocal): Deleted. (WebCore::parseDouble): Deleted. (WebCore::mightBeRGBA): Deleted. (WebCore::mightBeRGB): Deleted. (WebCore::ShadowParseContext::commitColor): Deleted. (WebCore::BorderImageParseContext::BorderImageParseContext): Deleted. (WebCore::BorderImageParseContext::commitForwardSlashOperator): Deleted. (WebCore::BorderImageParseContext::commitBorderImage): Deleted. (WebCore::isBorderImageRepeatKeyword): Deleted. (WebCore::BorderImageSliceParseContext::commitBorderImageSlice): Deleted. (WebCore::CSSParser::parseBorderImageQuad): Deleted. (WebCore::parseDeprecatedGradientColorStop): Deleted. (WebCore::valueFromSideKeyword): Deleted. (WebCore::CSSParser::isGeneratedImageValue): Deleted. (WebCore::CSSParser::parseCanvas): Deleted. (WebCore::CSSParser::parseNamedImage): Deleted. (WebCore::TransformOperationInfo::TransformOperationInfo): Deleted. (WebCore::CSSParser::isBlendMode): Deleted. (WebCore::filterInfoForName): Deleted. (WebCore::CSSParser::parseFlowThread): Deleted. (WebCore::CSSParser::parseRegionThread): Deleted. (WebCore::CSSParser::parseLineBoxContain): Deleted. (WebCore::CSSParser::parseFontFeatureTag): Deleted. (WebCore::CSSParser::parseFontVariantLigatures): Deleted. (WebCore::isCSSLetter): Deleted. (WebCore::CSSParser::markSupportsRuleHeaderEnd): Deleted. (WebCore::CSSParser::syntaxError): Deleted. (WebCore::CSSParser::logError): Deleted. (WebCore::CSSParser::rewriteSpecifiersWithElementName): Deleted. (WebCore::CSSParser::rewriteSpecifiers): Deleted. (WebCore::CSSParser::invalidBlockHit): Deleted. (WebCore::CSSParser::markRuleHeaderStart): Deleted. (WebCore::CSSParser::setRuleHeaderEnd): Deleted. (WebCore::CSSParser::markRuleHeaderEnd): Deleted. (WebCore::CSSParser::markRuleBodyStart): Deleted. (WebCore::cssPropertyID): Deleted. (WebCore::isCSSTokenizerIdentifier): Deleted. * css/CSSParser.h: (WebCore::CSSParser::ValueWithCalculation::setCalculation): Deleted. * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::cloneForCSSOM): * css/CSSPrimitiveValue.h: * css/CSSPropertySourceData.h: * css/CSSReflectValue.cpp: (WebCore::CSSReflectValue::equals): * css/CSSReflectValue.h: (WebCore::CSSReflectValue::create): (WebCore::CSSReflectValue::direction): (WebCore::CSSReflectValue::offset): (WebCore::CSSReflectValue::CSSReflectValue): * css/CSSShadowValue.cpp: (WebCore::CSSShadowValue::CSSShadowValue): (WebCore::CSSShadowValue::customCSSText): Deleted. * css/CSSShadowValue.h: (WebCore::CSSShadowValue::create): * css/CSSValue.h: (WebCore::compareCSSValueVector): * css/CSSVariableDependentValue.cpp: (WebCore::CSSVariableDependentValue::checkVariablesForCycles): * css/CSSVariableDependentValue.h: (WebCore::CSSVariableDependentValue::create): (WebCore::CSSVariableDependentValue::customCSSText): (WebCore::CSSVariableDependentValue::valueList): (WebCore::CSSVariableDependentValue::CSSVariableDependentValue): * css/CSSVariableValue.cpp: (WebCore::CSSVariableValue::buildParserValueListSubstitutingVariables): * css/Counter.h: (WebCore::Counter::create): (WebCore::Counter::identifier): (WebCore::Counter::listStyle): (WebCore::Counter::separator): (WebCore::Counter::listStyleIdent): (WebCore::Counter::setIdentifier): (WebCore::Counter::setListStyle): (WebCore::Counter::setSeparator): (WebCore::Counter::cloneForCSSOM): (WebCore::Counter::Counter): * css/DOMCSSNamespace.cpp: (WebCore::DOMCSSNamespace::supports): * css/FontFace.cpp: (WebCore::FontFace::parseString): (WebCore::FontFace::setVariant): * css/Rect.h: (WebCore::RectBase::RectBase): * css/SVGCSSParser.cpp: (WebCore::CSSParser::parseSVGStrokeDasharray): (WebCore::CSSParser::parseSVGPaint): (WebCore::CSSParser::parseSVGColor): (WebCore::CSSParser::parsePaintOrder): * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertReflection): * css/StyleProperties.cpp: (WebCore::MutableStyleProperties::setProperty): (WebCore::MutableStyleProperties::setCustomProperty): (WebCore::MutableStyleProperties::parseDeclaration): * css/StyleResolver.cpp: (WebCore::StyleResolver::keyframeStylesForAnimation): (WebCore::StyleResolver::cachedOrPendingFromValue): * css/StyleResolver.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::setFont): * inspector/InspectorStyleSheet.cpp: (flattenSourceData): (ParsedStyleSheet::setSourceData): (ParsedStyleSheet::ruleSourceDataAt): (WebCore::InspectorStyleSheetForInlineStyle::getStyleAttributeRanges): * page/PageSerializer.cpp: (WebCore::PageSerializer::retrieveResourcesForProperties): * page/animation/CSSPropertyAnimation.cpp: (WebCore::crossfadeBlend): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::checkVariablesInCustomProperties): Canonical link: https://commits.webkit.org/176106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201290 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent a1e4378 commit 1860500

54 files changed

Lines changed: 1178 additions & 899 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Source/WebCore/ChangeLog

Lines changed: 364 additions & 0 deletions
Large diffs are not rendered by default.

Source/WebCore/WebCore.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6661,7 +6661,7 @@
66616661
E48944A3180B57D800F165D8 /* SimpleLineLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = E48944A1180B57D800F165D8 /* SimpleLineLayout.h */; settings = {ATTRIBUTES = (Private, ); }; };
66626662
E4916FF7195DF6A0005AB349 /* LayerFlushThrottleState.h in Headers */ = {isa = PBXBuildFile; fileRef = E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */; settings = {ATTRIBUTES = (Private, ); }; };
66636663
E4946EAE156E64DD00D3297F /* StyleRuleImport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4946EAC156E64DD00D3297F /* StyleRuleImport.cpp */; };
6664-
E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */ = {isa = PBXBuildFile; fileRef = E4946EAD156E64DD00D3297F /* StyleRuleImport.h */; };
6664+
E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */ = {isa = PBXBuildFile; fileRef = E4946EAD156E64DD00D3297F /* StyleRuleImport.h */; settings = {ATTRIBUTES = (Private, ); }; };
66656665
E49BD9FA131FD2ED003C56F0 /* CSSValuePool.h in Headers */ = {isa = PBXBuildFile; fileRef = E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */; };
66666666
E49BDA0B131FD3E5003C56F0 /* CSSValuePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E49BDA0A131FD3E5003C56F0 /* CSSValuePool.cpp */; };
66676667
E4A007831B820EC8002C5A6E /* DataURLDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A007821B820EC8002C5A6E /* DataURLDecoder.h */; };

Source/WebCore/css/BasicShapeFunctions.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static Ref<CSSPrimitiveValue> basicShapeRadiusToCSSValue(const RenderStyle& styl
6565
return pool.createIdentifierValue(CSSValueClosestSide);
6666
}
6767

68-
Ref<CSSValue> valueForBasicShape(const RenderStyle& style, const BasicShape& basicShape)
68+
Ref<CSSPrimitiveValue> valueForBasicShape(const RenderStyle& style, const BasicShape& basicShape)
6969
{
7070
auto& cssValuePool = CSSValuePool::singleton();
7171

@@ -136,12 +136,12 @@ Ref<CSSValue> valueForBasicShape(const RenderStyle& style, const BasicShape& bas
136136
return cssValuePool.createValue(basicShapeValue.releaseNonNull());
137137
}
138138

139-
static Length convertToLength(const CSSToLengthConversionData& conversionData, CSSPrimitiveValue* value)
139+
static Length convertToLength(const CSSToLengthConversionData& conversionData, const CSSPrimitiveValue* value)
140140
{
141141
return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | CalculatedConversion>(conversionData);
142142
}
143143

144-
static LengthSize convertToLengthSize(const CSSToLengthConversionData& conversionData, CSSPrimitiveValue* value)
144+
static LengthSize convertToLengthSize(const CSSToLengthConversionData& conversionData, const CSSPrimitiveValue* value)
145145
{
146146
if (!value)
147147
return LengthSize(Length(0, Fixed), Length(0, Fixed));
@@ -242,9 +242,9 @@ Ref<BasicShape> basicShapeForValue(const CSSToLengthConversionData& conversionDa
242242
auto polygon = BasicShapePolygon::create();
243243

244244
polygon->setWindRule(polygonValue.windRule());
245-
const Vector<RefPtr<CSSPrimitiveValue>>& values = polygonValue.values();
245+
auto& values = polygonValue.values();
246246
for (unsigned i = 0; i < values.size(); i += 2)
247-
polygon->appendPoint(convertToLength(conversionData, values.at(i).get()), convertToLength(conversionData, values.at(i + 1).get()));
247+
polygon->appendPoint(convertToLength(conversionData, values[i].ptr()), convertToLength(conversionData, values[i + 1].ptr()));
248248

249249
basicShape = WTFMove(polygon);
250250
break;

Source/WebCore/css/BasicShapeFunctions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class BasicShape;
3737
class BasicShapeCenterCoordinate;
3838
class CSSBasicShape;
3939
class CSSToLengthConversionData;
40-
class CSSValue;
40+
class CSSPrimitiveValue;
4141
class RenderStyle;
4242

43-
Ref<CSSValue> valueForBasicShape(const RenderStyle&, const BasicShape&);
43+
Ref<CSSPrimitiveValue> valueForBasicShape(const RenderStyle&, const BasicShape&);
4444
Ref<BasicShape> basicShapeForValue(const CSSToLengthConversionData&, const CSSBasicShape&);
4545
float floatValueForCenterCoordinate(const BasicShapeCenterCoordinate&, float);
4646

Source/WebCore/css/CSSBasicShapes.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ String CSSBasicShapePolygon::cssText() const
286286
Vector<String> points;
287287
points.reserveInitialCapacity(m_values.size());
288288

289-
for (size_t i = 0; i < m_values.size(); ++i)
290-
points.append(m_values.at(i)->cssText());
289+
for (auto& shapeValue : m_values)
290+
points.uncheckedAppend(shapeValue->cssText());
291291

292292
return buildPolygonString(m_windRule, points);
293293
}
@@ -297,8 +297,7 @@ bool CSSBasicShapePolygon::equals(const CSSBasicShape& shape) const
297297
if (!is<CSSBasicShapePolygon>(shape))
298298
return false;
299299

300-
const CSSBasicShapePolygon& rhs = downcast<CSSBasicShapePolygon>(shape);
301-
return compareCSSValueVector<CSSPrimitiveValue>(m_values, rhs.m_values);
300+
return compareCSSValueVector<CSSPrimitiveValue>(m_values, downcast<CSSBasicShapePolygon>(shape).m_values);
302301
}
303302

304303
static bool buildInsetRadii(Vector<String>& radii, const String& topLeftRadius, const String& topRightRadius, const String& bottomRightRadius, const String& bottomLeftRadius)

Source/WebCore/css/CSSBasicShapes.h

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -76,32 +76,32 @@ class CSSBasicShapeInset final : public CSSBasicShape {
7676
CSSPrimitiveValue* bottomRightRadius() const { return m_bottomRightRadius.get(); }
7777
CSSPrimitiveValue* bottomLeftRadius() const { return m_bottomLeftRadius.get(); }
7878

79-
void setTop(RefPtr<CSSPrimitiveValue>&& top) { m_top = WTFMove(top); }
80-
void setRight(RefPtr<CSSPrimitiveValue>&& right) { m_right = WTFMove(right); }
81-
void setBottom(RefPtr<CSSPrimitiveValue>&& bottom) { m_bottom = WTFMove(bottom); }
82-
void setLeft(RefPtr<CSSPrimitiveValue>&& left) { m_left = WTFMove(left); }
79+
void setTop(Ref<CSSPrimitiveValue>&& top) { m_top = WTFMove(top); }
80+
void setRight(Ref<CSSPrimitiveValue>&& right) { m_right = WTFMove(right); }
81+
void setBottom(Ref<CSSPrimitiveValue>&& bottom) { m_bottom = WTFMove(bottom); }
82+
void setLeft(Ref<CSSPrimitiveValue>&& left) { m_left = WTFMove(left); }
8383

84-
void updateShapeSize4Values(CSSPrimitiveValue* top, CSSPrimitiveValue* right, CSSPrimitiveValue* bottom, CSSPrimitiveValue* left)
84+
void updateShapeSize4Values(Ref<CSSPrimitiveValue>&& top, Ref<CSSPrimitiveValue>&& right, Ref<CSSPrimitiveValue>&& bottom, Ref<CSSPrimitiveValue>&& left)
8585
{
86-
setTop(top);
87-
setRight(right);
88-
setBottom(bottom);
89-
setLeft(left);
86+
setTop(WTFMove(top));
87+
setRight(WTFMove(right));
88+
setBottom(WTFMove(bottom));
89+
setLeft(WTFMove(left));
9090
}
9191

92-
void updateShapeSize1Value(CSSPrimitiveValue* value1)
92+
void updateShapeSize1Value(Ref<CSSPrimitiveValue>&& value1)
9393
{
94-
updateShapeSize4Values(value1, value1, value1, value1);
94+
updateShapeSize4Values(value1.copyRef(), value1.copyRef(), value1.copyRef(), WTFMove(value1));
9595
}
9696

97-
void updateShapeSize2Values(CSSPrimitiveValue* value1, CSSPrimitiveValue* value2)
97+
void updateShapeSize2Values(Ref<CSSPrimitiveValue>&& value1, Ref<CSSPrimitiveValue>&& value2)
9898
{
99-
updateShapeSize4Values(value1, value2, value1, value2);
99+
updateShapeSize4Values(value1.copyRef(), value2.copyRef(), WTFMove(value1), WTFMove(value2));
100100
}
101101

102-
void updateShapeSize3Values(CSSPrimitiveValue* value1, CSSPrimitiveValue* value2, CSSPrimitiveValue* value3)
102+
void updateShapeSize3Values(Ref<CSSPrimitiveValue>&& value1, Ref<CSSPrimitiveValue>&& value2, Ref<CSSPrimitiveValue>&& value3)
103103
{
104-
updateShapeSize4Values(value1, value2, value3, value2);
104+
updateShapeSize4Values(WTFMove(value1), value2.copyRef(), WTFMove(value3), WTFMove(value2));
105105
}
106106

107107
void setTopLeftRadius(RefPtr<CSSPrimitiveValue>&& radius) { m_topLeftRadius = WTFMove(radius); }
@@ -135,9 +135,9 @@ class CSSBasicShapeCircle final : public CSSBasicShape {
135135
CSSPrimitiveValue* centerY() const { return m_centerY.get(); }
136136
CSSPrimitiveValue* radius() const { return m_radius.get(); }
137137

138-
void setCenterX(RefPtr<CSSPrimitiveValue>&& centerX) { m_centerX = WTFMove(centerX); }
139-
void setCenterY(RefPtr<CSSPrimitiveValue>&& centerY) { m_centerY = WTFMove(centerY); }
140-
void setRadius(RefPtr<CSSPrimitiveValue>&& radius) { m_radius = WTFMove(radius); }
138+
void setCenterX(Ref<CSSPrimitiveValue>&& centerX) { m_centerX = WTFMove(centerX); }
139+
void setCenterY(Ref<CSSPrimitiveValue>&& centerY) { m_centerY = WTFMove(centerY); }
140+
void setRadius(Ref<CSSPrimitiveValue>&& radius) { m_radius = WTFMove(radius); }
141141

142142
private:
143143
CSSBasicShapeCircle() { }
@@ -160,10 +160,10 @@ class CSSBasicShapeEllipse final : public CSSBasicShape {
160160
CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); }
161161
CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); }
162162

163-
void setCenterX(PassRefPtr<CSSPrimitiveValue> centerX) { m_centerX = centerX; }
164-
void setCenterY(PassRefPtr<CSSPrimitiveValue> centerY) { m_centerY = centerY; }
165-
void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
166-
void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
163+
void setCenterX(Ref<CSSPrimitiveValue>&& centerX) { m_centerX = WTFMove(centerX); }
164+
void setCenterY(Ref<CSSPrimitiveValue>&& centerY) { m_centerY = WTFMove(centerY); }
165+
void setRadiusX(Ref<CSSPrimitiveValue>&& radiusX) { m_radiusX = WTFMove(radiusX); }
166+
void setRadiusY(Ref<CSSPrimitiveValue>&& radiusY) { m_radiusY = WTFMove(radiusY); }
167167

168168
private:
169169
CSSBasicShapeEllipse() { }
@@ -182,15 +182,13 @@ class CSSBasicShapePolygon final : public CSSBasicShape {
182182
public:
183183
static Ref<CSSBasicShapePolygon> create() { return adoptRef(*new CSSBasicShapePolygon); }
184184

185-
void appendPoint(PassRefPtr<CSSPrimitiveValue> x, PassRefPtr<CSSPrimitiveValue> y)
185+
void appendPoint(Ref<CSSPrimitiveValue>&& x, Ref<CSSPrimitiveValue>&& y)
186186
{
187-
m_values.append(x);
188-
m_values.append(y);
187+
m_values.append(WTFMove(x));
188+
m_values.append(WTFMove(y));
189189
}
190190

191-
RefPtr<CSSPrimitiveValue> getXAt(unsigned i) const { return m_values.at(i * 2); }
192-
RefPtr<CSSPrimitiveValue> getYAt(unsigned i) const { return m_values.at(i * 2 + 1); }
193-
const Vector<RefPtr<CSSPrimitiveValue>>& values() const { return m_values; }
191+
const Vector<Ref<CSSPrimitiveValue>>& values() const { return m_values; }
194192

195193
void setWindRule(WindRule rule) { m_windRule = rule; }
196194
WindRule windRule() const { return m_windRule; }
@@ -205,7 +203,7 @@ class CSSBasicShapePolygon final : public CSSBasicShape {
205203
String cssText() const override;
206204
bool equals(const CSSBasicShape&) const override;
207205

208-
Vector<RefPtr<CSSPrimitiveValue>> m_values;
206+
Vector<Ref<CSSPrimitiveValue>> m_values;
209207
WindRule m_windRule;
210208
};
211209

Source/WebCore/css/CSSComputedStyleDeclaration.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ static Ref<CSSValue> valueForReflection(const StyleReflection* reflection, const
683683
break;
684684
}
685685

686-
return CSSReflectValue::create(direction.release(), offset.release(), valueForNinePieceImage(reflection->mask()));
686+
return CSSReflectValue::create(direction.releaseNonNull(), offset.releaseNonNull(), valueForNinePieceImage(reflection->mask()));
687687
}
688688

689689
static Ref<CSSValueList> createPositionListForLayer(CSSPropertyID propertyID, const FillLayer* layer, const RenderStyle& style)
@@ -907,13 +907,13 @@ Ref<CSSValue> ComputedStyleExtractor::valueForShadow(const ShadowData* shadow, C
907907

908908
auto list = CSSValueList::createCommaSeparated();
909909
for (const ShadowData* currShadowData = shadow; currShadowData; currShadowData = currShadowData->next()) {
910-
RefPtr<CSSPrimitiveValue> x = adjustLengthForZoom(currShadowData->x(), style, adjust);
911-
RefPtr<CSSPrimitiveValue> y = adjustLengthForZoom(currShadowData->y(), style, adjust);
912-
RefPtr<CSSPrimitiveValue> blur = adjustLengthForZoom(currShadowData->radius(), style, adjust);
913-
RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? PassRefPtr<CSSPrimitiveValue>() : adjustLengthForZoom(currShadowData->spread(), style, adjust);
914-
RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || currShadowData->style() == Normal ? PassRefPtr<CSSPrimitiveValue>() : cssValuePool.createIdentifierValue(CSSValueInset);
915-
RefPtr<CSSPrimitiveValue> color = cssValuePool.createColorValue(currShadowData->color().rgb());
916-
list.get().prepend(CSSShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
910+
auto x = adjustLengthForZoom(currShadowData->x(), style, adjust);
911+
auto y = adjustLengthForZoom(currShadowData->y(), style, adjust);
912+
auto blur = adjustLengthForZoom(currShadowData->radius(), style, adjust);
913+
auto spread = propertyID == CSSPropertyTextShadow ? RefPtr<CSSPrimitiveValue>() : adjustLengthForZoom(currShadowData->spread(), style, adjust);
914+
auto style = propertyID == CSSPropertyTextShadow || currShadowData->style() == Normal ? RefPtr<CSSPrimitiveValue>() : cssValuePool.createIdentifierValue(CSSValueInset);
915+
auto color = cssValuePool.createColorValue(currShadowData->color().rgb());
916+
list->prepend(CSSShadowValue::create(WTFMove(x), WTFMove(y), WTFMove(blur), WTFMove(spread), WTFMove(style), WTFMove(color)));
917917
}
918918
return WTFMove(list);
919919
}
@@ -1029,10 +1029,10 @@ static Ref<CSSValue> specifiedValueForGridTrackSize(const GridTrackSize& trackSi
10291029
return specifiedValueForGridTrackBreadth(trackSize.length(), style);
10301030
default:
10311031
ASSERT(trackSize.type() == MinMaxTrackSizing);
1032-
RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSeparated();
1032+
auto minMaxTrackBreadths = CSSValueList::createCommaSeparated();
10331033
minMaxTrackBreadths->append(specifiedValueForGridTrackBreadth(trackSize.minTrackBreadth(), style));
10341034
minMaxTrackBreadths->append(specifiedValueForGridTrackBreadth(trackSize.maxTrackBreadth(), style));
1035-
return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
1035+
return CSSFunctionValue::create("minmax(", WTFMove(minMaxTrackBreadths));
10361036
}
10371037
}
10381038

Source/WebCore/css/CSSCrossfadeValue.cpp

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static inline double blendFunc(double from, double to, double progress)
4545
return blend(from, to, progress);
4646
}
4747

48-
static bool subimageKnownToBeOpaque(CSSValue& value, const RenderElement* renderer)
48+
static bool subimageKnownToBeOpaque(const CSSValue& value, const RenderElement* renderer)
4949
{
5050
if (is<CSSImageValue>(value))
5151
return downcast<CSSImageValue>(value).knownToBeOpaque(renderer);
@@ -92,8 +92,8 @@ FloatSize CSSCrossfadeValue::fixedSize(const RenderElement* renderer)
9292
ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
9393

9494
CachedResourceLoader& cachedResourceLoader = renderer->document().cachedResourceLoader();
95-
CachedImage* cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), cachedResourceLoader, options);
96-
CachedImage* cachedToImage = cachedImageForCSSValue(m_toValue.get(), cachedResourceLoader, options);
95+
CachedImage* cachedFromImage = cachedImageForCSSValue(m_fromValue, cachedResourceLoader, options);
96+
CachedImage* cachedToImage = cachedImageForCSSValue(m_toValue, cachedResourceLoader, options);
9797

9898
if (!cachedFromImage || !cachedToImage)
9999
return FloatSize();
@@ -110,24 +110,24 @@ FloatSize CSSCrossfadeValue::fixedSize(const RenderElement* renderer)
110110
fromImageSize.height() * inversePercentage + toImageSize.height() * percentage);
111111
}
112112

113-
bool CSSCrossfadeValue::isPending() const
113+
bool CSSCrossfadeValue::isPending()
114114
{
115-
return CSSImageGeneratorValue::subimageIsPending(m_fromValue.get())
116-
|| CSSImageGeneratorValue::subimageIsPending(m_toValue.get());
115+
return CSSImageGeneratorValue::subimageIsPending(m_fromValue)
116+
|| CSSImageGeneratorValue::subimageIsPending(m_toValue);
117117
}
118118

119119
bool CSSCrossfadeValue::knownToBeOpaque(const RenderElement* renderer) const
120120
{
121-
return subimageKnownToBeOpaque(*m_fromValue, renderer) && subimageKnownToBeOpaque(*m_toValue, renderer);
121+
return subimageKnownToBeOpaque(m_fromValue, renderer) && subimageKnownToBeOpaque(m_toValue, renderer);
122122
}
123123

124124
void CSSCrossfadeValue::loadSubimages(CachedResourceLoader& cachedResourceLoader, const ResourceLoaderOptions& options)
125125
{
126126
CachedResourceHandle<CachedImage> oldCachedFromImage = m_cachedFromImage;
127127
CachedResourceHandle<CachedImage> oldCachedToImage = m_cachedToImage;
128128

129-
m_cachedFromImage = CSSImageGeneratorValue::cachedImageForCSSValue(m_fromValue.get(), cachedResourceLoader, options);
130-
m_cachedToImage = CSSImageGeneratorValue::cachedImageForCSSValue(m_toValue.get(), cachedResourceLoader, options);
129+
m_cachedFromImage = CSSImageGeneratorValue::cachedImageForCSSValue(m_fromValue, cachedResourceLoader, options);
130+
m_cachedToImage = CSSImageGeneratorValue::cachedImageForCSSValue(m_toValue, cachedResourceLoader, options);
131131

132132
if (m_cachedFromImage != oldCachedFromImage) {
133133
if (oldCachedFromImage)
@@ -156,8 +156,8 @@ RefPtr<Image> CSSCrossfadeValue::image(RenderElement* renderer, const FloatSize&
156156
ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
157157

158158
CachedResourceLoader& cachedResourceLoader = renderer->document().cachedResourceLoader();
159-
CachedImage* cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), cachedResourceLoader, options);
160-
CachedImage* cachedToImage = cachedImageForCSSValue(m_toValue.get(), cachedResourceLoader, options);
159+
CachedImage* cachedFromImage = cachedImageForCSSValue(m_fromValue, cachedResourceLoader, options);
160+
CachedImage* cachedToImage = cachedImageForCSSValue(m_toValue, cachedResourceLoader, options);
161161

162162
if (!cachedFromImage || !cachedToImage)
163163
return Image::nullImage();
@@ -205,29 +205,26 @@ RefPtr<CSSCrossfadeValue> CSSCrossfadeValue::blend(const CSSCrossfadeValue& from
205205
auto fromImageValue = CSSImageValue::create(m_cachedFromImage->url(), fromStyledImage.get());
206206
auto toImageValue = CSSImageValue::create(m_cachedToImage->url(), toStyledImage.get());
207207

208-
RefPtr<CSSCrossfadeValue> crossfadeValue = CSSCrossfadeValue::create(WTFMove(fromImageValue), WTFMove(toImageValue), from.isPrefixed() && isPrefixed());
209-
210208
double fromPercentage = from.m_percentageValue->getDoubleValue();
211209
if (from.m_percentageValue->isPercentage())
212210
fromPercentage /= 100.0;
213211
double toPercentage = m_percentageValue->getDoubleValue();
214212
if (m_percentageValue->isPercentage())
215213
toPercentage /= 100.0;
216-
crossfadeValue->setPercentage(CSSPrimitiveValue::create(blendFunc(fromPercentage, toPercentage, progress), CSSPrimitiveValue::CSS_NUMBER));
217-
return crossfadeValue;
214+
auto percentageValue = CSSPrimitiveValue::create(blendFunc(fromPercentage, toPercentage, progress), CSSPrimitiveValue::CSS_NUMBER);
215+
216+
return CSSCrossfadeValue::create(WTFMove(fromImageValue), WTFMove(toImageValue), WTFMove(percentageValue), from.isPrefixed() && isPrefixed());
218217
}
219218

220219
bool CSSCrossfadeValue::equals(const CSSCrossfadeValue& other) const
221220
{
222-
return equalInputImages(other)
223-
&& compareCSSValuePtr(m_percentageValue, other.m_percentageValue);
221+
return equalInputImages(other) && compareCSSValue(m_percentageValue, other.m_percentageValue);
224222
}
225223

226224

227225
bool CSSCrossfadeValue::equalInputImages(const CSSCrossfadeValue& other) const
228226
{
229-
return compareCSSValuePtr(m_fromValue, other.m_fromValue)
230-
&& compareCSSValuePtr(m_toValue, other.m_toValue);
227+
return compareCSSValue(m_fromValue, other.m_fromValue) && compareCSSValue(m_toValue, other.m_toValue);
231228
}
232229

233230
} // namespace WebCore

0 commit comments

Comments
 (0)