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

Unified Diff: Source/core/animation/LengthStyleInterpolation.cpp

Issue 995033002: Don't recurse in LengthStyleInterpolation helper constructCalcExpression (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/LengthStyleInterpolation.cpp
diff --git a/Source/core/animation/LengthStyleInterpolation.cpp b/Source/core/animation/LengthStyleInterpolation.cpp
index 71fc754d557ebd56fd5ddd18e3f0a0cc66405c4b..c242662a55390f4483fcdc42637c8412cd0fb616 100644
--- a/Source/core/animation/LengthStyleInterpolation.cpp
+++ b/Source/core/animation/LengthStyleInterpolation.cpp
@@ -202,24 +202,23 @@ static CSSPrimitiveValue::UnitType toUnitType(int lengthUnitType)
return static_cast<CSSPrimitiveValue::UnitType>(CSSPrimitiveValue::lengthUnitTypeToUnitType(static_cast<CSSPrimitiveValue::LengthUnitType>(lengthUnitType)));
}
-static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> constructCalcExpression(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> previous, const InterpolableList* list, size_t position)
+static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> constructCalcExpression(const InterpolableList* list)
{
const InterpolableList* listOfValues = toInterpolableList(list->get(0));
const InterpolableList* listOfTypes = toInterpolableList(list->get(1));
- while (position != CSSPrimitiveValue::LengthUnitTypeCount) {
+ RefPtrWillBeRawPtr<CSSCalcExpressionNode> expression;
+ for (size_t position = 0; position < CSSPrimitiveValue::LengthUnitTypeCount; position++) {
const InterpolableNumber *subValueType = toInterpolableNumber(listOfTypes->get(position));
- if (subValueType->value()) {
- RefPtrWillBeRawPtr<CSSCalcExpressionNode> next;
- double value = toInterpolableNumber(listOfValues->get(position))->value();
- if (previous)
- next = CSSCalcValue::createExpressionNode(previous, CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(value, toUnitType(position))), CalcAdd);
- else
- next = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(value, toUnitType(position)));
- return constructCalcExpression(next, list, position + 1);
- }
- position++;
+ if (!subValueType->value())
+ continue;
+ double value = toInterpolableNumber(listOfValues->get(position))->value();
+ RefPtrWillBeRawPtr<CSSCalcExpressionNode> currentTerm = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(value, toUnitType(position)));
+ if (expression)
+ expression = CSSCalcValue::createExpressionNode(expression.release(), currentTerm.release(), CalcAdd);
+ else
+ expression = currentTerm.release();
}
- return previous;
+ return expression.release();
}
static double clampToRange(double x, ValueRange range)
@@ -283,7 +282,7 @@ PassRefPtrWillBeRawPtr<CSSPrimitiveValue> LengthStyleInterpolation::fromInterpol
ASSERT_NOT_REACHED();
default:
ValueRange valueRange = (range == RangeNonNegative) ? ValueRangeNonNegative : ValueRangeAll;
- return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpression(nullptr, listOfValuesAndTypes, 0), valueRange));
+ return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpression(listOfValuesAndTypes), valueRange));
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698