OLD | NEW |
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/CSSPositionAxisListInterpolationType.h" | 7 #include "core/animation/CSSPositionAxisListInterpolationType.h" |
8 #include "core/animation/LengthInterpolationFunctions.h" | 8 #include "core/animation/LengthInterpolationFunctions.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" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 const InterpolableValue& interpolable_value, | 219 const InterpolableValue& interpolable_value, |
220 const CSSToLengthConversionData& conversion_data) { | 220 const CSSToLengthConversionData& conversion_data) { |
221 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::Create(); | 221 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::Create(); |
222 const InterpolableList& list = ToInterpolableList(interpolable_value); | 222 const InterpolableList& list = ToInterpolableList(interpolable_value); |
223 circle->SetCenterX( | 223 circle->SetCenterX( |
224 CreateCoordinate(*list.Get(kCircleCenterXIndex), conversion_data)); | 224 CreateCoordinate(*list.Get(kCircleCenterXIndex), conversion_data)); |
225 circle->SetCenterY( | 225 circle->SetCenterY( |
226 CreateCoordinate(*list.Get(kCircleCenterYIndex), conversion_data)); | 226 CreateCoordinate(*list.Get(kCircleCenterYIndex), conversion_data)); |
227 circle->SetRadius( | 227 circle->SetRadius( |
228 CreateRadius(*list.Get(kCircleRadiusIndex), conversion_data)); | 228 CreateRadius(*list.Get(kCircleRadiusIndex), conversion_data)); |
229 return circle.Release(); | 229 return circle; |
230 } | 230 } |
231 | 231 |
232 } // namespace CircleFunctions | 232 } // namespace CircleFunctions |
233 | 233 |
234 namespace EllipseFunctions { | 234 namespace EllipseFunctions { |
235 | 235 |
236 enum EllipseComponentIndex : unsigned { | 236 enum EllipseComponentIndex : unsigned { |
237 kEllipseCenterXIndex, | 237 kEllipseCenterXIndex, |
238 kEllipseCenterYIndex, | 238 kEllipseCenterYIndex, |
239 kEllipseRadiusXIndex, | 239 kEllipseRadiusXIndex, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::Create(); | 296 RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::Create(); |
297 const InterpolableList& list = ToInterpolableList(interpolable_value); | 297 const InterpolableList& list = ToInterpolableList(interpolable_value); |
298 ellipse->SetCenterX( | 298 ellipse->SetCenterX( |
299 CreateCoordinate(*list.Get(kEllipseCenterXIndex), conversion_data)); | 299 CreateCoordinate(*list.Get(kEllipseCenterXIndex), conversion_data)); |
300 ellipse->SetCenterY( | 300 ellipse->SetCenterY( |
301 CreateCoordinate(*list.Get(kEllipseCenterYIndex), conversion_data)); | 301 CreateCoordinate(*list.Get(kEllipseCenterYIndex), conversion_data)); |
302 ellipse->SetRadiusX( | 302 ellipse->SetRadiusX( |
303 CreateRadius(*list.Get(kEllipseRadiusXIndex), conversion_data)); | 303 CreateRadius(*list.Get(kEllipseRadiusXIndex), conversion_data)); |
304 ellipse->SetRadiusY( | 304 ellipse->SetRadiusY( |
305 CreateRadius(*list.Get(kEllipseRadiusYIndex), conversion_data)); | 305 CreateRadius(*list.Get(kEllipseRadiusYIndex), conversion_data)); |
306 return ellipse.Release(); | 306 return ellipse; |
307 } | 307 } |
308 | 308 |
309 } // namespace EllipseFunctions | 309 } // namespace EllipseFunctions |
310 | 310 |
311 namespace InsetFunctions { | 311 namespace InsetFunctions { |
312 | 312 |
313 enum InsetComponentIndex : unsigned { | 313 enum InsetComponentIndex : unsigned { |
314 kInsetTopIndex, | 314 kInsetTopIndex, |
315 kInsetRightIndex, | 315 kInsetRightIndex, |
316 kInsetBottomIndex, | 316 kInsetBottomIndex, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 *list.Get(kInsetBorderTopLeftHeightIndex), conversion_data)); | 435 *list.Get(kInsetBorderTopLeftHeightIndex), conversion_data)); |
436 inset->SetTopRightRadius(CreateBorderRadius( | 436 inset->SetTopRightRadius(CreateBorderRadius( |
437 *list.Get(kInsetBorderTopRightWidthIndex), | 437 *list.Get(kInsetBorderTopRightWidthIndex), |
438 *list.Get(kInsetBorderTopRightHeightIndex), conversion_data)); | 438 *list.Get(kInsetBorderTopRightHeightIndex), conversion_data)); |
439 inset->SetBottomRightRadius(CreateBorderRadius( | 439 inset->SetBottomRightRadius(CreateBorderRadius( |
440 *list.Get(kInsetBorderBottomRightWidthIndex), | 440 *list.Get(kInsetBorderBottomRightWidthIndex), |
441 *list.Get(kInsetBorderBottomRightHeightIndex), conversion_data)); | 441 *list.Get(kInsetBorderBottomRightHeightIndex), conversion_data)); |
442 inset->SetBottomLeftRadius(CreateBorderRadius( | 442 inset->SetBottomLeftRadius(CreateBorderRadius( |
443 *list.Get(kInsetBorderBottomLeftWidthIndex), | 443 *list.Get(kInsetBorderBottomLeftWidthIndex), |
444 *list.Get(kInsetBorderBottomLeftHeightIndex), conversion_data)); | 444 *list.Get(kInsetBorderBottomLeftHeightIndex), conversion_data)); |
445 return inset.Release(); | 445 return inset; |
446 } | 446 } |
447 | 447 |
448 } // namespace InsetFunctions | 448 } // namespace InsetFunctions |
449 | 449 |
450 namespace PolygonFunctions { | 450 namespace PolygonFunctions { |
451 | 451 |
452 InterpolationValue ConvertCSSValue(const CSSBasicShapePolygonValue& polygon) { | 452 InterpolationValue ConvertCSSValue(const CSSBasicShapePolygonValue& polygon) { |
453 size_t size = polygon.Values().size(); | 453 size_t size = polygon.Values().size(); |
454 std::unique_ptr<InterpolableList> list = InterpolableList::Create(size); | 454 std::unique_ptr<InterpolableList> list = InterpolableList::Create(size); |
455 for (size_t i = 0; i < size; i++) | 455 for (size_t i = 0; i < size; i++) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 size_t size = non_interpolable_value.size(); | 490 size_t size = non_interpolable_value.size(); |
491 DCHECK_EQ(list.length(), size); | 491 DCHECK_EQ(list.length(), size); |
492 DCHECK_EQ(size % 2, 0U); | 492 DCHECK_EQ(size % 2, 0U); |
493 for (size_t i = 0; i < size; i += 2) { | 493 for (size_t i = 0; i < size; i += 2) { |
494 polygon->AppendPoint( | 494 polygon->AppendPoint( |
495 LengthInterpolationFunctions::CreateLength( | 495 LengthInterpolationFunctions::CreateLength( |
496 *list.Get(i), nullptr, conversion_data, kValueRangeAll), | 496 *list.Get(i), nullptr, conversion_data, kValueRangeAll), |
497 LengthInterpolationFunctions::CreateLength( | 497 LengthInterpolationFunctions::CreateLength( |
498 *list.Get(i + 1), nullptr, conversion_data, kValueRangeAll)); | 498 *list.Get(i + 1), nullptr, conversion_data, kValueRangeAll)); |
499 } | 499 } |
500 return polygon.Release(); | 500 return polygon; |
501 } | 501 } |
502 | 502 |
503 } // namespace PolygonFunctions | 503 } // namespace PolygonFunctions |
504 | 504 |
505 } // namespace | 505 } // namespace |
506 | 506 |
507 InterpolationValue BasicShapeInterpolationFunctions::MaybeConvertCSSValue( | 507 InterpolationValue BasicShapeInterpolationFunctions::MaybeConvertCSSValue( |
508 const CSSValue& value) { | 508 const CSSValue& value) { |
509 if (value.IsBasicShapeCircleValue()) | 509 if (value.IsBasicShapeCircleValue()) |
510 return CircleFunctions::ConvertCSSValue(ToCSSBasicShapeCircleValue(value)); | 510 return CircleFunctions::ConvertCSSValue(ToCSSBasicShapeCircleValue(value)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 case BasicShape::kBasicShapePolygonType: | 588 case BasicShape::kBasicShapePolygonType: |
589 return PolygonFunctions::CreateBasicShape( | 589 return PolygonFunctions::CreateBasicShape( |
590 interpolable_value, non_interpolable_value, conversion_data); | 590 interpolable_value, non_interpolable_value, conversion_data); |
591 default: | 591 default: |
592 NOTREACHED(); | 592 NOTREACHED(); |
593 return nullptr; | 593 return nullptr; |
594 } | 594 } |
595 } | 595 } |
596 | 596 |
597 } // namespace blink | 597 } // namespace blink |
OLD | NEW |