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

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

Issue 2314453002: Use CSSPrimitiveValue::create in CSSLengthInterpolationType (Closed)
Patch Set: 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
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"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 std::unique_ptr<InterpolableValue> createNeutralInterpolableCoordinate() 94 std::unique_ptr<InterpolableValue> createNeutralInterpolableCoordinate()
95 { 95 {
96 return CSSLengthInterpolationType::createNeutralInterpolableValue(); 96 return CSSLengthInterpolationType::createNeutralInterpolableValue();
97 } 97 }
98 98
99 BasicShapeCenterCoordinate createCoordinate(const InterpolableValue& interpolabl eValue, const CSSToLengthConversionData& conversionData) 99 BasicShapeCenterCoordinate createCoordinate(const InterpolableValue& interpolabl eValue, const CSSToLengthConversionData& conversionData)
100 { 100 {
101 return BasicShapeCenterCoordinate( 101 return BasicShapeCenterCoordinate(
102 BasicShapeCenterCoordinate::TopLeft, 102 BasicShapeCenterCoordinate::TopLeft,
103 CSSLengthInterpolationType::resolveInterpolableLength(interpolableValue, nullptr, conversionData)); 103 CSSLengthInterpolationType::createLength(interpolableValue, nullptr, con versionData));
104 } 104 }
105 105
106 std::unique_ptr<InterpolableValue> convertCSSRadius(const CSSPrimitiveValue* rad ius) 106 std::unique_ptr<InterpolableValue> convertCSSRadius(const CSSPrimitiveValue* rad ius)
107 { 107 {
108 if (!radius || radius->isValueID()) 108 if (!radius || radius->isValueID())
109 return nullptr; 109 return nullptr;
110 return unwrap(CSSLengthInterpolationType::maybeConvertCSSValue(*radius)); 110 return unwrap(CSSLengthInterpolationType::maybeConvertCSSValue(*radius));
111 } 111 }
112 112
113 std::unique_ptr<InterpolableValue> convertRadius(const BasicShapeRadius& radius, double zoom) 113 std::unique_ptr<InterpolableValue> convertRadius(const BasicShapeRadius& radius, double zoom)
114 { 114 {
115 if (radius.type() != BasicShapeRadius::Value) 115 if (radius.type() != BasicShapeRadius::Value)
116 return nullptr; 116 return nullptr;
117 return unwrap(CSSLengthInterpolationType::maybeConvertLength(radius.value(), zoom)); 117 return unwrap(CSSLengthInterpolationType::maybeConvertLength(radius.value(), zoom));
118 } 118 }
119 119
120 std::unique_ptr<InterpolableValue> createNeutralInterpolableRadius() 120 std::unique_ptr<InterpolableValue> createNeutralInterpolableRadius()
121 { 121 {
122 return CSSLengthInterpolationType::createNeutralInterpolableValue(); 122 return CSSLengthInterpolationType::createNeutralInterpolableValue();
123 } 123 }
124 124
125 BasicShapeRadius createRadius(const InterpolableValue& interpolableValue, const CSSToLengthConversionData& conversionData) 125 BasicShapeRadius createRadius(const InterpolableValue& interpolableValue, const CSSToLengthConversionData& conversionData)
126 { 126 {
127 return BasicShapeRadius(CSSLengthInterpolationType::resolveInterpolableLengt h(interpolableValue, nullptr, conversionData, ValueRangeNonNegative)); 127 return BasicShapeRadius(CSSLengthInterpolationType::createLength(interpolabl eValue, nullptr, conversionData, ValueRangeNonNegative));
128 } 128 }
129 129
130 std::unique_ptr<InterpolableValue> convertCSSLength(const CSSValue* length) 130 std::unique_ptr<InterpolableValue> convertCSSLength(const CSSValue* length)
131 { 131 {
132 if (!length) 132 if (!length)
133 return CSSLengthInterpolationType::createNeutralInterpolableValue(); 133 return CSSLengthInterpolationType::createNeutralInterpolableValue();
134 return unwrap(CSSLengthInterpolationType::maybeConvertCSSValue(*length)); 134 return unwrap(CSSLengthInterpolationType::maybeConvertCSSValue(*length));
135 } 135 }
136 136
137 std::unique_ptr<InterpolableValue> convertLength(const Length& length, double zo om) 137 std::unique_ptr<InterpolableValue> convertLength(const Length& length, double zo om)
138 { 138 {
139 return unwrap(CSSLengthInterpolationType::maybeConvertLength(length, zoom)); 139 return unwrap(CSSLengthInterpolationType::maybeConvertLength(length, zoom));
140 } 140 }
141 141
142 std::unique_ptr<InterpolableValue> convertCSSBorderRadiusWidth(const CSSValuePai r* pair) 142 std::unique_ptr<InterpolableValue> convertCSSBorderRadiusWidth(const CSSValuePai r* pair)
143 { 143 {
144 return convertCSSLength(pair ? &pair->first() : nullptr); 144 return convertCSSLength(pair ? &pair->first() : nullptr);
145 } 145 }
146 146
147 std::unique_ptr<InterpolableValue> convertCSSBorderRadiusHeight(const CSSValuePa ir* pair) 147 std::unique_ptr<InterpolableValue> convertCSSBorderRadiusHeight(const CSSValuePa ir* pair)
148 { 148 {
149 return convertCSSLength(pair ? &pair->second() : nullptr); 149 return convertCSSLength(pair ? &pair->second() : nullptr);
150 } 150 }
151 151
152 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)
153 { 153 {
154 return LengthSize( 154 return LengthSize(
155 CSSLengthInterpolationType::resolveInterpolableLength(width, nullptr, co nversionData, ValueRangeNonNegative), 155 CSSLengthInterpolationType::createLength(width, nullptr, conversionData, ValueRangeNonNegative),
156 CSSLengthInterpolationType::resolveInterpolableLength(height, nullptr, c onversionData, ValueRangeNonNegative)); 156 CSSLengthInterpolationType::createLength(height, nullptr, conversionData , ValueRangeNonNegative));
157 } 157 }
158 158
159 namespace CircleFunctions { 159 namespace CircleFunctions {
160 160
161 enum CircleComponentIndex : unsigned { 161 enum CircleComponentIndex : unsigned {
162 CircleCenterXIndex, 162 CircleCenterXIndex,
163 CircleCenterYIndex, 163 CircleCenterYIndex,
164 CircleRadiusIndex, 164 CircleRadiusIndex,
165 CircleComponentIndexCount, 165 CircleComponentIndexCount,
166 }; 166 };
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 list->set(InsetBorderBottomRightHeightIndex, CSSLengthInterpolationType::cre ateNeutralInterpolableValue()); 353 list->set(InsetBorderBottomRightHeightIndex, CSSLengthInterpolationType::cre ateNeutralInterpolableValue());
354 list->set(InsetBorderBottomLeftWidthIndex, CSSLengthInterpolationType::creat eNeutralInterpolableValue()); 354 list->set(InsetBorderBottomLeftWidthIndex, CSSLengthInterpolationType::creat eNeutralInterpolableValue());
355 list->set(InsetBorderBottomLeftHeightIndex, CSSLengthInterpolationType::crea teNeutralInterpolableValue()); 355 list->set(InsetBorderBottomLeftHeightIndex, CSSLengthInterpolationType::crea teNeutralInterpolableValue());
356 return std::move(list); 356 return std::move(list);
357 } 357 }
358 358
359 PassRefPtr<BasicShape> createBasicShape(const InterpolableValue& interpolableVal ue, const CSSToLengthConversionData& conversionData) 359 PassRefPtr<BasicShape> createBasicShape(const InterpolableValue& interpolableVal ue, const CSSToLengthConversionData& conversionData)
360 { 360 {
361 RefPtr<BasicShapeInset> inset = BasicShapeInset::create(); 361 RefPtr<BasicShapeInset> inset = BasicShapeInset::create();
362 const InterpolableList& list = toInterpolableList(interpolableValue); 362 const InterpolableList& list = toInterpolableList(interpolableValue);
363 inset->setTop(CSSLengthInterpolationType::resolveInterpolableLength(*list.ge t(InsetTopIndex), nullptr, conversionData)); 363 inset->setTop(CSSLengthInterpolationType::createLength(*list.get(InsetTopInd ex), nullptr, conversionData));
364 inset->setRight(CSSLengthInterpolationType::resolveInterpolableLength(*list. get(InsetRightIndex), nullptr, conversionData)); 364 inset->setRight(CSSLengthInterpolationType::createLength(*list.get(InsetRigh tIndex), nullptr, conversionData));
365 inset->setBottom(CSSLengthInterpolationType::resolveInterpolableLength(*list .get(InsetBottomIndex), nullptr, conversionData)); 365 inset->setBottom(CSSLengthInterpolationType::createLength(*list.get(InsetBot tomIndex), nullptr, conversionData));
366 inset->setLeft(CSSLengthInterpolationType::resolveInterpolableLength(*list.g et(InsetLeftIndex), nullptr, conversionData)); 366 inset->setLeft(CSSLengthInterpolationType::createLength(*list.get(InsetLeftI ndex), nullptr, conversionData));
367 367
368 inset->setTopLeftRadius(createBorderRadius(*list.get(InsetBorderTopLeftWidth Index), *list.get(InsetBorderTopLeftHeightIndex), conversionData)); 368 inset->setTopLeftRadius(createBorderRadius(*list.get(InsetBorderTopLeftWidth Index), *list.get(InsetBorderTopLeftHeightIndex), conversionData));
369 inset->setTopRightRadius(createBorderRadius(*list.get(InsetBorderTopRightWid thIndex), *list.get(InsetBorderTopRightHeightIndex), conversionData)); 369 inset->setTopRightRadius(createBorderRadius(*list.get(InsetBorderTopRightWid thIndex), *list.get(InsetBorderTopRightHeightIndex), conversionData));
370 inset->setBottomRightRadius(createBorderRadius(*list.get(InsetBorderBottomRi ghtWidthIndex), *list.get(InsetBorderBottomRightHeightIndex), conversionData)); 370 inset->setBottomRightRadius(createBorderRadius(*list.get(InsetBorderBottomRi ghtWidthIndex), *list.get(InsetBorderBottomRightHeightIndex), conversionData));
371 inset->setBottomLeftRadius(createBorderRadius(*list.get(InsetBorderBottomLef tWidthIndex), *list.get(InsetBorderBottomLeftHeightIndex), conversionData)); 371 inset->setBottomLeftRadius(createBorderRadius(*list.get(InsetBorderBottomLef tWidthIndex), *list.get(InsetBorderBottomLeftHeightIndex), conversionData));
372 return inset.release(); 372 return inset.release();
373 } 373 }
374 374
375 } // namespace InsetFunctions 375 } // namespace InsetFunctions
376 376
(...skipping 28 matching lines...) Expand all
405 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)
406 { 406 {
407 RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create(); 407 RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create();
408 polygon->setWindRule(nonInterpolableValue.windRule()); 408 polygon->setWindRule(nonInterpolableValue.windRule());
409 const InterpolableList& list = toInterpolableList(interpolableValue); 409 const InterpolableList& list = toInterpolableList(interpolableValue);
410 size_t size = nonInterpolableValue.size(); 410 size_t size = nonInterpolableValue.size();
411 DCHECK_EQ(list.length(), size); 411 DCHECK_EQ(list.length(), size);
412 DCHECK_EQ(size % 2, 0U); 412 DCHECK_EQ(size % 2, 0U);
413 for (size_t i = 0; i < size; i += 2) { 413 for (size_t i = 0; i < size; i += 2) {
414 polygon->appendPoint( 414 polygon->appendPoint(
415 CSSLengthInterpolationType::resolveInterpolableLength(*list.get(i), nullptr, conversionData), 415 CSSLengthInterpolationType::createLength(*list.get(i), nullptr, conv ersionData),
416 CSSLengthInterpolationType::resolveInterpolableLength(*list.get(i + 1), nullptr, conversionData)); 416 CSSLengthInterpolationType::createLength(*list.get(i + 1), nullptr, conversionData));
417 } 417 }
418 return polygon.release(); 418 return polygon.release();
419 } 419 }
420 420
421 } // namespace PolygonFunctions 421 } // namespace PolygonFunctions
422 422
423 } // namespace 423 } // namespace
424 424
425 InterpolationValue BasicShapeInterpolationFunctions::maybeConvertCSSValue(const CSSValue& value) 425 InterpolationValue BasicShapeInterpolationFunctions::maybeConvertCSSValue(const CSSValue& value)
426 { 426 {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 return InsetFunctions::createBasicShape(interpolableValue, conversionDat a); 489 return InsetFunctions::createBasicShape(interpolableValue, conversionDat a);
490 case BasicShape::BasicShapePolygonType: 490 case BasicShape::BasicShapePolygonType:
491 return PolygonFunctions::createBasicShape(interpolableValue, nonInterpol ableValue, conversionData); 491 return PolygonFunctions::createBasicShape(interpolableValue, nonInterpol ableValue, conversionData);
492 default: 492 default:
493 NOTREACHED(); 493 NOTREACHED();
494 return nullptr; 494 return nullptr;
495 } 495 }
496 } 496 }
497 497
498 } // namespace blink 498 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698