| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ShadowInterpolationFunctions.h" | 6 #include "core/animation/ShadowInterpolationFunctions.h" |
| 7 | 7 |
| 8 #include "core/animation/ColorInterpolationType.h" | 8 #include "core/animation/CSSColorInterpolationType.h" |
| 9 #include "core/animation/CSSLengthInterpolationType.h" |
| 9 #include "core/animation/InterpolationValue.h" | 10 #include "core/animation/InterpolationValue.h" |
| 10 #include "core/animation/LengthInterpolationType.h" | |
| 11 #include "core/animation/NonInterpolableValue.h" | 11 #include "core/animation/NonInterpolableValue.h" |
| 12 #include "core/css/CSSShadowValue.h" | 12 #include "core/css/CSSShadowValue.h" |
| 13 #include "core/css/resolver/StyleResolverState.h" | 13 #include "core/css/resolver/StyleResolverState.h" |
| 14 #include "core/style/ShadowData.h" | 14 #include "core/style/ShadowData.h" |
| 15 #include "platform/geometry/FloatPoint.h" | 15 #include "platform/geometry/FloatPoint.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 enum ShadowComponentIndex { | 19 enum ShadowComponentIndex { |
| 20 ShadowX, | 20 ShadowX, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 PairwiseInterpolationComponent ShadowInterpolationFunctions::mergeSingleConversi
ons(InterpolationComponent& start, InterpolationComponent& end) | 57 PairwiseInterpolationComponent ShadowInterpolationFunctions::mergeSingleConversi
ons(InterpolationComponent& start, InterpolationComponent& end) |
| 58 { | 58 { |
| 59 if (!nonInterpolableValuesAreCompatible(start.nonInterpolableValue.get(), en
d.nonInterpolableValue.get())) | 59 if (!nonInterpolableValuesAreCompatible(start.nonInterpolableValue.get(), en
d.nonInterpolableValue.get())) |
| 60 return nullptr; | 60 return nullptr; |
| 61 return PairwiseInterpolationComponent(start.interpolableValue.release(), end
.interpolableValue.release(), start.nonInterpolableValue.release()); | 61 return PairwiseInterpolationComponent(start.interpolableValue.release(), end
.interpolableValue.release(), start.nonInterpolableValue.release()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 InterpolationComponent ShadowInterpolationFunctions::convertShadowData(const Sha
dowData& shadowData, double zoom) | 64 InterpolationComponent ShadowInterpolationFunctions::convertShadowData(const Sha
dowData& shadowData, double zoom) |
| 65 { | 65 { |
| 66 OwnPtr<InterpolableList> interpolableList = InterpolableList::create(ShadowC
omponentIndexCount); | 66 OwnPtr<InterpolableList> interpolableList = InterpolableList::create(ShadowC
omponentIndexCount); |
| 67 interpolableList->set(ShadowX, LengthInterpolationType::createInterpolablePi
xels(shadowData.x() / zoom)); | 67 interpolableList->set(ShadowX, CSSLengthInterpolationType::createInterpolabl
ePixels(shadowData.x() / zoom)); |
| 68 interpolableList->set(ShadowY, LengthInterpolationType::createInterpolablePi
xels(shadowData.y() / zoom)); | 68 interpolableList->set(ShadowY, CSSLengthInterpolationType::createInterpolabl
ePixels(shadowData.y() / zoom)); |
| 69 interpolableList->set(ShadowBlur, LengthInterpolationType::createInterpolabl
ePixels(shadowData.blur() / zoom)); | 69 interpolableList->set(ShadowBlur, CSSLengthInterpolationType::createInterpol
ablePixels(shadowData.blur() / zoom)); |
| 70 interpolableList->set(ShadowSpread, LengthInterpolationType::createInterpola
blePixels(shadowData.spread() / zoom)); | 70 interpolableList->set(ShadowSpread, CSSLengthInterpolationType::createInterp
olablePixels(shadowData.spread() / zoom)); |
| 71 interpolableList->set(ShadowColor, ColorInterpolationType::createInterpolabl
eColor(shadowData.color())); | 71 interpolableList->set(ShadowColor, CSSColorInterpolationType::createInterpol
ableColor(shadowData.color())); |
| 72 return InterpolationComponent(interpolableList.release(), ShadowNonInterpola
bleValue::create(shadowData.style())); | 72 return InterpolationComponent(interpolableList.release(), ShadowNonInterpola
bleValue::create(shadowData.style())); |
| 73 } | 73 } |
| 74 | 74 |
| 75 InterpolationComponent ShadowInterpolationFunctions::maybeConvertCSSValue(const
CSSValue& value) | 75 InterpolationComponent ShadowInterpolationFunctions::maybeConvertCSSValue(const
CSSValue& value) |
| 76 { | 76 { |
| 77 if (!value.isShadowValue()) | 77 if (!value.isShadowValue()) |
| 78 return nullptr; | 78 return nullptr; |
| 79 const CSSShadowValue& shadow = toCSSShadowValue(value); | 79 const CSSShadowValue& shadow = toCSSShadowValue(value); |
| 80 | 80 |
| 81 ShadowStyle style = Normal; | 81 ShadowStyle style = Normal; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 static_assert(ShadowBlur == 2, "Enum ordering check."); | 92 static_assert(ShadowBlur == 2, "Enum ordering check."); |
| 93 static_assert(ShadowSpread == 3, "Enum ordering check."); | 93 static_assert(ShadowSpread == 3, "Enum ordering check."); |
| 94 const CSSPrimitiveValue* lengths[] = { | 94 const CSSPrimitiveValue* lengths[] = { |
| 95 shadow.x.get(), | 95 shadow.x.get(), |
| 96 shadow.y.get(), | 96 shadow.y.get(), |
| 97 shadow.blur.get(), | 97 shadow.blur.get(), |
| 98 shadow.spread.get(), | 98 shadow.spread.get(), |
| 99 }; | 99 }; |
| 100 for (size_t i = 0; i < WTF_ARRAY_LENGTH(lengths); i++) { | 100 for (size_t i = 0; i < WTF_ARRAY_LENGTH(lengths); i++) { |
| 101 if (lengths[i]) { | 101 if (lengths[i]) { |
| 102 InterpolationComponent component = LengthInterpolationType::maybeCon
vertCSSValue(*lengths[i]); | 102 InterpolationComponent component = CSSLengthInterpolationType::maybe
ConvertCSSValue(*lengths[i]); |
| 103 if (!component) | 103 if (!component) |
| 104 return nullptr; | 104 return nullptr; |
| 105 ASSERT(!component.nonInterpolableValue); | 105 ASSERT(!component.nonInterpolableValue); |
| 106 interpolableList->set(i, component.interpolableValue.release()); | 106 interpolableList->set(i, component.interpolableValue.release()); |
| 107 } else { | 107 } else { |
| 108 interpolableList->set(i, LengthInterpolationType::createInterpolable
Pixels(0)); | 108 interpolableList->set(i, CSSLengthInterpolationType::createInterpola
blePixels(0)); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 if (shadow.color) { | 112 if (shadow.color) { |
| 113 OwnPtr<InterpolableValue> interpolableColor = ColorInterpolationType::ma
ybeCreateInterpolableColor(*shadow.color); | 113 OwnPtr<InterpolableValue> interpolableColor = CSSColorInterpolationType:
:maybeCreateInterpolableColor(*shadow.color); |
| 114 if (!interpolableColor) | 114 if (!interpolableColor) |
| 115 return nullptr; | 115 return nullptr; |
| 116 interpolableList->set(ShadowColor, interpolableColor.release()); | 116 interpolableList->set(ShadowColor, interpolableColor.release()); |
| 117 } else { | 117 } else { |
| 118 interpolableList->set(ShadowColor, ColorInterpolationType::createInterpo
lableColor(StyleColor::currentColor())); | 118 interpolableList->set(ShadowColor, CSSColorInterpolationType::createInte
rpolableColor(StyleColor::currentColor())); |
| 119 } | 119 } |
| 120 | 120 |
| 121 return InterpolationComponent(interpolableList.release(), ShadowNonInterpola
bleValue::create(style)); | 121 return InterpolationComponent(interpolableList.release(), ShadowNonInterpola
bleValue::create(style)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void ShadowInterpolationFunctions::composite(OwnPtr<InterpolableValue>& underlyi
ngInterpolableValue, RefPtr<NonInterpolableValue>& underlyingNonInterpolableValu
e, double underlyingFraction, const InterpolableValue& interpolableValue, const
NonInterpolableValue* nonInterpolableValue) | 124 void ShadowInterpolationFunctions::composite(OwnPtr<InterpolableValue>& underlyi
ngInterpolableValue, RefPtr<NonInterpolableValue>& underlyingNonInterpolableValu
e, double underlyingFraction, const InterpolableValue& interpolableValue, const
NonInterpolableValue* nonInterpolableValue) |
| 125 { | 125 { |
| 126 ASSERT(nonInterpolableValuesAreCompatible(underlyingNonInterpolableValue.get
(), nonInterpolableValue)); | 126 ASSERT(nonInterpolableValuesAreCompatible(underlyingNonInterpolableValue.get
(), nonInterpolableValue)); |
| 127 InterpolableList& underlyingInterpolableList = toInterpolableList(*underlyin
gInterpolableValue); | 127 InterpolableList& underlyingInterpolableList = toInterpolableList(*underlyin
gInterpolableValue); |
| 128 const InterpolableList& interpolableList = toInterpolableList(interpolableVa
lue); | 128 const InterpolableList& interpolableList = toInterpolableList(interpolableVa
lue); |
| 129 underlyingInterpolableList.scaleAndAdd(underlyingFraction, interpolableList)
; | 129 underlyingInterpolableList.scaleAndAdd(underlyingFraction, interpolableList)
; |
| 130 } | 130 } |
| 131 | 131 |
| 132 ShadowData ShadowInterpolationFunctions::createShadowData(const InterpolableValu
e& interpolableValue, const NonInterpolableValue* nonInterpolableValue, const St
yleResolverState& state) | 132 ShadowData ShadowInterpolationFunctions::createShadowData(const InterpolableValu
e& interpolableValue, const NonInterpolableValue* nonInterpolableValue, const St
yleResolverState& state) |
| 133 { | 133 { |
| 134 const InterpolableList& interpolableList = toInterpolableList(interpolableVa
lue); | 134 const InterpolableList& interpolableList = toInterpolableList(interpolableVa
lue); |
| 135 const ShadowNonInterpolableValue& shadowNonInterpolableValue = toShadowNonIn
terpolableValue(*nonInterpolableValue); | 135 const ShadowNonInterpolableValue& shadowNonInterpolableValue = toShadowNonIn
terpolableValue(*nonInterpolableValue); |
| 136 const CSSToLengthConversionData& conversionData = state.cssToLengthConversio
nData(); | 136 const CSSToLengthConversionData& conversionData = state.cssToLengthConversio
nData(); |
| 137 Length shadowX = LengthInterpolationType::resolveInterpolableLength(*interpo
lableList.get(ShadowX), nullptr, conversionData); | 137 Length shadowX = CSSLengthInterpolationType::resolveInterpolableLength(*inte
rpolableList.get(ShadowX), nullptr, conversionData); |
| 138 Length shadowY = LengthInterpolationType::resolveInterpolableLength(*interpo
lableList.get(ShadowY), nullptr, conversionData); | 138 Length shadowY = CSSLengthInterpolationType::resolveInterpolableLength(*inte
rpolableList.get(ShadowY), nullptr, conversionData); |
| 139 Length shadowBlur = LengthInterpolationType::resolveInterpolableLength(*inte
rpolableList.get(ShadowBlur), nullptr, conversionData, ValueRangeNonNegative); | 139 Length shadowBlur = CSSLengthInterpolationType::resolveInterpolableLength(*i
nterpolableList.get(ShadowBlur), nullptr, conversionData, ValueRangeNonNegative)
; |
| 140 Length shadowSpread = LengthInterpolationType::resolveInterpolableLength(*in
terpolableList.get(ShadowSpread), nullptr, conversionData); | 140 Length shadowSpread = CSSLengthInterpolationType::resolveInterpolableLength(
*interpolableList.get(ShadowSpread), nullptr, conversionData); |
| 141 ASSERT(shadowX.isFixed() && shadowY.isFixed() && shadowBlur.isFixed() && sha
dowSpread.isFixed()); | 141 ASSERT(shadowX.isFixed() && shadowY.isFixed() && shadowBlur.isFixed() && sha
dowSpread.isFixed()); |
| 142 return ShadowData( | 142 return ShadowData( |
| 143 FloatPoint(shadowX.value(), shadowY.value()), shadowBlur.value(), shadow
Spread.value(), shadowNonInterpolableValue.style(), | 143 FloatPoint(shadowX.value(), shadowY.value()), shadowBlur.value(), shadow
Spread.value(), shadowNonInterpolableValue.style(), |
| 144 ColorInterpolationType::resolveInterpolableColor(*interpolableList.get(S
hadowColor), state)); | 144 CSSColorInterpolationType::resolveInterpolableColor(*interpolableList.ge
t(ShadowColor), state)); |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace blink | 147 } // namespace blink |
| OLD | NEW |