| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/animation/LengthBoxStyleInterpolation.h" | 6 #include "core/animation/LengthBoxStyleInterpolation.h" |
| 7 | 7 |
| 8 #include "core/css/resolver/StyleBuilder.h" | 8 #include "core/css/resolver/StyleBuilder.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 const CSSPrimitiveValue& startValue = toCSSPrimitiveValue(start); | 58 const CSSPrimitiveValue& startValue = toCSSPrimitiveValue(start); |
| 59 const CSSPrimitiveValue& endValue = toCSSPrimitiveValue(end); | 59 const CSSPrimitiveValue& endValue = toCSSPrimitiveValue(end); |
| 60 if ((startValue.isValueID() && startValue.getValueID() == CSSValueAuto) | 60 if ((startValue.isValueID() && startValue.getValueID() == CSSValueAuto) |
| 61 || (endValue.isValueID() && endValue.getValueID() == CSSValueAuto)) | 61 || (endValue.isValueID() && endValue.getValueID() == CSSValueAuto)) |
| 62 return true; | 62 return true; |
| 63 return onlyInterpolateBetweenLengthAndCSSValueAuto(*startValue.getRectValue(
), *endValue.getRectValue()); | 63 return onlyInterpolateBetweenLengthAndCSSValueAuto(*startValue.getRectValue(
), *endValue.getRectValue()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 namespace { | 66 namespace { |
| 67 | 67 |
| 68 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> indexedValueToLength(InterpolableList&
lengthBox, size_t i, CSSPrimitiveValue* start[], CSSPrimitiveValue* end[]) | 68 PassRefPtr<CSSPrimitiveValue> indexedValueToLength(InterpolableList& lengthBox,
size_t i, CSSPrimitiveValue* start[], CSSPrimitiveValue* end[]) |
| 69 { | 69 { |
| 70 if (lengthBox.get(i)->isBool()) { | 70 if (lengthBox.get(i)->isBool()) { |
| 71 if (toInterpolableBool(lengthBox.get(i))->value()) | 71 if (toInterpolableBool(lengthBox.get(i))->value()) |
| 72 return end[i]; | 72 return end[i]; |
| 73 return start[i]; | 73 return start[i]; |
| 74 } | 74 } |
| 75 return LengthStyleInterpolation::fromInterpolableValue(*lengthBox.get(i), Ra
ngeAll); | 75 return LengthStyleInterpolation::fromInterpolableValue(*lengthBox.get(i), Ra
ngeAll); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } | 78 } |
| 79 | 79 |
| 80 PassRefPtrWillBeRawPtr<CSSValue> LengthBoxStyleInterpolation::interpolableValueT
oLengthBox(InterpolableValue* value, const CSSValue& originalStart, const CSSVal
ue& originalEnd) | 80 PassRefPtr<CSSValue> LengthBoxStyleInterpolation::interpolableValueToLengthBox(I
nterpolableValue* value, const CSSValue& originalStart, const CSSValue& original
End) |
| 81 { | 81 { |
| 82 InterpolableList* lengthBox = toInterpolableList(value); | 82 InterpolableList* lengthBox = toInterpolableList(value); |
| 83 Rect* startRect = toCSSPrimitiveValue(originalStart).getRectValue(); | 83 Rect* startRect = toCSSPrimitiveValue(originalStart).getRectValue(); |
| 84 Rect* endRect = toCSSPrimitiveValue(originalEnd).getRectValue(); | 84 Rect* endRect = toCSSPrimitiveValue(originalEnd).getRectValue(); |
| 85 CSSPrimitiveValue* startSides[4] = { startRect->left(), startRect->right(),
startRect->top(), startRect->bottom() }; | 85 CSSPrimitiveValue* startSides[4] = { startRect->left(), startRect->right(),
startRect->top(), startRect->bottom() }; |
| 86 CSSPrimitiveValue* endSides[4] = { endRect->left(), endRect->right(), endRec
t->top(), endRect->bottom() }; | 86 CSSPrimitiveValue* endSides[4] = { endRect->left(), endRect->right(), endRec
t->top(), endRect->bottom() }; |
| 87 RefPtrWillBeRawPtr<Rect> result = Rect::create(); | 87 RefPtr<Rect> result = Rect::create(); |
| 88 | 88 |
| 89 result->setLeft(indexedValueToLength(*lengthBox, 0, startSides, endSides)); | 89 result->setLeft(indexedValueToLength(*lengthBox, 0, startSides, endSides)); |
| 90 result->setRight(indexedValueToLength(*lengthBox, 1, startSides, endSides)); | 90 result->setRight(indexedValueToLength(*lengthBox, 1, startSides, endSides)); |
| 91 result->setTop(indexedValueToLength(*lengthBox, 2, startSides, endSides)); | 91 result->setTop(indexedValueToLength(*lengthBox, 2, startSides, endSides)); |
| 92 result->setBottom(indexedValueToLength(*lengthBox, 3, startSides, endSides))
; | 92 result->setBottom(indexedValueToLength(*lengthBox, 3, startSides, endSides))
; |
| 93 | 93 |
| 94 return CSSPrimitiveValue::create(result.release()); | 94 return CSSPrimitiveValue::create(result.release()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void LengthBoxStyleInterpolation::apply(StyleResolverState& state) const | 97 void LengthBoxStyleInterpolation::apply(StyleResolverState& state) const |
| 98 { | 98 { |
| 99 if (m_cachedValue.get()->isBool()) | 99 if (m_cachedValue.get()->isBool()) |
| 100 StyleBuilder::applyProperty(m_id, state, toInterpolableBool(m_cachedValu
e.get())->value() ? m_endCSSValue.get() : m_startCSSValue.get()); | 100 StyleBuilder::applyProperty(m_id, state, toInterpolableBool(m_cachedValu
e.get())->value() ? m_endCSSValue.get() : m_startCSSValue.get()); |
| 101 else | 101 else |
| 102 StyleBuilder::applyProperty(m_id, state, interpolableValueToLengthBox(m_
cachedValue.get(), *m_startCSSValue, *m_endCSSValue).get()); | 102 StyleBuilder::applyProperty(m_id, state, interpolableValueToLengthBox(m_
cachedValue.get(), *m_startCSSValue, *m_endCSSValue).get()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 DEFINE_TRACE(LengthBoxStyleInterpolation) | 105 DEFINE_TRACE(LengthBoxStyleInterpolation) |
| 106 { | 106 { |
| 107 StyleInterpolation::trace(visitor); | 107 StyleInterpolation::trace(visitor); |
| 108 visitor->trace(m_startCSSValue); | |
| 109 visitor->trace(m_endCSSValue); | |
| 110 } | 108 } |
| 111 | 109 |
| 112 } | 110 } |
| OLD | NEW |