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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> indexedValueToLength(InterpolableList&
lengthBox, size_t i, CSSPrimitiveValue* start[], CSSPrimitiveValue* end[]) | 73 PassRefPtrWillBeRawPtr<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 } | 83 } // namespace |
84 | 84 |
85 PassRefPtrWillBeRawPtr<CSSValue> LengthBoxStyleInterpolation::interpolableValueT
oLengthBox(InterpolableValue* value, const CSSValue& originalStart, const CSSVal
ue& originalEnd) | 85 PassRefPtrWillBeRawPtr<CSSValue> LengthBoxStyleInterpolation::interpolableValueT
oLengthBox(InterpolableValue* value, const CSSValue& originalStart, const CSSVal
ue& 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 RefPtrWillBeRawPtr<CSSPrimitiveValue> left = indexedValueToLength(*lengthBox
, 0, startSides, endSides); |
94 RefPtrWillBeRawPtr<CSSPrimitiveValue> right = indexedValueToLength(*lengthBo
x, 1, startSides, endSides); | 94 RefPtrWillBeRawPtr<CSSPrimitiveValue> right = indexedValueToLength(*lengthBo
x, 1, startSides, endSides); |
95 RefPtrWillBeRawPtr<CSSPrimitiveValue> top = indexedValueToLength(*lengthBox,
2, startSides, endSides); | 95 RefPtrWillBeRawPtr<CSSPrimitiveValue> top = indexedValueToLength(*lengthBox,
2, startSides, endSides); |
96 RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = indexedValueToLength(*lengthB
ox, 3, startSides, endSides); | 96 RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = indexedValueToLength(*lengthB
ox, 3, startSides, 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 } | 109 } // namespace blink |
OLD | NEW |