Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Unified Diff: Source/core/css/CSSGradientValue.cpp

Issue 1233363002: CSSValue Immediates: Replace CSSPrimitiveValue usage with const references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_4_attempt_2
Patch Set: Rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/CSSGradientValue.h ('k') | Source/core/css/CSSPrimitiveValue.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSGradientValue.cpp
diff --git a/Source/core/css/CSSGradientValue.cpp b/Source/core/css/CSSGradientValue.cpp
index 0467195962303cc25e9cf1f7a4ddb6c1bf47567e..bfffae009a8d2d2b6327299eddb36cca423b7265 100644
--- a/Source/core/css/CSSGradientValue.cpp
+++ b/Source/core/css/CSSGradientValue.cpp
@@ -192,7 +192,7 @@ static void replaceColorHintsWithColorStops(Vector<GradientStop>& stops, const W
}
}
-static Color resolveStopColor(CSSPrimitiveValue stopColor, const LayoutObject& object)
+static Color resolveStopColor(const CSSPrimitiveValue& stopColor, const LayoutObject& object)
{
return object.document().textLinkColors().colorFromPrimitiveValue(stopColor, object.resolveColor(CSSPropertyColor));
}
@@ -379,7 +379,7 @@ void CSSGradientValue::addStops(Gradient* gradient, const CSSToLengthConversionD
stops[i].color = resolveStopColor(toCSSPrimitiveValue(*stop.m_color), object);
if (stop.m_position) {
- CSSPrimitiveValue stopPosition = toCSSPrimitiveValue(*stop.m_position);
+ const CSSPrimitiveValue& stopPosition = toCSSPrimitiveValue(*stop.m_position);
if (stopPosition.isPercentage()) {
stops[i].offset = toCSSPrimitiveValue(*stop.m_position).getFloatValue() / 100;
} else if (stopPosition.isLength() || stopPosition.isCalculatedPercentageWithLength()) {
@@ -481,7 +481,7 @@ void CSSGradientValue::addStops(Gradient* gradient, const CSSToLengthConversionD
}
}
-static float positionFromValue(CSSPrimitiveValue value, const CSSToLengthConversionData& conversionData, const IntSize& size, bool isHorizontal)
+static float positionFromValue(const CSSPrimitiveValue& value, const CSSToLengthConversionData& conversionData, const IntSize& size, bool isHorizontal)
{
int origin = 0;
int sign = 1;
@@ -489,9 +489,10 @@ static float positionFromValue(CSSPrimitiveValue value, const CSSToLengthConvers
// In this case the center of the gradient is given relative to an edge in the form of:
// [ top | bottom | right | left ] [ <percentage> | <length> ].
- if (Pair* pair = value.getPairValue()) {
- CSSValueID originID = toCSSPrimitiveValue(*pair->first()).getValueID();
- value = toCSSPrimitiveValue(*pair->second());
+ CSSPrimitiveValue valueToUse = value;
+ if (Pair* pair = valueToUse.getPairValue()) {
+ CSSValueID originID = pair->first().getValueID();
+ valueToUse = pair->second();
if (originID == CSSValueRight || originID == CSSValueBottom) {
// For right/bottom, the offset is relative to the far edge.
@@ -500,16 +501,16 @@ static float positionFromValue(CSSPrimitiveValue value, const CSSToLengthConvers
}
}
- if (value.isNumber())
- return origin + sign * value.getFloatValue() * conversionData.zoom();
+ if (valueToUse.isNumber())
+ return origin + sign * valueToUse.getFloatValue() * conversionData.zoom();
- if (value.isPercentage())
- return origin + sign * value.getFloatValue() / 100.f * edgeDistance;
+ if (valueToUse.isPercentage())
+ return origin + sign * valueToUse.getFloatValue() / 100.f * edgeDistance;
- if (value.isCalculatedPercentageWithLength())
- return origin + sign * value.cssCalcValue()->toCalcValue(conversionData)->evaluate(edgeDistance);
+ if (valueToUse.isCalculatedPercentageWithLength())
+ return origin + sign * valueToUse.cssCalcValue()->toCalcValue(conversionData)->evaluate(edgeDistance);
- switch (value.getValueID()) {
+ switch (valueToUse.getValueID()) {
case CSSValueTop:
ASSERT(!isHorizontal);
return 0;
@@ -526,7 +527,7 @@ static float positionFromValue(CSSPrimitiveValue value, const CSSToLengthConvers
break;
}
- return origin + sign * value.computeLength<float>(conversionData);
+ return origin + sign * valueToUse.computeLength<float>(conversionData);
}
FloatPoint CSSGradientValue::computeEndPoint(NullableCSSValue horizontal, NullableCSSValue vertical, const CSSToLengthConversionData& conversionData, const IntSize& size)
@@ -999,7 +1000,7 @@ String CSSRadialGradientValue::customCSSText() const
return result.toString();
}
-float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue radius, const CSSToLengthConversionData& conversionData, float* widthOrHeight)
+float CSSRadialGradientValue::resolveRadius(const CSSPrimitiveValue& radius, const CSSToLengthConversionData& conversionData, float* widthOrHeight)
{
float result = 0;
if (radius.isNumber()) // Can the radius be a percentage?
« no previous file with comments | « Source/core/css/CSSGradientValue.h ('k') | Source/core/css/CSSPrimitiveValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698