Changeset 200343 in webkit
- Timestamp:
- May 2, 2016 3:19:33 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r200342 r200343 1 2016-05-02 Simon Fraser <simon.fraser@apple.com> 2 3 Make Length, LengthSize and LengthPoint blending not use member functions 4 https://bugs.webkit.org/show_bug.cgi?id=157281 5 6 Reviewed by Zalan Bujtas. 7 8 Having blend() be a member function is ambiguous because it's hard to tell which are 9 the 'from' and 'to' values. Fix Length, LengthSize and LengthPoint accordingly. 10 11 No behavior change. 12 13 * page/animation/CSSPropertyAnimation.cpp: 14 (WebCore::blendFunc): 15 * platform/Length.cpp: 16 (WebCore::blendMixedTypes): 17 (WebCore::blend): 18 (WebCore::Length::blendMixedTypes): Deleted. 19 * platform/Length.h: 20 (WebCore::Length::blend): Deleted. 21 * platform/LengthPoint.h: 22 (WebCore::blend): 23 (WebCore::LengthPoint::blend): Deleted. 24 * platform/LengthSize.h: 25 (WebCore::blend): 26 (WebCore::LengthSize::blend): Deleted. 27 * platform/graphics/filters/FilterOperation.cpp: 28 (WebCore::BlurFilterOperation::blend): 29 * platform/graphics/transforms/TranslateTransformOperation.cpp: 30 (WebCore::TranslateTransformOperation::blend): 31 * rendering/style/BasicShapes.cpp: 32 (WebCore::BasicShapePolygon::blend): 33 (WebCore::BasicShapeInset::blend): 34 * rendering/style/BasicShapes.h: 35 (WebCore::BasicShapeCenterCoordinate::blend): 36 (WebCore::BasicShapeRadius::blend): 37 1 38 2016-05-02 Simon Fraser <simon.fraser@apple.com> 2 39 -
trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp
r200341 r200343 85 85 static inline Length blendFunc(const AnimationBase*, const Length& from, const Length& to, double progress) 86 86 { 87 return to.blend(from, progress);87 return blend(from, to, progress); 88 88 } 89 89 -
trunk/Source/WebCore/platform/Length.cpp
r200341 r200343 252 252 m_calculationValueHandle = calculationValues().insert(WTFMove(value)); 253 253 } 254 255 Length Length::blendMixedTypes(const Length& from, double progress) const256 {257 if (progress <= 0.0)258 return from;259 260 if (progress >= 1.0)261 return *this;262 263 auto blend = std::make_unique<CalcExpressionBlendLength>(from, *this, progress);264 return Length(CalculationValue::create(WTFMove(blend), CalculationRangeAll));265 }266 254 267 255 CalculationValue& Length::calculationValue() const … … 295 283 { 296 284 return calculationValue() == other.calculationValue(); 285 } 286 287 static Length blendMixedTypes(const Length& from, const Length& to, double progress) 288 { 289 if (progress <= 0.0) 290 return from; 291 292 if (progress >= 1.0) 293 return to; 294 295 auto blend = std::make_unique<CalcExpressionBlendLength>(from, to, progress); 296 return Length(CalculationValue::create(WTFMove(blend), CalculationRangeAll)); 297 } 298 299 Length blend(const Length& from, const Length& to, double progress) 300 { 301 if (from.type() == Calculated || to.type() == Calculated) 302 return blendMixedTypes(from, to, progress); 303 304 if (!from.isZero() && !to.isZero() && from.type() != to.type()) 305 return blendMixedTypes(from, to, progress); 306 307 if (from.isZero() && to.isZero()) 308 return progress ? to : from; // Pick up 'auto' from 'from' if progress is zero. 309 310 LengthType resultType = to.type(); 311 if (to.isZero()) 312 resultType = from.type(); 313 314 if (resultType == Percent) { 315 float fromPercent = from.isZero() ? 0 : from.percent(); 316 float toPercent = to.isZero() ? 0 : to.percent(); 317 return Length(WebCore::blend(fromPercent, toPercent, progress), Percent); 318 } 319 320 float fromValue = from.isZero() ? 0 : from.value(); 321 float toValue = to.isZero() ? 0 : to.value(); 322 return Length(WebCore::blend(fromValue, toValue, progress), resultType); 297 323 } 298 324 -
trunk/Source/WebCore/platform/Length.h
r193610 r200343 108 108 bool isSpecifiedOrIntrinsic() const; 109 109 110 // Blend two lengths to produce a new length that is in between them. Used for animation.111 // FIXME: Why is this a member function?112 Length blend(const Length& from, double progress) const;113 114 110 float nonNanCalculatedValue(int maxValue) const; 115 111 … … 118 114 119 115 bool isCalculatedEqual(const Length&) const; 120 Length blendMixedTypes(const Length& from, double progress) const;121 116 122 117 WEBCORE_EXPORT void ref() const; … … 133 128 }; 134 129 130 // Blend two lengths to produce a new length that is in between them. Used for animation. 131 Length blend(const Length& from, const Length& to, double progress); 132 135 133 std::unique_ptr<Length[]> newCoordsArray(const String&, int& length); 136 134 std::unique_ptr<Length[]> newLengthArray(const String&, int& length); … … 413 411 } 414 412 415 // FIXME: Does this need to be in the header? Is it valuable to inline? Does it get inlined?416 inline Length Length::blend(const Length& from, double progress) const417 {418 if (from.type() == Calculated || type() == Calculated)419 return blendMixedTypes(from, progress);420 421 if (!from.isZero() && !isZero() && from.type() != type())422 return blendMixedTypes(from, progress);423 424 if (from.isZero() && isZero())425 return progress ? *this : from; // Pick up 'auto' from 'from' if progress is zero.426 427 LengthType resultType = type();428 if (isZero())429 resultType = from.type();430 431 if (resultType == Percent) {432 float fromPercent = from.isZero() ? 0 : from.percent();433 float toPercent = isZero() ? 0 : percent();434 return Length(WebCore::blend(fromPercent, toPercent, progress), Percent);435 }436 437 float fromValue = from.isZero() ? 0 : from.value();438 float toValue = isZero() ? 0 : value();439 return Length(WebCore::blend(fromValue, toValue, progress), resultType);440 }441 442 413 TextStream& operator<<(TextStream&, Length); 443 414 -
trunk/Source/WebCore/platform/LengthPoint.h
r197617 r200343 59 59 const Length& y() const { return m_y; } 60 60 61 LengthPoint blend(const LengthPoint& from, double progress) const62 {63 return LengthPoint(m_x.blend(from.x(), progress), m_y.blend(from.y(), progress));64 }65 66 61 private: 67 62 // FIXME: it would be nice to pack the two Lengths together better somehow (to avoid padding between them). … … 70 65 }; 71 66 67 inline LengthPoint blend(const LengthPoint& from, const LengthPoint& to, double progress) 68 { 69 return LengthPoint(blend(from.x(), to.x(), progress), blend(from.y(), to.y(), progress)); 70 } 71 72 72 TextStream& operator<<(TextStream&, const LengthPoint&); 73 73 -
trunk/Source/WebCore/platform/LengthSize.h
r194496 r200343 49 49 const Length& height() const { return m_height; } 50 50 51 LengthSize blend(const LengthSize& from, double progress) const52 {53 return LengthSize(m_width.blend(from.width(), progress), m_height.blend(from.height(), progress));54 }55 56 51 private: 57 52 Length m_width; 58 53 Length m_height; 59 54 }; 55 56 inline LengthSize blend(const LengthSize& from, const LengthSize& to, double progress) 57 { 58 return LengthSize(blend(from.width(), to.width(), progress), blend(from.height(), to.height(), progress)); 59 } 60 60 61 61 TextStream& operator<<(TextStream&, const LengthSize&); -
trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp
r191243 r200343 163 163 164 164 if (blendToPassthrough) 165 return BlurFilterOperation::create( Length(lengthType).blend(m_stdDeviation, progress));165 return BlurFilterOperation::create(WebCore::blend(m_stdDeviation, Length(lengthType), progress)); 166 166 167 167 const BlurFilterOperation* fromOperation = downcast<BlurFilterOperation>(from); 168 168 Length fromLength = fromOperation ? fromOperation->m_stdDeviation : Length(lengthType); 169 return BlurFilterOperation::create( m_stdDeviation.blend(fromLength, progress));169 return BlurFilterOperation::create(WebCore::blend(fromLength, m_stdDeviation, progress)); 170 170 } 171 171 -
trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp
r200341 r200343 43 43 Length zeroLength(0, Fixed); 44 44 if (blendToIdentity) 45 return TranslateTransformOperation::create( zeroLength.blend(m_x, progress), zeroLength.blend(m_y, progress), zeroLength.blend(m_z, progress), m_type);45 return TranslateTransformOperation::create(WebCore::blend(m_x, zeroLength, progress), WebCore::blend(m_y, zeroLength, progress), WebCore::blend(m_z, zeroLength, progress), m_type); 46 46 47 47 const TranslateTransformOperation* fromOp = downcast<TranslateTransformOperation>(from); … … 49 49 Length fromY = fromOp ? fromOp->m_y : zeroLength; 50 50 Length fromZ = fromOp ? fromOp->m_z : zeroLength; 51 return TranslateTransformOperation::create( m_x.blend(fromX, progress), m_y.blend(fromY, progress), m_z.blend(fromZ, progress), m_type);51 return TranslateTransformOperation::create(WebCore::blend(fromX, x(), progress), WebCore::blend(fromY, y(), progress), WebCore::blend(fromZ, z(), progress), m_type); 52 52 } 53 53 -
trunk/Source/WebCore/rendering/style/BasicShapes.cpp
r195970 r200343 320 320 321 321 for (size_t i = 0; i < length; i = i + 2) { 322 result->appendPoint(m_values.at(i).blend(otherPolygon.values().at(i), progress), 323 m_values.at(i + 1).blend(otherPolygon.values().at(i + 1), progress)); 322 result->appendPoint( 323 WebCore::blend(otherPolygon.values().at(i), m_values.at(i), progress), 324 WebCore::blend(otherPolygon.values().at(i + 1), m_values.at(i + 1), progress)); 324 325 } 325 326 … … 412 413 } 413 414 414 Ref<BasicShape> BasicShapeInset::blend(const BasicShape& other, double progress) const415 { 416 ASSERT(type() == other.type());417 418 auto& otherInset = downcast<BasicShapeInset>(other);415 Ref<BasicShape> BasicShapeInset::blend(const BasicShape& from, double progress) const 416 { 417 ASSERT(type() == from.type()); 418 419 auto& fromInset = downcast<BasicShapeInset>(from); 419 420 auto result = BasicShapeInset::create(); 420 result->setTop( m_top.blend(otherInset.top(), progress));421 result->setRight( m_right.blend(otherInset.right(), progress));422 result->setBottom( m_bottom.blend(otherInset.bottom(), progress));423 result->setLeft( m_left.blend(otherInset.left(), progress));424 425 result->setTopLeftRadius( m_topLeftRadius.blend(otherInset.topLeftRadius(), progress));426 result->setTopRightRadius( m_topRightRadius.blend(otherInset.topRightRadius(), progress));427 result->setBottomRightRadius( m_bottomRightRadius.blend(otherInset.bottomRightRadius(), progress));428 result->setBottomLeftRadius( m_bottomLeftRadius.blend(otherInset.bottomLeftRadius(), progress));421 result->setTop(WebCore::blend(fromInset.top(), top(), progress)); 422 result->setRight(WebCore::blend(fromInset.right(), right(), progress)); 423 result->setBottom(WebCore::blend(fromInset.bottom(), bottom(), progress)); 424 result->setLeft(WebCore::blend(fromInset.left(), left(), progress)); 425 426 result->setTopLeftRadius(WebCore::blend(fromInset.topLeftRadius(), topLeftRadius(), progress)); 427 result->setTopRightRadius(WebCore::blend(fromInset.topRightRadius(), topRightRadius(), progress)); 428 result->setBottomRightRadius(WebCore::blend(fromInset.bottomRightRadius(), bottomRightRadius(), progress)); 429 result->setBottomLeftRadius(WebCore::blend(fromInset.bottomLeftRadius(), bottomLeftRadius(), progress)); 429 430 430 431 return WTFMove(result); -
trunk/Source/WebCore/rendering/style/BasicShapes.h
r197563 r200343 65 65 66 66 virtual bool canBlend(const BasicShape&) const = 0; 67 virtual Ref<BasicShape> blend(const BasicShape& , double) const = 0;67 virtual Ref<BasicShape> blend(const BasicShape& from, double) const = 0; 68 68 69 69 virtual bool operator==(const BasicShape&) const = 0; … … 102 102 const Length& computedLength() const { return m_computedLength; } 103 103 104 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, double progress) const105 { 106 return BasicShapeCenterCoordinate(TopLeft, m_computedLength.blend(other.m_computedLength, progress));104 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& from, double progress) const 105 { 106 return BasicShapeCenterCoordinate(TopLeft, WebCore::blend(from.m_computedLength, m_computedLength, progress)); 107 107 } 108 108 … … 156 156 } 157 157 158 BasicShapeRadius blend(const BasicShapeRadius& other, double progress) const159 { 160 if (m_type != Value || other.type() != Value)161 return BasicShapeRadius( other);162 163 return BasicShapeRadius( m_value.blend(other.value(), progress));158 BasicShapeRadius blend(const BasicShapeRadius& from, double progress) const 159 { 160 if (m_type != Value || from.type() != Value) 161 return BasicShapeRadius(from); 162 163 return BasicShapeRadius(WebCore::blend(from.value(), value(), progress)); 164 164 } 165 165 … … 196 196 197 197 bool canBlend(const BasicShape&) const override; 198 Ref<BasicShape> blend(const BasicShape& , double) const override;198 Ref<BasicShape> blend(const BasicShape& from, double) const override; 199 199 200 200 bool operator==(const BasicShape&) const override; … … 228 228 229 229 bool canBlend(const BasicShape&) const override; 230 Ref<BasicShape> blend(const BasicShape& , double) const override;230 Ref<BasicShape> blend(const BasicShape& from, double) const override; 231 231 232 232 bool operator==(const BasicShape&) const override; … … 259 259 260 260 bool canBlend(const BasicShape&) const override; 261 Ref<BasicShape> blend(const BasicShape& , double) const override;261 Ref<BasicShape> blend(const BasicShape& from, double) const override; 262 262 263 263 bool operator==(const BasicShape&) const override; … … 287 287 288 288 bool canBlend(const BasicShape&) const override; 289 Ref<BasicShape> blend(const BasicShape& , double) const override;289 Ref<BasicShape> blend(const BasicShape& from, double) const override; 290 290 291 291 bool operator==(const BasicShape&) const override; … … 327 327 328 328 bool canBlend(const BasicShape&) const override; 329 Ref<BasicShape> blend(const BasicShape& , double) const override;329 Ref<BasicShape> blend(const BasicShape& from, double) const override; 330 330 331 331 bool operator==(const BasicShape&) const override;
Note: See TracChangeset
for help on using the changeset viewer.