Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: third_party/WebKit/Source/core/animation/ShadowInterpolationFunctions.cpp

Issue 2283783002: Move static methods out of CSSLengthInterpolationType to LengthInterpolationFunctions (Closed)
Patch Set: Fix compile Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/animation/LengthInterpolationFunctions.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/animation/ShadowInterpolationFunctions.h" 5 #include "core/animation/ShadowInterpolationFunctions.h"
6 6
7 #include "core/animation/CSSColorInterpolationType.h" 7 #include "core/animation/CSSColorInterpolationType.h"
8 #include "core/animation/CSSLengthInterpolationType.h"
9 #include "core/animation/InterpolationValue.h" 8 #include "core/animation/InterpolationValue.h"
9 #include "core/animation/LengthInterpolationFunctions.h"
10 #include "core/animation/NonInterpolableValue.h" 10 #include "core/animation/NonInterpolableValue.h"
11 #include "core/css/CSSShadowValue.h" 11 #include "core/css/CSSShadowValue.h"
12 #include "core/css/resolver/StyleResolverState.h" 12 #include "core/css/resolver/StyleResolverState.h"
13 #include "core/style/ShadowData.h" 13 #include "core/style/ShadowData.h"
14 #include "platform/geometry/FloatPoint.h" 14 #include "platform/geometry/FloatPoint.h"
15 #include <memory> 15 #include <memory>
16 16
17 namespace blink { 17 namespace blink {
18 18
19 enum ShadowComponentIndex : unsigned { 19 enum ShadowComponentIndex : unsigned {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 PairwiseInterpolationValue ShadowInterpolationFunctions::maybeMergeSingles(Inter polationValue&& start, InterpolationValue&& end) 57 PairwiseInterpolationValue ShadowInterpolationFunctions::maybeMergeSingles(Inter polationValue&& start, InterpolationValue&& 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 PairwiseInterpolationValue(std::move(start.interpolableValue), std::m ove(end.interpolableValue), start.nonInterpolableValue.release()); 61 return PairwiseInterpolationValue(std::move(start.interpolableValue), std::m ove(end.interpolableValue), start.nonInterpolableValue.release());
62 } 62 }
63 63
64 InterpolationValue ShadowInterpolationFunctions::convertShadowData(const ShadowD ata& shadowData, double zoom) 64 InterpolationValue ShadowInterpolationFunctions::convertShadowData(const ShadowD ata& shadowData, double zoom)
65 { 65 {
66 std::unique_ptr<InterpolableList> interpolableList = InterpolableList::creat e(ShadowComponentIndexCount); 66 std::unique_ptr<InterpolableList> interpolableList = InterpolableList::creat e(ShadowComponentIndexCount);
67 interpolableList->set(ShadowX, CSSLengthInterpolationType::createInterpolabl ePixels(shadowData.x() / zoom)); 67 interpolableList->set(ShadowX, LengthInterpolationFunctions::createInterpola blePixels(shadowData.x() / zoom));
68 interpolableList->set(ShadowY, CSSLengthInterpolationType::createInterpolabl ePixels(shadowData.y() / zoom)); 68 interpolableList->set(ShadowY, LengthInterpolationFunctions::createInterpola blePixels(shadowData.y() / zoom));
69 interpolableList->set(ShadowBlur, CSSLengthInterpolationType::createInterpol ablePixels(shadowData.blur() / zoom)); 69 interpolableList->set(ShadowBlur, LengthInterpolationFunctions::createInterp olablePixels(shadowData.blur() / zoom));
70 interpolableList->set(ShadowSpread, CSSLengthInterpolationType::createInterp olablePixels(shadowData.spread() / zoom)); 70 interpolableList->set(ShadowSpread, LengthInterpolationFunctions::createInte rpolablePixels(shadowData.spread() / zoom));
71 interpolableList->set(ShadowColor, CSSColorInterpolationType::createInterpol ableColor(shadowData.color())); 71 interpolableList->set(ShadowColor, CSSColorInterpolationType::createInterpol ableColor(shadowData.color()));
72 return InterpolationValue(std::move(interpolableList), ShadowNonInterpolable Value::create(shadowData.style())); 72 return InterpolationValue(std::move(interpolableList), ShadowNonInterpolable Value::create(shadowData.style()));
73 } 73 }
74 74
75 InterpolationValue ShadowInterpolationFunctions::maybeConvertCSSValue(const CSSV alue& value) 75 InterpolationValue ShadowInterpolationFunctions::maybeConvertCSSValue(const CSSV alue& 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
(...skipping 11 matching lines...) Expand all
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 InterpolationValue lengthField = CSSLengthInterpolationType::maybeCo nvertCSSValue(*lengths[i]); 102 InterpolationValue lengthField = LengthInterpolationFunctions::maybe ConvertCSSValue(*lengths[i]);
103 if (!lengthField) 103 if (!lengthField)
104 return nullptr; 104 return nullptr;
105 DCHECK(!lengthField.nonInterpolableValue); 105 DCHECK(!lengthField.nonInterpolableValue);
106 interpolableList->set(i, std::move(lengthField.interpolableValue)); 106 interpolableList->set(i, std::move(lengthField.interpolableValue));
107 } else { 107 } else {
108 interpolableList->set(i, CSSLengthInterpolationType::createInterpola blePixels(0)); 108 interpolableList->set(i, LengthInterpolationFunctions::createInterpo lablePixels(0));
109 } 109 }
110 } 110 }
111 111
112 if (shadow.color) { 112 if (shadow.color) {
113 std::unique_ptr<InterpolableValue> interpolableColor = CSSColorInterpola tionType::maybeCreateInterpolableColor(*shadow.color); 113 std::unique_ptr<InterpolableValue> interpolableColor = CSSColorInterpola tionType::maybeCreateInterpolableColor(*shadow.color);
114 if (!interpolableColor) 114 if (!interpolableColor)
115 return nullptr; 115 return nullptr;
116 interpolableList->set(ShadowColor, std::move(interpolableColor)); 116 interpolableList->set(ShadowColor, std::move(interpolableColor));
117 } else { 117 } else {
118 interpolableList->set(ShadowColor, CSSColorInterpolationType::createInte rpolableColor(StyleColor::currentColor())); 118 interpolableList->set(ShadowColor, CSSColorInterpolationType::createInte rpolableColor(StyleColor::currentColor()));
(...skipping 13 matching lines...) Expand all
132 InterpolableList& underlyingInterpolableList = toInterpolableList(*underlyin gInterpolableValue); 132 InterpolableList& underlyingInterpolableList = toInterpolableList(*underlyin gInterpolableValue);
133 const InterpolableList& interpolableList = toInterpolableList(interpolableVa lue); 133 const InterpolableList& interpolableList = toInterpolableList(interpolableVa lue);
134 underlyingInterpolableList.scaleAndAdd(underlyingFraction, interpolableList) ; 134 underlyingInterpolableList.scaleAndAdd(underlyingFraction, interpolableList) ;
135 } 135 }
136 136
137 ShadowData ShadowInterpolationFunctions::createShadowData(const InterpolableValu e& interpolableValue, const NonInterpolableValue* nonInterpolableValue, const St yleResolverState& state) 137 ShadowData ShadowInterpolationFunctions::createShadowData(const InterpolableValu e& interpolableValue, const NonInterpolableValue* nonInterpolableValue, const St yleResolverState& state)
138 { 138 {
139 const InterpolableList& interpolableList = toInterpolableList(interpolableVa lue); 139 const InterpolableList& interpolableList = toInterpolableList(interpolableVa lue);
140 const ShadowNonInterpolableValue& shadowNonInterpolableValue = toShadowNonIn terpolableValue(*nonInterpolableValue); 140 const ShadowNonInterpolableValue& shadowNonInterpolableValue = toShadowNonIn terpolableValue(*nonInterpolableValue);
141 const CSSToLengthConversionData& conversionData = state.cssToLengthConversio nData(); 141 const CSSToLengthConversionData& conversionData = state.cssToLengthConversio nData();
142 Length shadowX = CSSLengthInterpolationType::createLength(*interpolableList. get(ShadowX), nullptr, conversionData); 142 Length shadowX = LengthInterpolationFunctions::createLength(*interpolableLis t.get(ShadowX), nullptr, conversionData, ValueRangeAll);
143 Length shadowY = CSSLengthInterpolationType::createLength(*interpolableList. get(ShadowY), nullptr, conversionData); 143 Length shadowY = LengthInterpolationFunctions::createLength(*interpolableLis t.get(ShadowY), nullptr, conversionData, ValueRangeAll);
144 Length shadowBlur = CSSLengthInterpolationType::createLength(*interpolableLi st.get(ShadowBlur), nullptr, conversionData, ValueRangeNonNegative); 144 Length shadowBlur = LengthInterpolationFunctions::createLength(*interpolable List.get(ShadowBlur), nullptr, conversionData, ValueRangeNonNegative);
145 Length shadowSpread = CSSLengthInterpolationType::createLength(*interpolable List.get(ShadowSpread), nullptr, conversionData); 145 Length shadowSpread = LengthInterpolationFunctions::createLength(*interpolab leList.get(ShadowSpread), nullptr, conversionData, ValueRangeAll);
146 DCHECK(shadowX.isFixed() && shadowY.isFixed() && shadowBlur.isFixed() && sha dowSpread.isFixed()); 146 DCHECK(shadowX.isFixed() && shadowY.isFixed() && shadowBlur.isFixed() && sha dowSpread.isFixed());
147 return ShadowData( 147 return ShadowData(
148 FloatPoint(shadowX.value(), shadowY.value()), shadowBlur.value(), shadow Spread.value(), shadowNonInterpolableValue.style(), 148 FloatPoint(shadowX.value(), shadowY.value()), shadowBlur.value(), shadow Spread.value(), shadowNonInterpolableValue.style(),
149 CSSColorInterpolationType::resolveInterpolableColor(*interpolableList.ge t(ShadowColor), state)); 149 CSSColorInterpolationType::resolveInterpolableColor(*interpolableList.ge t(ShadowColor), state));
150 } 150 }
151 151
152 } // namespace blink 152 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/LengthInterpolationFunctions.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698