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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/BasicShapeInterpolationFunctions.h" 5 #include "core/animation/BasicShapeInterpolationFunctions.h"
6 6
7 #include "core/animation/CSSLengthInterpolationType.h" 7 #include "core/animation/CSSLengthInterpolationType.h"
8 #include "core/animation/CSSPositionAxisListInterpolationType.h" 8 #include "core/animation/CSSPositionAxisListInterpolationType.h"
9 #include "core/css/CSSBasicShapeValues.h" 9 #include "core/css/CSSBasicShapeValues.h"
10 #include "core/css/resolver/StyleResolverState.h" 10 #include "core/css/resolver/StyleResolverState.h"
11 #include "core/style/BasicShapes.h" 11 #include "core/style/BasicShapes.h"
12 #include <memory>
12 13
13 namespace blink { 14 namespace blink {
14 15
15 class BasicShapeNonInterpolableValue : public NonInterpolableValue { 16 class BasicShapeNonInterpolableValue : public NonInterpolableValue {
16 public: 17 public:
17 static PassRefPtr<NonInterpolableValue> create(BasicShape::ShapeType type) 18 static PassRefPtr<NonInterpolableValue> create(BasicShape::ShapeType type)
18 { 19 {
19 return adoptRef(new BasicShapeNonInterpolableValue(type)); 20 return adoptRef(new BasicShapeNonInterpolableValue(type));
20 } 21 }
21 static PassRefPtr<NonInterpolableValue> createPolygon(WindRule windRule, siz e_t size) 22 static PassRefPtr<NonInterpolableValue> createPolygon(WindRule windRule, siz e_t size)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 const BasicShape::ShapeType m_type; 66 const BasicShape::ShapeType m_type;
66 const WindRule m_windRule; 67 const WindRule m_windRule;
67 const size_t m_size; 68 const size_t m_size;
68 }; 69 };
69 70
70 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(BasicShapeNonInterpolableValue); 71 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(BasicShapeNonInterpolableValue);
71 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(BasicShapeNonInterpolableValue); 72 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(BasicShapeNonInterpolableValue);
72 73
73 namespace { 74 namespace {
74 75
75 PassOwnPtr<InterpolableValue> unwrap(InterpolationValue&& value) 76 std::unique_ptr<InterpolableValue> unwrap(InterpolationValue&& value)
76 { 77 {
77 ASSERT(value.interpolableValue); 78 ASSERT(value.interpolableValue);
78 return std::move(value.interpolableValue); 79 return std::move(value.interpolableValue);
79 } 80 }
80 81
81 PassOwnPtr<InterpolableValue> convertCSSCoordinate(const CSSValue* coordinate) 82 std::unique_ptr<InterpolableValue> convertCSSCoordinate(const CSSValue* coordina te)
82 { 83 {
83 if (coordinate) 84 if (coordinate)
84 return unwrap(CSSPositionAxisListInterpolationType::convertPositionAxisC SSValue(*coordinate)); 85 return unwrap(CSSPositionAxisListInterpolationType::convertPositionAxisC SSValue(*coordinate));
85 return unwrap(CSSLengthInterpolationType::maybeConvertLength(Length(50, Perc ent), 1)); 86 return unwrap(CSSLengthInterpolationType::maybeConvertLength(Length(50, Perc ent), 1));
86 } 87 }
87 88
88 PassOwnPtr<InterpolableValue> convertCoordinate(const BasicShapeCenterCoordinate & coordinate, double zoom) 89 std::unique_ptr<InterpolableValue> convertCoordinate(const BasicShapeCenterCoord inate& coordinate, double zoom)
89 { 90 {
90 return unwrap(CSSLengthInterpolationType::maybeConvertLength(coordinate.comp utedLength(), zoom)); 91 return unwrap(CSSLengthInterpolationType::maybeConvertLength(coordinate.comp utedLength(), zoom));
91 } 92 }
92 93
93 PassOwnPtr<InterpolableValue> createNeutralInterpolableCoordinate() 94 std::unique_ptr<InterpolableValue> createNeutralInterpolableCoordinate()
94 { 95 {
95 return CSSLengthInterpolationType::createNeutralInterpolableValue(); 96 return CSSLengthInterpolationType::createNeutralInterpolableValue();
96 } 97 }
97 98
98 BasicShapeCenterCoordinate createCoordinate(const InterpolableValue& interpolabl eValue, const CSSToLengthConversionData& conversionData) 99 BasicShapeCenterCoordinate createCoordinate(const InterpolableValue& interpolabl eValue, const CSSToLengthConversionData& conversionData)
99 { 100 {
100 return BasicShapeCenterCoordinate( 101 return BasicShapeCenterCoordinate(
101 BasicShapeCenterCoordinate::TopLeft, 102 BasicShapeCenterCoordinate::TopLeft,
102 CSSLengthInterpolationType::resolveInterpolableLength(interpolableValue, nullptr, conversionData)); 103 CSSLengthInterpolationType::resolveInterpolableLength(interpolableValue, nullptr, conversionData));
103 } 104 }
104 105
105 PassOwnPtr<InterpolableValue> convertCSSRadius(const CSSPrimitiveValue* radius) 106 std::unique_ptr<InterpolableValue> convertCSSRadius(const CSSPrimitiveValue* rad ius)
106 { 107 {
107 if (!radius || radius->isValueID()) 108 if (!radius || radius->isValueID())
108 return nullptr; 109 return nullptr;
109 return unwrap(CSSLengthInterpolationType::maybeConvertCSSValue(*radius)); 110 return unwrap(CSSLengthInterpolationType::maybeConvertCSSValue(*radius));
110 } 111 }
111 112
112 PassOwnPtr<InterpolableValue> convertRadius(const BasicShapeRadius& radius, doub le zoom) 113 std::unique_ptr<InterpolableValue> convertRadius(const BasicShapeRadius& radius, double zoom)
113 { 114 {
114 if (radius.type() != BasicShapeRadius::Value) 115 if (radius.type() != BasicShapeRadius::Value)
115 return nullptr; 116 return nullptr;
116 return unwrap(CSSLengthInterpolationType::maybeConvertLength(radius.value(), zoom)); 117 return unwrap(CSSLengthInterpolationType::maybeConvertLength(radius.value(), zoom));
117 } 118 }
118 119
119 PassOwnPtr<InterpolableValue> createNeutralInterpolableRadius() 120 std::unique_ptr<InterpolableValue> createNeutralInterpolableRadius()
120 { 121 {
121 return CSSLengthInterpolationType::createNeutralInterpolableValue(); 122 return CSSLengthInterpolationType::createNeutralInterpolableValue();
122 } 123 }
123 124
124 BasicShapeRadius createRadius(const InterpolableValue& interpolableValue, const CSSToLengthConversionData& conversionData) 125 BasicShapeRadius createRadius(const InterpolableValue& interpolableValue, const CSSToLengthConversionData& conversionData)
125 { 126 {
126 return BasicShapeRadius(CSSLengthInterpolationType::resolveInterpolableLengt h(interpolableValue, nullptr, conversionData, ValueRangeNonNegative)); 127 return BasicShapeRadius(CSSLengthInterpolationType::resolveInterpolableLengt h(interpolableValue, nullptr, conversionData, ValueRangeNonNegative));
127 } 128 }
128 129
129 PassOwnPtr<InterpolableValue> convertCSSLength(const CSSValue* length) 130 std::unique_ptr<InterpolableValue> convertCSSLength(const CSSValue* length)
130 { 131 {
131 if (!length) 132 if (!length)
132 return CSSLengthInterpolationType::createNeutralInterpolableValue(); 133 return CSSLengthInterpolationType::createNeutralInterpolableValue();
133 return unwrap(CSSLengthInterpolationType::maybeConvertCSSValue(*length)); 134 return unwrap(CSSLengthInterpolationType::maybeConvertCSSValue(*length));
134 } 135 }
135 136
136 PassOwnPtr<InterpolableValue> convertLength(const Length& length, double zoom) 137 std::unique_ptr<InterpolableValue> convertLength(const Length& length, double zo om)
137 { 138 {
138 return unwrap(CSSLengthInterpolationType::maybeConvertLength(length, zoom)); 139 return unwrap(CSSLengthInterpolationType::maybeConvertLength(length, zoom));
139 } 140 }
140 141
141 PassOwnPtr<InterpolableValue> convertCSSBorderRadiusWidth(const CSSValuePair* pa ir) 142 std::unique_ptr<InterpolableValue> convertCSSBorderRadiusWidth(const CSSValuePai r* pair)
142 { 143 {
143 return convertCSSLength(pair ? &pair->first() : nullptr); 144 return convertCSSLength(pair ? &pair->first() : nullptr);
144 } 145 }
145 146
146 PassOwnPtr<InterpolableValue> convertCSSBorderRadiusHeight(const CSSValuePair* p air) 147 std::unique_ptr<InterpolableValue> convertCSSBorderRadiusHeight(const CSSValuePa ir* pair)
147 { 148 {
148 return convertCSSLength(pair ? &pair->second() : nullptr); 149 return convertCSSLength(pair ? &pair->second() : nullptr);
149 } 150 }
150 151
151 LengthSize createBorderRadius(const InterpolableValue& width, const Interpolable Value& height, const CSSToLengthConversionData& conversionData) 152 LengthSize createBorderRadius(const InterpolableValue& width, const Interpolable Value& height, const CSSToLengthConversionData& conversionData)
152 { 153 {
153 return LengthSize( 154 return LengthSize(
154 CSSLengthInterpolationType::resolveInterpolableLength(width, nullptr, co nversionData, ValueRangeNonNegative), 155 CSSLengthInterpolationType::resolveInterpolableLength(width, nullptr, co nversionData, ValueRangeNonNegative),
155 CSSLengthInterpolationType::resolveInterpolableLength(height, nullptr, c onversionData, ValueRangeNonNegative)); 156 CSSLengthInterpolationType::resolveInterpolableLength(height, nullptr, c onversionData, ValueRangeNonNegative));
156 } 157 }
157 158
158 namespace CircleFunctions { 159 namespace CircleFunctions {
159 160
160 enum CircleComponentIndex { 161 enum CircleComponentIndex {
161 CircleCenterXIndex, 162 CircleCenterXIndex,
162 CircleCenterYIndex, 163 CircleCenterYIndex,
163 CircleRadiusIndex, 164 CircleRadiusIndex,
164 CircleComponentIndexCount, 165 CircleComponentIndexCount,
165 }; 166 };
166 167
167 InterpolationValue convertCSSValue(const CSSBasicShapeCircleValue& circle) 168 InterpolationValue convertCSSValue(const CSSBasicShapeCircleValue& circle)
168 { 169 {
169 OwnPtr<InterpolableList> list = InterpolableList::create(CircleComponentInde xCount); 170 std::unique_ptr<InterpolableList> list = InterpolableList::create(CircleComp onentIndexCount);
170 list->set(CircleCenterXIndex, convertCSSCoordinate(circle.centerX())); 171 list->set(CircleCenterXIndex, convertCSSCoordinate(circle.centerX()));
171 list->set(CircleCenterYIndex, convertCSSCoordinate(circle.centerY())); 172 list->set(CircleCenterYIndex, convertCSSCoordinate(circle.centerY()));
172 173
173 OwnPtr<InterpolableValue> radius; 174 std::unique_ptr<InterpolableValue> radius;
174 if (!(radius = convertCSSRadius(circle.radius()))) 175 if (!(radius = convertCSSRadius(circle.radius())))
175 return nullptr; 176 return nullptr;
176 list->set(CircleRadiusIndex, std::move(radius)); 177 list->set(CircleRadiusIndex, std::move(radius));
177 178
178 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reate(BasicShape::BasicShapeCircleType)); 179 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reate(BasicShape::BasicShapeCircleType));
179 } 180 }
180 181
181 InterpolationValue convertBasicShape(const BasicShapeCircle& circle, double zoom ) 182 InterpolationValue convertBasicShape(const BasicShapeCircle& circle, double zoom )
182 { 183 {
183 OwnPtr<InterpolableList> list = InterpolableList::create(CircleComponentInde xCount); 184 std::unique_ptr<InterpolableList> list = InterpolableList::create(CircleComp onentIndexCount);
184 list->set(CircleCenterXIndex, convertCoordinate(circle.centerX(), zoom)); 185 list->set(CircleCenterXIndex, convertCoordinate(circle.centerX(), zoom));
185 list->set(CircleCenterYIndex, convertCoordinate(circle.centerY(), zoom)); 186 list->set(CircleCenterYIndex, convertCoordinate(circle.centerY(), zoom));
186 187
187 OwnPtr<InterpolableValue> radius; 188 std::unique_ptr<InterpolableValue> radius;
188 if (!(radius = convertRadius(circle.radius(), zoom))) 189 if (!(radius = convertRadius(circle.radius(), zoom)))
189 return nullptr; 190 return nullptr;
190 list->set(CircleRadiusIndex, std::move(radius)); 191 list->set(CircleRadiusIndex, std::move(radius));
191 192
192 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reate(BasicShape::BasicShapeCircleType)); 193 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reate(BasicShape::BasicShapeCircleType));
193 } 194 }
194 195
195 PassOwnPtr<InterpolableValue> createNeutralValue() 196 std::unique_ptr<InterpolableValue> createNeutralValue()
196 { 197 {
197 OwnPtr<InterpolableList> list = InterpolableList::create(CircleComponentInde xCount); 198 std::unique_ptr<InterpolableList> list = InterpolableList::create(CircleComp onentIndexCount);
198 list->set(CircleCenterXIndex, createNeutralInterpolableCoordinate()); 199 list->set(CircleCenterXIndex, createNeutralInterpolableCoordinate());
199 list->set(CircleCenterYIndex, createNeutralInterpolableCoordinate()); 200 list->set(CircleCenterYIndex, createNeutralInterpolableCoordinate());
200 list->set(CircleRadiusIndex, createNeutralInterpolableRadius()); 201 list->set(CircleRadiusIndex, createNeutralInterpolableRadius());
201 return std::move(list); 202 return std::move(list);
202 } 203 }
203 204
204 PassRefPtr<BasicShape> createBasicShape(const InterpolableValue& interpolableVal ue, const CSSToLengthConversionData& conversionData) 205 PassRefPtr<BasicShape> createBasicShape(const InterpolableValue& interpolableVal ue, const CSSToLengthConversionData& conversionData)
205 { 206 {
206 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create(); 207 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create();
207 const InterpolableList& list = toInterpolableList(interpolableValue); 208 const InterpolableList& list = toInterpolableList(interpolableValue);
(...skipping 10 matching lines...) Expand all
218 enum EllipseComponentIndex { 219 enum EllipseComponentIndex {
219 EllipseCenterXIndex, 220 EllipseCenterXIndex,
220 EllipseCenterYIndex, 221 EllipseCenterYIndex,
221 EllipseRadiusXIndex, 222 EllipseRadiusXIndex,
222 EllipseRadiusYIndex, 223 EllipseRadiusYIndex,
223 EllipseComponentIndexCount, 224 EllipseComponentIndexCount,
224 }; 225 };
225 226
226 InterpolationValue convertCSSValue(const CSSBasicShapeEllipseValue& ellipse) 227 InterpolationValue convertCSSValue(const CSSBasicShapeEllipseValue& ellipse)
227 { 228 {
228 OwnPtr<InterpolableList> list = InterpolableList::create(EllipseComponentInd exCount); 229 std::unique_ptr<InterpolableList> list = InterpolableList::create(EllipseCom ponentIndexCount);
229 list->set(EllipseCenterXIndex, convertCSSCoordinate(ellipse.centerX())); 230 list->set(EllipseCenterXIndex, convertCSSCoordinate(ellipse.centerX()));
230 list->set(EllipseCenterYIndex, convertCSSCoordinate(ellipse.centerY())); 231 list->set(EllipseCenterYIndex, convertCSSCoordinate(ellipse.centerY()));
231 232
232 OwnPtr<InterpolableValue> radius; 233 std::unique_ptr<InterpolableValue> radius;
233 if (!(radius = convertCSSRadius(ellipse.radiusX()))) 234 if (!(radius = convertCSSRadius(ellipse.radiusX())))
234 return nullptr; 235 return nullptr;
235 list->set(EllipseRadiusXIndex, std::move(radius)); 236 list->set(EllipseRadiusXIndex, std::move(radius));
236 if (!(radius = convertCSSRadius(ellipse.radiusY()))) 237 if (!(radius = convertCSSRadius(ellipse.radiusY())))
237 return nullptr; 238 return nullptr;
238 list->set(EllipseRadiusYIndex, std::move(radius)); 239 list->set(EllipseRadiusYIndex, std::move(radius));
239 240
240 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reate(BasicShape::BasicShapeEllipseType)); 241 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reate(BasicShape::BasicShapeEllipseType));
241 } 242 }
242 243
243 InterpolationValue convertBasicShape(const BasicShapeEllipse& ellipse, double zo om) 244 InterpolationValue convertBasicShape(const BasicShapeEllipse& ellipse, double zo om)
244 { 245 {
245 OwnPtr<InterpolableList> list = InterpolableList::create(EllipseComponentInd exCount); 246 std::unique_ptr<InterpolableList> list = InterpolableList::create(EllipseCom ponentIndexCount);
246 list->set(EllipseCenterXIndex, convertCoordinate(ellipse.centerX(), zoom)); 247 list->set(EllipseCenterXIndex, convertCoordinate(ellipse.centerX(), zoom));
247 list->set(EllipseCenterYIndex, convertCoordinate(ellipse.centerY(), zoom)); 248 list->set(EllipseCenterYIndex, convertCoordinate(ellipse.centerY(), zoom));
248 249
249 OwnPtr<InterpolableValue> radius; 250 std::unique_ptr<InterpolableValue> radius;
250 if (!(radius = convertRadius(ellipse.radiusX(), zoom))) 251 if (!(radius = convertRadius(ellipse.radiusX(), zoom)))
251 return nullptr; 252 return nullptr;
252 list->set(EllipseRadiusXIndex, std::move(radius)); 253 list->set(EllipseRadiusXIndex, std::move(radius));
253 if (!(radius = convertRadius(ellipse.radiusY(), zoom))) 254 if (!(radius = convertRadius(ellipse.radiusY(), zoom)))
254 return nullptr; 255 return nullptr;
255 list->set(EllipseRadiusYIndex, std::move(radius)); 256 list->set(EllipseRadiusYIndex, std::move(radius));
256 257
257 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reate(BasicShape::BasicShapeEllipseType)); 258 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reate(BasicShape::BasicShapeEllipseType));
258 } 259 }
259 260
260 PassOwnPtr<InterpolableValue> createNeutralValue() 261 std::unique_ptr<InterpolableValue> createNeutralValue()
261 { 262 {
262 OwnPtr<InterpolableList> list = InterpolableList::create(EllipseComponentInd exCount); 263 std::unique_ptr<InterpolableList> list = InterpolableList::create(EllipseCom ponentIndexCount);
263 list->set(EllipseCenterXIndex, createNeutralInterpolableCoordinate()); 264 list->set(EllipseCenterXIndex, createNeutralInterpolableCoordinate());
264 list->set(EllipseCenterYIndex, createNeutralInterpolableCoordinate()); 265 list->set(EllipseCenterYIndex, createNeutralInterpolableCoordinate());
265 list->set(EllipseRadiusXIndex, createNeutralInterpolableRadius()); 266 list->set(EllipseRadiusXIndex, createNeutralInterpolableRadius());
266 list->set(EllipseRadiusYIndex, createNeutralInterpolableRadius()); 267 list->set(EllipseRadiusYIndex, createNeutralInterpolableRadius());
267 return std::move(list); 268 return std::move(list);
268 } 269 }
269 270
270 PassRefPtr<BasicShape> createBasicShape(const InterpolableValue& interpolableVal ue, const CSSToLengthConversionData& conversionData) 271 PassRefPtr<BasicShape> createBasicShape(const InterpolableValue& interpolableVal ue, const CSSToLengthConversionData& conversionData)
271 { 272 {
272 RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create(); 273 RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create();
(...skipping 20 matching lines...) Expand all
293 InsetBorderTopRightHeightIndex, 294 InsetBorderTopRightHeightIndex,
294 InsetBorderBottomRightWidthIndex, 295 InsetBorderBottomRightWidthIndex,
295 InsetBorderBottomRightHeightIndex, 296 InsetBorderBottomRightHeightIndex,
296 InsetBorderBottomLeftWidthIndex, 297 InsetBorderBottomLeftWidthIndex,
297 InsetBorderBottomLeftHeightIndex, 298 InsetBorderBottomLeftHeightIndex,
298 InsetComponentIndexCount, 299 InsetComponentIndexCount,
299 }; 300 };
300 301
301 InterpolationValue convertCSSValue(const CSSBasicShapeInsetValue& inset) 302 InterpolationValue convertCSSValue(const CSSBasicShapeInsetValue& inset)
302 { 303 {
303 OwnPtr<InterpolableList> list = InterpolableList::create(InsetComponentIndex Count); 304 std::unique_ptr<InterpolableList> list = InterpolableList::create(InsetCompo nentIndexCount);
304 list->set(InsetTopIndex, convertCSSLength(inset.top())); 305 list->set(InsetTopIndex, convertCSSLength(inset.top()));
305 list->set(InsetRightIndex, convertCSSLength(inset.right())); 306 list->set(InsetRightIndex, convertCSSLength(inset.right()));
306 list->set(InsetBottomIndex, convertCSSLength(inset.bottom())); 307 list->set(InsetBottomIndex, convertCSSLength(inset.bottom()));
307 list->set(InsetLeftIndex, convertCSSLength(inset.left())); 308 list->set(InsetLeftIndex, convertCSSLength(inset.left()));
308 309
309 list->set(InsetBorderTopLeftWidthIndex, convertCSSBorderRadiusWidth(inset.to pLeftRadius())); 310 list->set(InsetBorderTopLeftWidthIndex, convertCSSBorderRadiusWidth(inset.to pLeftRadius()));
310 list->set(InsetBorderTopLeftHeightIndex, convertCSSBorderRadiusHeight(inset. topLeftRadius())); 311 list->set(InsetBorderTopLeftHeightIndex, convertCSSBorderRadiusHeight(inset. topLeftRadius()));
311 list->set(InsetBorderTopRightWidthIndex, convertCSSBorderRadiusWidth(inset.t opRightRadius())); 312 list->set(InsetBorderTopRightWidthIndex, convertCSSBorderRadiusWidth(inset.t opRightRadius()));
312 list->set(InsetBorderTopRightHeightIndex, convertCSSBorderRadiusHeight(inset .topRightRadius())); 313 list->set(InsetBorderTopRightHeightIndex, convertCSSBorderRadiusHeight(inset .topRightRadius()));
313 list->set(InsetBorderBottomRightWidthIndex, convertCSSBorderRadiusWidth(inse t.bottomRightRadius())); 314 list->set(InsetBorderBottomRightWidthIndex, convertCSSBorderRadiusWidth(inse t.bottomRightRadius()));
314 list->set(InsetBorderBottomRightHeightIndex, convertCSSBorderRadiusHeight(in set.bottomRightRadius())); 315 list->set(InsetBorderBottomRightHeightIndex, convertCSSBorderRadiusHeight(in set.bottomRightRadius()));
315 list->set(InsetBorderBottomLeftWidthIndex, convertCSSBorderRadiusWidth(inset .bottomLeftRadius())); 316 list->set(InsetBorderBottomLeftWidthIndex, convertCSSBorderRadiusWidth(inset .bottomLeftRadius()));
316 list->set(InsetBorderBottomLeftHeightIndex, convertCSSBorderRadiusHeight(ins et.bottomLeftRadius())); 317 list->set(InsetBorderBottomLeftHeightIndex, convertCSSBorderRadiusHeight(ins et.bottomLeftRadius()));
317 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reate(BasicShape::BasicShapeInsetType)); 318 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reate(BasicShape::BasicShapeInsetType));
318 } 319 }
319 320
320 InterpolationValue convertBasicShape(const BasicShapeInset& inset, double zoom) 321 InterpolationValue convertBasicShape(const BasicShapeInset& inset, double zoom)
321 { 322 {
322 OwnPtr<InterpolableList> list = InterpolableList::create(InsetComponentIndex Count); 323 std::unique_ptr<InterpolableList> list = InterpolableList::create(InsetCompo nentIndexCount);
323 list->set(InsetTopIndex, convertLength(inset.top(), zoom)); 324 list->set(InsetTopIndex, convertLength(inset.top(), zoom));
324 list->set(InsetRightIndex, convertLength(inset.right(), zoom)); 325 list->set(InsetRightIndex, convertLength(inset.right(), zoom));
325 list->set(InsetBottomIndex, convertLength(inset.bottom(), zoom)); 326 list->set(InsetBottomIndex, convertLength(inset.bottom(), zoom));
326 list->set(InsetLeftIndex, convertLength(inset.left(), zoom)); 327 list->set(InsetLeftIndex, convertLength(inset.left(), zoom));
327 328
328 list->set(InsetBorderTopLeftWidthIndex, convertLength(inset.topLeftRadius(). width(), zoom)); 329 list->set(InsetBorderTopLeftWidthIndex, convertLength(inset.topLeftRadius(). width(), zoom));
329 list->set(InsetBorderTopLeftHeightIndex, convertLength(inset.topLeftRadius() .height(), zoom)); 330 list->set(InsetBorderTopLeftHeightIndex, convertLength(inset.topLeftRadius() .height(), zoom));
330 list->set(InsetBorderTopRightWidthIndex, convertLength(inset.topRightRadius( ).width(), zoom)); 331 list->set(InsetBorderTopRightWidthIndex, convertLength(inset.topRightRadius( ).width(), zoom));
331 list->set(InsetBorderTopRightHeightIndex, convertLength(inset.topRightRadius ().height(), zoom)); 332 list->set(InsetBorderTopRightHeightIndex, convertLength(inset.topRightRadius ().height(), zoom));
332 list->set(InsetBorderBottomRightWidthIndex, convertLength(inset.bottomRightR adius().width(), zoom)); 333 list->set(InsetBorderBottomRightWidthIndex, convertLength(inset.bottomRightR adius().width(), zoom));
333 list->set(InsetBorderBottomRightHeightIndex, convertLength(inset.bottomRight Radius().height(), zoom)); 334 list->set(InsetBorderBottomRightHeightIndex, convertLength(inset.bottomRight Radius().height(), zoom));
334 list->set(InsetBorderBottomLeftWidthIndex, convertLength(inset.bottomLeftRad ius().width(), zoom)); 335 list->set(InsetBorderBottomLeftWidthIndex, convertLength(inset.bottomLeftRad ius().width(), zoom));
335 list->set(InsetBorderBottomLeftHeightIndex, convertLength(inset.bottomLeftRa dius().height(), zoom)); 336 list->set(InsetBorderBottomLeftHeightIndex, convertLength(inset.bottomLeftRa dius().height(), zoom));
336 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reate(BasicShape::BasicShapeInsetType)); 337 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reate(BasicShape::BasicShapeInsetType));
337 } 338 }
338 339
339 PassOwnPtr<InterpolableValue> createNeutralValue() 340 std::unique_ptr<InterpolableValue> createNeutralValue()
340 { 341 {
341 OwnPtr<InterpolableList> list = InterpolableList::create(InsetComponentIndex Count); 342 std::unique_ptr<InterpolableList> list = InterpolableList::create(InsetCompo nentIndexCount);
342 list->set(InsetTopIndex, CSSLengthInterpolationType::createNeutralInterpolab leValue()); 343 list->set(InsetTopIndex, CSSLengthInterpolationType::createNeutralInterpolab leValue());
343 list->set(InsetRightIndex, CSSLengthInterpolationType::createNeutralInterpol ableValue()); 344 list->set(InsetRightIndex, CSSLengthInterpolationType::createNeutralInterpol ableValue());
344 list->set(InsetBottomIndex, CSSLengthInterpolationType::createNeutralInterpo lableValue()); 345 list->set(InsetBottomIndex, CSSLengthInterpolationType::createNeutralInterpo lableValue());
345 list->set(InsetLeftIndex, CSSLengthInterpolationType::createNeutralInterpola bleValue()); 346 list->set(InsetLeftIndex, CSSLengthInterpolationType::createNeutralInterpola bleValue());
346 347
347 list->set(InsetBorderTopLeftWidthIndex, CSSLengthInterpolationType::createNe utralInterpolableValue()); 348 list->set(InsetBorderTopLeftWidthIndex, CSSLengthInterpolationType::createNe utralInterpolableValue());
348 list->set(InsetBorderTopLeftHeightIndex, CSSLengthInterpolationType::createN eutralInterpolableValue()); 349 list->set(InsetBorderTopLeftHeightIndex, CSSLengthInterpolationType::createN eutralInterpolableValue());
349 list->set(InsetBorderTopRightWidthIndex, CSSLengthInterpolationType::createN eutralInterpolableValue()); 350 list->set(InsetBorderTopRightWidthIndex, CSSLengthInterpolationType::createN eutralInterpolableValue());
350 list->set(InsetBorderTopRightHeightIndex, CSSLengthInterpolationType::create NeutralInterpolableValue()); 351 list->set(InsetBorderTopRightHeightIndex, CSSLengthInterpolationType::create NeutralInterpolableValue());
351 list->set(InsetBorderBottomRightWidthIndex, CSSLengthInterpolationType::crea teNeutralInterpolableValue()); 352 list->set(InsetBorderBottomRightWidthIndex, CSSLengthInterpolationType::crea teNeutralInterpolableValue());
(...skipping 19 matching lines...) Expand all
371 return inset.release(); 372 return inset.release();
372 } 373 }
373 374
374 } // namespace InsetFunctions 375 } // namespace InsetFunctions
375 376
376 namespace PolygonFunctions { 377 namespace PolygonFunctions {
377 378
378 InterpolationValue convertCSSValue(const CSSBasicShapePolygonValue& polygon) 379 InterpolationValue convertCSSValue(const CSSBasicShapePolygonValue& polygon)
379 { 380 {
380 size_t size = polygon.values().size(); 381 size_t size = polygon.values().size();
381 OwnPtr<InterpolableList> list = InterpolableList::create(size); 382 std::unique_ptr<InterpolableList> list = InterpolableList::create(size);
382 for (size_t i = 0; i < size; i++) 383 for (size_t i = 0; i < size; i++)
383 list->set(i, convertCSSLength(polygon.values()[i].get())); 384 list->set(i, convertCSSLength(polygon.values()[i].get()));
384 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reatePolygon(polygon.getWindRule(), size)); 385 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reatePolygon(polygon.getWindRule(), size));
385 } 386 }
386 387
387 InterpolationValue convertBasicShape(const BasicShapePolygon& polygon, double zo om) 388 InterpolationValue convertBasicShape(const BasicShapePolygon& polygon, double zo om)
388 { 389 {
389 size_t size = polygon.values().size(); 390 size_t size = polygon.values().size();
390 OwnPtr<InterpolableList> list = InterpolableList::create(size); 391 std::unique_ptr<InterpolableList> list = InterpolableList::create(size);
391 for (size_t i = 0; i < size; i++) 392 for (size_t i = 0; i < size; i++)
392 list->set(i, convertLength(polygon.values()[i], zoom)); 393 list->set(i, convertLength(polygon.values()[i], zoom));
393 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reatePolygon(polygon.getWindRule(), size)); 394 return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::c reatePolygon(polygon.getWindRule(), size));
394 } 395 }
395 396
396 PassOwnPtr<InterpolableValue> createNeutralValue(const BasicShapeNonInterpolable Value& nonInterpolableValue) 397 std::unique_ptr<InterpolableValue> createNeutralValue(const BasicShapeNonInterpo lableValue& nonInterpolableValue)
397 { 398 {
398 OwnPtr<InterpolableList> list = InterpolableList::create(nonInterpolableValu e.size()); 399 std::unique_ptr<InterpolableList> list = InterpolableList::create(nonInterpo lableValue.size());
399 for (size_t i = 0; i < nonInterpolableValue.size(); i++) 400 for (size_t i = 0; i < nonInterpolableValue.size(); i++)
400 list->set(i, CSSLengthInterpolationType::createNeutralInterpolableValue( )); 401 list->set(i, CSSLengthInterpolationType::createNeutralInterpolableValue( ));
401 return std::move(list); 402 return std::move(list);
402 } 403 }
403 404
404 PassRefPtr<BasicShape> createBasicShape(const InterpolableValue& interpolableVal ue, const BasicShapeNonInterpolableValue& nonInterpolableValue, const CSSToLengt hConversionData& conversionData) 405 PassRefPtr<BasicShape> createBasicShape(const InterpolableValue& interpolableVal ue, const BasicShapeNonInterpolableValue& nonInterpolableValue, const CSSToLengt hConversionData& conversionData)
405 { 406 {
406 RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create(); 407 RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create();
407 polygon->setWindRule(nonInterpolableValue.windRule()); 408 polygon->setWindRule(nonInterpolableValue.windRule());
408 const InterpolableList& list = toInterpolableList(interpolableValue); 409 const InterpolableList& list = toInterpolableList(interpolableValue);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 case BasicShape::BasicShapeInsetType: 447 case BasicShape::BasicShapeInsetType:
447 return InsetFunctions::convertBasicShape(toBasicShapeInset(*shape), zoom ); 448 return InsetFunctions::convertBasicShape(toBasicShapeInset(*shape), zoom );
448 case BasicShape::BasicShapePolygonType: 449 case BasicShape::BasicShapePolygonType:
449 return PolygonFunctions::convertBasicShape(toBasicShapePolygon(*shape), zoom); 450 return PolygonFunctions::convertBasicShape(toBasicShapePolygon(*shape), zoom);
450 default: 451 default:
451 ASSERT_NOT_REACHED(); 452 ASSERT_NOT_REACHED();
452 return nullptr; 453 return nullptr;
453 } 454 }
454 } 455 }
455 456
456 PassOwnPtr<InterpolableValue> BasicShapeInterpolationFunctions::createNeutralVal ue(const NonInterpolableValue& untypedNonInterpolableValue) 457 std::unique_ptr<InterpolableValue> BasicShapeInterpolationFunctions::createNeutr alValue(const NonInterpolableValue& untypedNonInterpolableValue)
457 { 458 {
458 const BasicShapeNonInterpolableValue& nonInterpolableValue = toBasicShapeNon InterpolableValue(untypedNonInterpolableValue); 459 const BasicShapeNonInterpolableValue& nonInterpolableValue = toBasicShapeNon InterpolableValue(untypedNonInterpolableValue);
459 switch (nonInterpolableValue.type()) { 460 switch (nonInterpolableValue.type()) {
460 case BasicShape::BasicShapeCircleType: 461 case BasicShape::BasicShapeCircleType:
461 return CircleFunctions::createNeutralValue(); 462 return CircleFunctions::createNeutralValue();
462 case BasicShape::BasicShapeEllipseType: 463 case BasicShape::BasicShapeEllipseType:
463 return EllipseFunctions::createNeutralValue(); 464 return EllipseFunctions::createNeutralValue();
464 case BasicShape::BasicShapeInsetType: 465 case BasicShape::BasicShapeInsetType:
465 return InsetFunctions::createNeutralValue(); 466 return InsetFunctions::createNeutralValue();
466 case BasicShape::BasicShapePolygonType: 467 case BasicShape::BasicShapePolygonType:
(...skipping 21 matching lines...) Expand all
488 return InsetFunctions::createBasicShape(interpolableValue, conversionDat a); 489 return InsetFunctions::createBasicShape(interpolableValue, conversionDat a);
489 case BasicShape::BasicShapePolygonType: 490 case BasicShape::BasicShapePolygonType:
490 return PolygonFunctions::createBasicShape(interpolableValue, nonInterpol ableValue, conversionData); 491 return PolygonFunctions::createBasicShape(interpolableValue, nonInterpol ableValue, conversionData);
491 default: 492 default:
492 ASSERT_NOT_REACHED(); 493 ASSERT_NOT_REACHED();
493 return nullptr; 494 return nullptr;
494 } 495 }
495 } 496 }
496 497
497 } // namespace blink 498 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698