Chromium Code Reviews| Index: Source/core/animation/LengthBoxStyleInterpolation.cpp |
| diff --git a/Source/core/animation/LengthBoxStyleInterpolation.cpp b/Source/core/animation/LengthBoxStyleInterpolation.cpp |
| index 53440c0aae4c8741b248d0a92d6d43adae1c025b..b0c1f603ed9dcfb0012f782f7140118890526d7f 100644 |
| --- a/Source/core/animation/LengthBoxStyleInterpolation.cpp |
| +++ b/Source/core/animation/LengthBoxStyleInterpolation.cpp |
| @@ -11,7 +11,7 @@ namespace blink { |
| namespace { |
| -bool onlyInterpolateBetweenLengthAndCSSValueAuto(Rect& startRect, Rect& endRect) |
| +bool onlyInterpolateBetweenLengthAndCSSValueAuto(const CSSQuadValue& startRect, const CSSQuadValue& endRect) |
| { |
| return startRect.left()->isLength() != endRect.left()->isLength() |
| && startRect.right()->isLength() != endRect.right()->isLength() |
| @@ -23,8 +23,8 @@ bool onlyInterpolateBetweenLengthAndCSSValueAuto(Rect& startRect, Rect& endRect) |
| PassRefPtrWillBeRawPtr<LengthBoxStyleInterpolation> LengthBoxStyleInterpolation::maybeCreateFrom(CSSValue& start, CSSValue& end, CSSPropertyID id) |
| { |
| - bool startRect = start.isPrimitiveValue() && toCSSPrimitiveValue(start).isRect(); |
| - bool endRect = end.isPrimitiveValue() && toCSSPrimitiveValue(end).isRect(); |
| + bool startRect = start.isQuadValue() && toCSSQuadValue(start).isRect(); |
|
Timothy Loh
2015/08/24 03:18:04
Not sure if we need to check isRect. Maybe alancut
sashab
2015/08/24 05:43:57
Matches the old code atm though. Sounds unrelated
alancutter (OOO until 2018)
2015/08/24 06:27:44
Agreed, changing this should be a separate patch.
|
| + bool endRect = end.isQuadValue() && toCSSQuadValue(end).isRect(); |
| if (startRect && endRect) |
| return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(lengthBoxtoInterpolableValue(start, end, false), lengthBoxtoInterpolableValue(end, start, true), id, &start, &end)); |
| @@ -35,10 +35,10 @@ PassOwnPtrWillBeRawPtr<InterpolableValue> LengthBoxStyleInterpolation::lengthBox |
| { |
| const int numberOfSides = 4; |
| OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(numberOfSides); |
| - Rect* rect = toCSSPrimitiveValue(lengthBox).getRectValue(); |
| - Rect* matchingRect = toCSSPrimitiveValue(matchingValue).getRectValue(); |
| - CSSPrimitiveValue* side[numberOfSides] = { rect->left(), rect->right(), rect->top(), rect->bottom() }; |
| - CSSPrimitiveValue* matchingSide[numberOfSides] = { matchingRect->left(), matchingRect->right(), matchingRect->top(), matchingRect->bottom() }; |
| + const CSSQuadValue& rect = toCSSQuadValue(lengthBox); |
| + const CSSQuadValue& matchingRect = toCSSQuadValue(matchingValue); |
| + CSSPrimitiveValue* side[numberOfSides] = { rect.left(), rect.right(), rect.top(), rect.bottom() }; |
| + CSSPrimitiveValue* matchingSide[numberOfSides] = { matchingRect.left(), matchingRect.right(), matchingRect.top(), matchingRect.bottom() }; |
| for (size_t i = 0; i < numberOfSides; i++) { |
| if (side[i]->isValueID() || matchingSide[i]->isValueID()) { |
| @@ -53,14 +53,21 @@ PassOwnPtrWillBeRawPtr<InterpolableValue> LengthBoxStyleInterpolation::lengthBox |
| bool LengthBoxStyleInterpolation::usesDefaultInterpolation(const CSSValue& start, const CSSValue& end) |
| { |
| - if (!start.isPrimitiveValue() || !end.isPrimitiveValue()) |
| + if (start.isPrimitiveValue() && end.isPrimitiveValue()) { |
| + const CSSPrimitiveValue& startValue = toCSSPrimitiveValue(start); |
| + const CSSPrimitiveValue& endValue = toCSSPrimitiveValue(end); |
| + if ((startValue.isValueID() && startValue.getValueID() == CSSValueAuto) |
|
Timothy Loh
2015/08/24 03:18:04
return .. || ..?
sashab
2015/08/24 05:43:58
Done.
|
| + || (endValue.isValueID() && endValue.getValueID() == CSSValueAuto)) |
| + return true; |
| return false; |
| - const CSSPrimitiveValue& startValue = toCSSPrimitiveValue(start); |
| - const CSSPrimitiveValue& endValue = toCSSPrimitiveValue(end); |
| - if ((startValue.isValueID() && startValue.getValueID() == CSSValueAuto) |
| - || (endValue.isValueID() && endValue.getValueID() == CSSValueAuto)) |
| - return true; |
| - return onlyInterpolateBetweenLengthAndCSSValueAuto(*startValue.getRectValue(), *endValue.getRectValue()); |
| + } |
| + |
| + if (!start.isQuadValue() || !end.isQuadValue()) |
| + return false; |
| + |
| + const CSSQuadValue& startValue = toCSSQuadValue(start); |
| + const CSSQuadValue& endValue = toCSSQuadValue(end); |
| + return onlyInterpolateBetweenLengthAndCSSValueAuto(startValue, endValue); |
| } |
| namespace { |
| @@ -80,18 +87,17 @@ PassRefPtrWillBeRawPtr<CSSPrimitiveValue> indexedValueToLength(InterpolableList& |
| PassRefPtrWillBeRawPtr<CSSValue> LengthBoxStyleInterpolation::interpolableValueToLengthBox(InterpolableValue* value, const CSSValue& originalStart, const CSSValue& originalEnd) |
| { |
| InterpolableList* lengthBox = toInterpolableList(value); |
| - Rect* startRect = toCSSPrimitiveValue(originalStart).getRectValue(); |
| - Rect* endRect = toCSSPrimitiveValue(originalEnd).getRectValue(); |
| - CSSPrimitiveValue* startSides[4] = { startRect->left(), startRect->right(), startRect->top(), startRect->bottom() }; |
| - CSSPrimitiveValue* endSides[4] = { endRect->left(), endRect->right(), endRect->top(), endRect->bottom() }; |
| - RefPtrWillBeRawPtr<Rect> result = Rect::create(); |
| - |
| - result->setLeft(indexedValueToLength(*lengthBox, 0, startSides, endSides)); |
| - result->setRight(indexedValueToLength(*lengthBox, 1, startSides, endSides)); |
| - result->setTop(indexedValueToLength(*lengthBox, 2, startSides, endSides)); |
| - result->setBottom(indexedValueToLength(*lengthBox, 3, startSides, endSides)); |
| - |
| - return CSSPrimitiveValue::create(result.release()); |
| + const CSSQuadValue& startRect = toCSSQuadValue(originalStart); |
| + const CSSQuadValue& endRect = toCSSQuadValue(originalEnd); |
| + CSSPrimitiveValue* startSides[4] = { startRect.left(), startRect.right(), startRect.top(), startRect.bottom() }; |
| + CSSPrimitiveValue* endSides[4] = { endRect.left(), endRect.right(), endRect.top(), endRect.bottom() }; |
| + |
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> left = indexedValueToLength(*lengthBox, 0, startSides, endSides); |
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> right = indexedValueToLength(*lengthBox, 1, startSides, endSides); |
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> top = indexedValueToLength(*lengthBox, 2, startSides, endSides); |
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = indexedValueToLength(*lengthBox, 3, startSides, endSides); |
| + |
| + return CSSQuadValue::createRect(top, right, bottom, left); |
| } |
| void LengthBoxStyleInterpolation::apply(StyleResolverState& state) const |