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