| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/animation/LengthBoxStyleInterpolation.h" | 5 #include "core/animation/LengthBoxStyleInterpolation.h" |
| 6 | 6 |
| 7 #include "core/css/CSSQuadValue.h" | 7 #include "core/css/CSSQuadValue.h" |
| 8 #include "core/css/resolver/StyleBuilder.h" | 8 #include "core/css/resolver/StyleBuilder.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if (!start.isQuadValue() || !end.isQuadValue()) | 63 if (!start.isQuadValue() || !end.isQuadValue()) |
| 64 return false; | 64 return false; |
| 65 | 65 |
| 66 const CSSQuadValue& startValue = toCSSQuadValue(start); | 66 const CSSQuadValue& startValue = toCSSQuadValue(start); |
| 67 const CSSQuadValue& endValue = toCSSQuadValue(end); | 67 const CSSQuadValue& endValue = toCSSQuadValue(end); |
| 68 return onlyInterpolateBetweenLengthAndCSSValueAuto(startValue, endValue); | 68 return onlyInterpolateBetweenLengthAndCSSValueAuto(startValue, endValue); |
| 69 } | 69 } |
| 70 | 70 |
| 71 namespace { | 71 namespace { |
| 72 | 72 |
| 73 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> indexedValueToLength(InterpolableList&
lengthBox, size_t i, CSSPrimitiveValue* start[], CSSPrimitiveValue* end[]) | 73 RawPtr<CSSPrimitiveValue> indexedValueToLength(InterpolableList& lengthBox, size
_t i, CSSPrimitiveValue* start[], CSSPrimitiveValue* end[]) |
| 74 { | 74 { |
| 75 if (lengthBox.get(i)->isBool()) { | 75 if (lengthBox.get(i)->isBool()) { |
| 76 if (toInterpolableBool(lengthBox.get(i))->value()) | 76 if (toInterpolableBool(lengthBox.get(i))->value()) |
| 77 return end[i]; | 77 return end[i]; |
| 78 return start[i]; | 78 return start[i]; |
| 79 } | 79 } |
| 80 return LengthStyleInterpolation::fromInterpolableValue(*lengthBox.get(i), Ra
ngeAll); | 80 return LengthStyleInterpolation::fromInterpolableValue(*lengthBox.get(i), Ra
ngeAll); |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace | 83 } // namespace |
| 84 | 84 |
| 85 PassRefPtrWillBeRawPtr<CSSValue> LengthBoxStyleInterpolation::interpolableValueT
oLengthBox(InterpolableValue* value, const CSSValue& originalStart, const CSSVal
ue& originalEnd) | 85 RawPtr<CSSValue> LengthBoxStyleInterpolation::interpolableValueToLengthBox(Inter
polableValue* value, const CSSValue& originalStart, const CSSValue& originalEnd) |
| 86 { | 86 { |
| 87 InterpolableList* lengthBox = toInterpolableList(value); | 87 InterpolableList* lengthBox = toInterpolableList(value); |
| 88 const CSSQuadValue& startRect = toCSSQuadValue(originalStart); | 88 const CSSQuadValue& startRect = toCSSQuadValue(originalStart); |
| 89 const CSSQuadValue& endRect = toCSSQuadValue(originalEnd); | 89 const CSSQuadValue& endRect = toCSSQuadValue(originalEnd); |
| 90 CSSPrimitiveValue* startSides[4] = { startRect.left(), startRect.right(), st
artRect.top(), startRect.bottom() }; | 90 CSSPrimitiveValue* startSides[4] = { startRect.left(), startRect.right(), st
artRect.top(), startRect.bottom() }; |
| 91 CSSPrimitiveValue* endSides[4] = { endRect.left(), endRect.right(), endRect.
top(), endRect.bottom() }; | 91 CSSPrimitiveValue* endSides[4] = { endRect.left(), endRect.right(), endRect.
top(), endRect.bottom() }; |
| 92 | 92 |
| 93 RefPtrWillBeRawPtr<CSSPrimitiveValue> left = indexedValueToLength(*lengthBox
, 0, startSides, endSides); | 93 RawPtr<CSSPrimitiveValue> left = indexedValueToLength(*lengthBox, 0, startSi
des, endSides); |
| 94 RefPtrWillBeRawPtr<CSSPrimitiveValue> right = indexedValueToLength(*lengthBo
x, 1, startSides, endSides); | 94 RawPtr<CSSPrimitiveValue> right = indexedValueToLength(*lengthBox, 1, startS
ides, endSides); |
| 95 RefPtrWillBeRawPtr<CSSPrimitiveValue> top = indexedValueToLength(*lengthBox,
2, startSides, endSides); | 95 RawPtr<CSSPrimitiveValue> top = indexedValueToLength(*lengthBox, 2, startSid
es, endSides); |
| 96 RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = indexedValueToLength(*lengthB
ox, 3, startSides, endSides); | 96 RawPtr<CSSPrimitiveValue> bottom = indexedValueToLength(*lengthBox, 3, start
Sides, endSides); |
| 97 | 97 |
| 98 return CSSQuadValue::create(top.release(), right.release(), bottom.release()
, left.release(), CSSQuadValue::SerializeAsRect); | 98 return CSSQuadValue::create(top.release(), right.release(), bottom.release()
, left.release(), CSSQuadValue::SerializeAsRect); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void LengthBoxStyleInterpolation::apply(StyleResolverState& state) const | 101 void LengthBoxStyleInterpolation::apply(StyleResolverState& state) const |
| 102 { | 102 { |
| 103 if (m_cachedValue.get()->isBool()) | 103 if (m_cachedValue.get()->isBool()) |
| 104 StyleBuilder::applyProperty(m_id, state, toInterpolableBool(m_cachedValu
e.get())->value() ? m_endCSSValue.get() : m_startCSSValue.get()); | 104 StyleBuilder::applyProperty(m_id, state, toInterpolableBool(m_cachedValu
e.get())->value() ? m_endCSSValue.get() : m_startCSSValue.get()); |
| 105 else | 105 else |
| 106 StyleBuilder::applyProperty(m_id, state, interpolableValueToLengthBox(m_
cachedValue.get(), *m_startCSSValue, *m_endCSSValue).get()); | 106 StyleBuilder::applyProperty(m_id, state, interpolableValueToLengthBox(m_
cachedValue.get(), *m_startCSSValue, *m_endCSSValue).get()); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace blink | 109 } // namespace blink |
| OLD | NEW |