Changeset 276141 in webkit
- Timestamp:
- Apr 16, 2021, 9:55:43 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 40 edited
-
ChangeLog (modified) (1 diff)
-
animation/CSSPropertyAnimation.cpp (modified) (94 diffs)
-
animation/CSSPropertyAnimation.h (modified) (2 diffs)
-
animation/KeyframeEffect.cpp (modified) (3 diffs)
-
css/CSSCrossfadeValue.cpp (modified) (3 diffs)
-
css/CSSCrossfadeValue.h (modified) (2 diffs)
-
css/CSSGradientValue.cpp (modified) (5 diffs)
-
platform/Length.cpp (modified) (3 diffs)
-
platform/Length.h (modified) (2 diffs)
-
platform/LengthPoint.h (modified) (2 diffs)
-
platform/LengthSize.h (modified) (2 diffs)
-
platform/animation/AnimationUtilities.h (modified) (1 diff)
-
platform/graphics/ColorBlending.cpp (modified) (4 diffs)
-
platform/graphics/ColorBlending.h (modified) (2 diffs)
-
platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm (modified) (1 diff)
-
platform/graphics/filters/FilterOperation.cpp (modified) (10 diffs)
-
platform/graphics/filters/FilterOperation.h (modified) (7 diffs)
-
platform/graphics/transforms/IdentityTransformOperation.h (modified) (2 diffs)
-
platform/graphics/transforms/Matrix3DTransformOperation.cpp (modified) (3 diffs)
-
platform/graphics/transforms/Matrix3DTransformOperation.h (modified) (2 diffs)
-
platform/graphics/transforms/MatrixTransformOperation.cpp (modified) (3 diffs)
-
platform/graphics/transforms/MatrixTransformOperation.h (modified) (2 diffs)
-
platform/graphics/transforms/PerspectiveTransformOperation.cpp (modified) (3 diffs)
-
platform/graphics/transforms/PerspectiveTransformOperation.h (modified) (2 diffs)
-
platform/graphics/transforms/RotateTransformOperation.cpp (modified) (4 diffs)
-
platform/graphics/transforms/RotateTransformOperation.h (modified) (2 diffs)
-
platform/graphics/transforms/ScaleTransformOperation.cpp (modified) (3 diffs)
-
platform/graphics/transforms/ScaleTransformOperation.h (modified) (2 diffs)
-
platform/graphics/transforms/SkewTransformOperation.cpp (modified) (2 diffs)
-
platform/graphics/transforms/SkewTransformOperation.h (modified) (2 diffs)
-
platform/graphics/transforms/TransformOperation.h (modified) (2 diffs)
-
platform/graphics/transforms/TransformOperations.cpp (modified) (7 diffs)
-
platform/graphics/transforms/TransformOperations.h (modified) (2 diffs)
-
platform/graphics/transforms/TranslateTransformOperation.cpp (modified) (4 diffs)
-
platform/graphics/transforms/TranslateTransformOperation.h (modified) (2 diffs)
-
rendering/style/BasicShapes.cpp (modified) (11 diffs)
-
rendering/style/BasicShapes.h (modified) (9 diffs)
-
style/Styleable.cpp (modified) (3 diffs)
-
svg/SVGLengthValue.cpp (modified) (3 diffs)
-
svg/SVGPathBlender.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r276138 r276141 1 2021-04-16 Antoine Quint <graouts@webkit.org> 2 3 Refactor parameters to blending functions 4 https://bugs.webkit.org/show_bug.cgi?id=224433 5 6 Reviewed by Dean Jackson. 7 8 Reduce the number of parameters passed to the blending functions such that we package 9 the client and progress together and track whether the animation is discrete instead 10 of computing it several times. This information is now passed as a BlendingContext 11 parameter, and a CSSPropertyBlendingContext private to CSSPropertyAnimation. 12 13 When we support composite operations, we'll just need to add a new member to that 14 struct instead of modifying all the method signatures. 15 16 Since we are modifying the method signatures, we also change the RenderStyle pointers 17 to references since we would never pass in a null value. 18 19 * animation/CSSPropertyAnimation.cpp: 20 (WebCore::CSSPropertyBlendingContext::CSSPropertyBlendingContext): 21 (WebCore::blendFunc): 22 (WebCore::blendFilterOperations): 23 (WebCore::blendFilter): 24 (WebCore::crossfadeBlend): 25 (WebCore::AnimationPropertyWrapperBase::canInterpolate const): 26 (WebCore::PropertyWrapperGetter::value const): 27 (WebCore::canInterpolateCaretColor): 28 (WebCore::CSSPropertyAnimation::blendProperties): 29 (WebCore::CSSPropertyAnimation::propertiesEqual): 30 (WebCore::CSSPropertyAnimation::canPropertyBeInterpolated): 31 * animation/CSSPropertyAnimation.h: 32 * animation/KeyframeEffect.cpp: 33 (WebCore::KeyframeEffect::setAnimatedPropertiesInStyle): 34 * css/CSSCrossfadeValue.cpp: 35 (WebCore::blendFunc): 36 (WebCore::CSSCrossfadeValue::blend const): 37 * css/CSSCrossfadeValue.h: 38 * css/CSSGradientValue.cpp: 39 (WebCore::RadialGradientAdapter::normalizeStopsAndEndpointsOutsideRange): 40 (WebCore::ConicGradientAdapter::normalizeStopsAndEndpointsOutsideRange): 41 (WebCore::CSSGradientValue::computeStops): 42 * platform/Length.cpp: 43 (WebCore::blendMixedTypes): 44 (WebCore::blend): 45 * platform/Length.h: 46 * platform/LengthPoint.h: 47 (WebCore::blend): 48 * platform/LengthSize.h: 49 (WebCore::blend): 50 * platform/animation/AnimationUtilities.h: 51 (WebCore::blend): 52 * platform/graphics/ColorBlending.cpp: 53 (WebCore::blend): 54 (WebCore::blendWithoutPremultiply): 55 * platform/graphics/ColorBlending.h: 56 * platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm: 57 (WebCore::PlatformCAFilters::colorMatrixValueForFilter): 58 * platform/graphics/filters/FilterOperation.cpp: 59 (WebCore::BasicColorMatrixFilterOperation::blend): 60 (WebCore::BasicComponentTransferFilterOperation::blend): 61 (WebCore::InvertLightnessFilterOperation::blend): 62 (WebCore::BlurFilterOperation::blend): 63 (WebCore::DropShadowFilterOperation::blend): 64 * platform/graphics/filters/FilterOperation.h: 65 (WebCore::FilterOperation::blend): 66 * platform/graphics/transforms/IdentityTransformOperation.h: 67 * platform/graphics/transforms/Matrix3DTransformOperation.cpp: 68 (WebCore::createOperation): 69 (WebCore::Matrix3DTransformOperation::blend): 70 * platform/graphics/transforms/Matrix3DTransformOperation.h: 71 * platform/graphics/transforms/MatrixTransformOperation.cpp: 72 (WebCore::MatrixTransformOperation::blend): 73 * platform/graphics/transforms/MatrixTransformOperation.h: 74 * platform/graphics/transforms/PerspectiveTransformOperation.cpp: 75 (WebCore::PerspectiveTransformOperation::blend): 76 * platform/graphics/transforms/PerspectiveTransformOperation.h: 77 * platform/graphics/transforms/RotateTransformOperation.cpp: 78 (WebCore::RotateTransformOperation::blend): 79 * platform/graphics/transforms/RotateTransformOperation.h: 80 * platform/graphics/transforms/ScaleTransformOperation.cpp: 81 (WebCore::ScaleTransformOperation::blend): 82 * platform/graphics/transforms/ScaleTransformOperation.h: 83 * platform/graphics/transforms/SkewTransformOperation.cpp: 84 (WebCore::SkewTransformOperation::blend): 85 * platform/graphics/transforms/SkewTransformOperation.h: 86 * platform/graphics/transforms/TransformOperation.h: 87 * platform/graphics/transforms/TransformOperations.cpp: 88 (WebCore::TransformOperations::blendByMatchingOperations const): 89 (WebCore::TransformOperations::blendByUsingMatrixInterpolation const): 90 (WebCore::TransformOperations::blend const): 91 * platform/graphics/transforms/TransformOperations.h: 92 * platform/graphics/transforms/TranslateTransformOperation.cpp: 93 (WebCore::TranslateTransformOperation::blend): 94 * platform/graphics/transforms/TranslateTransformOperation.h: 95 * rendering/style/BasicShapes.cpp: 96 (WebCore::BasicShapeCircle::blend const): 97 (WebCore::BasicShapeEllipse::blend const): 98 (WebCore::BasicShapePolygon::blend const): 99 (WebCore::BasicShapePath::blend const): 100 (WebCore::BasicShapeInset::blend const): 101 * rendering/style/BasicShapes.h: 102 (WebCore::BasicShapeCenterCoordinate::blend const): 103 (WebCore::BasicShapeRadius::blend const): 104 * style/Styleable.cpp: 105 (WebCore::propertyInStyleMatchesValueForTransitionInMap): 106 (WebCore::updateCSSTransitionsForStyleableAndProperty): 107 * svg/SVGLengthValue.cpp: 108 (WebCore::SVGLengthValue::blend): 109 * svg/SVGPathBlender.cpp: 110 (WebCore::blendFloatPoint): 111 (WebCore::SVGPathBlender::blendAnimatedDimensonalFloat): 112 (WebCore::SVGPathBlender::blendArcToSegment): 113 1 114 2021-04-16 Antoine Quint <graouts@webkit.org> 2 115 -
trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp
r276138 r276141 31 31 #include "CSSPropertyAnimation.h" 32 32 33 #include "AnimationUtilities.h" 33 34 #include "CSSComputedStyleDeclaration.h" 34 35 #include "CSSCrossfadeValue.h" … … 71 72 namespace WebCore { 72 73 73 static inline int blendFunc(const CSSPropertyBlendingClient*, int from, int to, double progress) 74 { 75 return blend(from, to, progress); 76 } 77 78 static inline double blendFunc(const CSSPropertyBlendingClient*, double from, double to, double progress) 79 { 80 return blend(from, to, progress); 81 } 82 83 static inline float blendFunc(const CSSPropertyBlendingClient*, float from, float to, double progress) 84 { 85 return narrowPrecisionToFloat(from + (to - from) * progress); 86 } 87 88 static inline Color blendFunc(const CSSPropertyBlendingClient*, const Color& from, const Color& to, double progress) 89 { 90 return blend(from, to, progress); 91 } 92 93 static inline Length blendFunc(const CSSPropertyBlendingClient*, const Length& from, const Length& to, double progress, ValueRange valueRange = ValueRangeAll) 94 { 95 return blend(from, to, progress, valueRange); 96 } 97 98 static inline GapLength blendFunc(const CSSPropertyBlendingClient*, const GapLength& from, const GapLength& to, double progress) 74 struct CSSPropertyBlendingContext : BlendingContext { 75 const CSSPropertyBlendingClient* client { nullptr }; 76 77 CSSPropertyBlendingContext(double progress, bool isDiscrete, const CSSPropertyBlendingClient* client) 78 : BlendingContext(progress, isDiscrete) 79 , client(client) 80 { 81 } 82 }; 83 84 static inline int blendFunc(int from, int to, const CSSPropertyBlendingContext& context) 85 { 86 return blend(from, to, context); 87 } 88 89 static inline double blendFunc(double from, double to, const CSSPropertyBlendingContext& context) 90 { 91 return blend(from, to, context); 92 } 93 94 static inline float blendFunc(float from, float to, const CSSPropertyBlendingContext& context) 95 { 96 return narrowPrecisionToFloat(from + (to - from) * context.progress); 97 } 98 99 static inline Color blendFunc(const Color& from, const Color& to, const CSSPropertyBlendingContext& context) 100 { 101 return blend(from, to, context); 102 } 103 104 static inline Length blendFunc(const Length& from, const Length& to, const CSSPropertyBlendingContext& context, ValueRange valueRange = ValueRangeAll) 105 { 106 return blend(from, to, context, valueRange); 107 } 108 109 static inline GapLength blendFunc(const GapLength& from, const GapLength& to, const CSSPropertyBlendingContext& context) 99 110 { 100 111 if (from.isNormal() || to.isNormal()) 101 return progress < 0.5 ? from : to;102 return blend(from.length(), to.length(), progress, ValueRangeNonNegative);103 } 104 105 static inline TabSize blendFunc(const CSSPropertyBlendingClient*, const TabSize& from, const TabSize& to, double progress)106 { 107 auto blendedValue = blend(from.value(), to.value(), progress);112 return context.progress < 0.5 ? from : to; 113 return blend(from.length(), to.length(), context, ValueRangeNonNegative); 114 } 115 116 static inline TabSize blendFunc(const TabSize& from, const TabSize& to, const CSSPropertyBlendingContext& context) 117 { 118 auto blendedValue = blend(from.value(), to.value(), context); 108 119 return { blendedValue < 0 ? 0 : blendedValue, from.isSpaces() ? SpaceValueType : LengthValueType }; 109 120 } 110 121 111 static inline LengthSize blendFunc(const CSSPropertyBlendingClient* client, const LengthSize& from, const LengthSize& to, double progress)112 { 113 return { blendFunc( client, from.width, to.width, progress, ValueRangeNonNegative),114 blendFunc( client, from.height, to.height, progress, ValueRangeNonNegative) };115 } 116 117 static inline LengthPoint blendFunc(const CSSPropertyBlendingClient*, const LengthPoint& from, const LengthPoint& to, double progress)118 { 119 return blend(from, to, progress);120 } 121 122 static inline ShadowStyle blendFunc( const CSSPropertyBlendingClient* client, ShadowStyle from, ShadowStyle to, double progress)122 static inline LengthSize blendFunc(const LengthSize& from, const LengthSize& to, const CSSPropertyBlendingContext& context) 123 { 124 return { blendFunc(from.width, to.width, context, ValueRangeNonNegative), 125 blendFunc(from.height, to.height, context, ValueRangeNonNegative) }; 126 } 127 128 static inline LengthPoint blendFunc(const LengthPoint& from, const LengthPoint& to, const CSSPropertyBlendingContext& context) 129 { 130 return blend(from, to, context); 131 } 132 133 static inline ShadowStyle blendFunc(ShadowStyle from, ShadowStyle to, const CSSPropertyBlendingContext& context) 123 134 { 124 135 if (from == to) … … 127 138 double fromVal = from == ShadowStyle::Normal ? 1 : 0; 128 139 double toVal = to == ShadowStyle::Normal ? 1 : 0; 129 double result = blendFunc( client, fromVal, toVal, progress);140 double result = blendFunc(fromVal, toVal, context); 130 141 return result > 0 ? ShadowStyle::Normal : ShadowStyle::Inset; 131 142 } 132 143 133 static inline std::unique_ptr<ShadowData> blendFunc(const CSSPropertyBlendingClient* client, const ShadowData* from, const ShadowData* to, double progress)144 static inline std::unique_ptr<ShadowData> blendFunc(const ShadowData* from, const ShadowData* to, const CSSPropertyBlendingContext& context) 134 145 { 135 146 ASSERT(from && to); 136 147 ASSERT(from->style() == to->style()); 137 148 138 return makeUnique<ShadowData>(blend(from->location(), to->location(), progress),139 std::max(0, blend(from->radius(), to->radius(), progress)),140 blend(from->spread(), to->spread(), progress),141 blendFunc( client, from->style(), to->style(), progress),149 return makeUnique<ShadowData>(blend(from->location(), to->location(), context), 150 std::max(0, blend(from->radius(), to->radius(), context)), 151 blend(from->spread(), to->spread(), context), 152 blendFunc(from->style(), to->style(), context), 142 153 from->isWebkitBoxShadow(), 143 blend(from->color(), to->color(), progress));144 } 145 146 static inline TransformOperations blendFunc(const CSSPropertyBlendingClient* client, const TransformOperations& from, const TransformOperations& to, double progress)147 { 148 if (c lient->transformFunctionListsMatch())149 return to.blendByMatchingOperations(from, progress);150 return to.blendByUsingMatrixInterpolation(from, progress, is<RenderBox>(client->renderer()) ? downcast<RenderBox>(*client->renderer()).borderBoxRect().size() : LayoutSize());151 } 152 153 static RefPtr<ScaleTransformOperation> blendFunc( const CSSPropertyBlendingClient* client, ScaleTransformOperation* from, ScaleTransformOperation* to, double progress)154 blend(from->color(), to->color(), context)); 155 } 156 157 static inline TransformOperations blendFunc(const TransformOperations& from, const TransformOperations& to, const CSSPropertyBlendingContext& context) 158 { 159 if (context.client->transformFunctionListsMatch()) 160 return to.blendByMatchingOperations(from, context); 161 return to.blendByUsingMatrixInterpolation(from, context, is<RenderBox>(context.client->renderer()) ? downcast<RenderBox>(*context.client->renderer()).borderBoxRect().size() : LayoutSize()); 162 } 163 164 static RefPtr<ScaleTransformOperation> blendFunc(ScaleTransformOperation* from, ScaleTransformOperation* to, const CSSPropertyBlendingContext& context) 154 165 { 155 166 if (!from && !to) … … 176 187 normalizedTo = ScaleTransformOperation::create(to->x(), to->y(), TransformOperation::SCALE); 177 188 } 178 return blendFunc( client, normalizedFrom.get(), normalizedTo.get(), progress);179 } 180 181 auto blendedOperation = to->blend(from, progress);189 return blendFunc(normalizedFrom.get(), normalizedTo.get(), context); 190 } 191 192 auto blendedOperation = to->blend(from, context); 182 193 if (is<ScaleTransformOperation>(blendedOperation.get())) { 183 194 auto& scale = downcast<ScaleTransformOperation>(blendedOperation.get()); … … 187 198 } 188 199 189 static RefPtr<RotateTransformOperation> blendFunc( const CSSPropertyBlendingClient* client, RotateTransformOperation* from, RotateTransformOperation* to, double progress)200 static RefPtr<RotateTransformOperation> blendFunc(RotateTransformOperation* from, RotateTransformOperation* to, const CSSPropertyBlendingContext& context) 190 201 { 191 202 if (!from && !to) … … 212 223 normalizedTo = RotateTransformOperation::create(to->angle(), TransformOperation::ROTATE); 213 224 } 214 return blendFunc( client, normalizedFrom.get(), normalizedTo.get(), progress);215 } 216 217 auto blendedOperation = to->blend(from, progress);225 return blendFunc(normalizedFrom.get(), normalizedTo.get(), context); 226 } 227 228 auto blendedOperation = to->blend(from, context); 218 229 if (is<RotateTransformOperation>(blendedOperation.get())) { 219 230 auto& rotate = downcast<RotateTransformOperation>(blendedOperation.get()); … … 223 234 } 224 235 225 static RefPtr<TranslateTransformOperation> blendFunc( const CSSPropertyBlendingClient* client, TranslateTransformOperation* from, TranslateTransformOperation* to, double progress)236 static RefPtr<TranslateTransformOperation> blendFunc(TranslateTransformOperation* from, TranslateTransformOperation* to, const CSSPropertyBlendingContext& context) 226 237 { 227 238 if (!from && !to) … … 248 259 normalizedTo = TranslateTransformOperation::create(to->x(), to->y(), TransformOperation::TRANSLATE); 249 260 } 250 return blendFunc( client, normalizedFrom.get(), normalizedTo.get(), progress);251 } 252 253 Ref<TransformOperation> blendedOperation = to->blend(from, progress);261 return blendFunc(normalizedFrom.get(), normalizedTo.get(), context); 262 } 263 264 Ref<TransformOperation> blendedOperation = to->blend(from, context); 254 265 if (is<TranslateTransformOperation>(blendedOperation.get())) { 255 266 TranslateTransformOperation& translate = downcast<TranslateTransformOperation>(blendedOperation.get()); … … 259 270 } 260 271 261 static inline RefPtr<ClipPathOperation> blendFunc( const CSSPropertyBlendingClient*, ClipPathOperation* from, ClipPathOperation* to, double progress)272 static inline RefPtr<ClipPathOperation> blendFunc(ClipPathOperation* from, ClipPathOperation* to, const CSSPropertyBlendingContext& context) 262 273 { 263 274 if (!from || !to) … … 274 285 return to; 275 286 276 return ShapeClipPathOperation::create(toShape.blend(fromShape, progress));277 } 278 279 static inline RefPtr<ShapeValue> blendFunc( const CSSPropertyBlendingClient*, ShapeValue* from, ShapeValue* to, double progress)280 { 281 if (! progress)287 return ShapeClipPathOperation::create(toShape.blend(fromShape, context)); 288 } 289 290 static inline RefPtr<ShapeValue> blendFunc(ShapeValue* from, ShapeValue* to, const CSSPropertyBlendingContext& context) 291 { 292 if (!context.progress) 282 293 return from; 283 294 284 if ( progress == 1.0)295 if (context.progress == 1.0) 285 296 return to; 286 297 … … 288 299 const BasicShape& fromShape = *from->shape(); 289 300 const BasicShape& toShape = *to->shape(); 290 return ShapeValue::create(toShape.blend(fromShape, progress), to->cssBox());291 } 292 293 static inline RefPtr<FilterOperation> blendFunc( const CSSPropertyBlendingClient*, FilterOperation* from, FilterOperation* to, double progress, bool blendToPassthrough = false)301 return ShapeValue::create(toShape.blend(fromShape, context), to->cssBox()); 302 } 303 304 static inline RefPtr<FilterOperation> blendFunc(FilterOperation* from, FilterOperation* to, const CSSPropertyBlendingContext& context, bool blendToPassthrough = false) 294 305 { 295 306 ASSERT(to); 296 return to->blend(from, progress, blendToPassthrough);297 } 298 299 static inline FilterOperations blendFilterOperations(const CSSPropertyBlendingClient* client, const FilterOperations& from, const FilterOperations& to, double progress)307 return to->blend(from, context, blendToPassthrough); 308 } 309 310 static inline FilterOperations blendFilterOperations(const FilterOperations& from, const FilterOperations& to, const CSSPropertyBlendingContext& context) 300 311 { 301 312 FilterOperations result; … … 306 317 RefPtr<FilterOperation> fromOp = (i < fromSize) ? from.operations()[i].get() : 0; 307 318 RefPtr<FilterOperation> toOp = (i < toSize) ? to.operations()[i].get() : 0; 308 RefPtr<FilterOperation> blendedOp = toOp ? blendFunc( client, fromOp.get(), toOp.get(), progress) : (fromOp ? blendFunc(client, 0, fromOp.get(), progress, true) : 0);319 RefPtr<FilterOperation> blendedOp = toOp ? blendFunc(fromOp.get(), toOp.get(), context) : (fromOp ? blendFunc(0, fromOp.get(), context, true) : 0); 309 320 if (blendedOp) 310 321 result.operations().append(blendedOp); 311 322 else { 312 323 auto identityOp = PassthroughFilterOperation::create(); 313 if ( progress > 0.5)324 if (context.progress > 0.5) 314 325 result.operations().append(toOp ? toOp : WTFMove(identityOp)); 315 326 else … … 320 331 } 321 332 322 static inline FilterOperations blendFunc(const CSSPropertyBlendingClient* client, const FilterOperations& from, const FilterOperations& to, double progress, CSSPropertyID propertyID = CSSPropertyFilter)333 static inline FilterOperations blendFunc(const FilterOperations& from, const FilterOperations& to, const CSSPropertyBlendingContext& context, CSSPropertyID propertyID = CSSPropertyFilter) 323 334 { 324 335 FilterOperations result; … … 329 340 switch (propertyID) { 330 341 case CSSPropertyFilter: 331 listsMatch = c lient->filterFunctionListsMatch();342 listsMatch = context.client->filterFunctionListsMatch(); 332 343 break; 333 344 #if ENABLE(FILTERS_LEVEL_2) 334 345 case CSSPropertyWebkitBackdropFilter: 335 listsMatch = c lient->backdropFilterFunctionListsMatch();346 listsMatch = context.client->backdropFilterFunctionListsMatch(); 336 347 break; 337 348 #endif 338 349 case CSSPropertyAppleColorFilter: 339 listsMatch = c lient->colorFilterFunctionListsMatch();350 listsMatch = context.client->colorFilterFunctionListsMatch(); 340 351 break; 341 352 default: … … 344 355 345 356 if (listsMatch) 346 result = blendFilterOperations( client, from, to, progress);357 result = blendFilterOperations(from, to, context); 347 358 else { 348 359 // If the filter function lists don't match, we could try to cross-fade, but don't yet have a way to represent that in CSS. … … 354 365 } 355 366 356 static inline RefPtr<StyleImage> blendFilter( const CSSPropertyBlendingClient* client, CachedImage* image, const FilterOperations& from, const FilterOperations& to, double progress)367 static inline RefPtr<StyleImage> blendFilter(CachedImage* image, const FilterOperations& from, const FilterOperations& to, const CSSPropertyBlendingContext& context) 357 368 { 358 369 ASSERT(image); 359 FilterOperations filterResult = blendFilterOperations( client, from, to, progress);370 FilterOperations filterResult = blendFilterOperations(from, to, context); 360 371 361 372 auto imageValue = CSSImageValue::create(*image); 362 auto filterValue = ComputedStyleExtractor::valueForFilter(c lient->currentStyle(), filterResult, DoNotAdjustPixelValues);373 auto filterValue = ComputedStyleExtractor::valueForFilter(context.client->currentStyle(), filterResult, DoNotAdjustPixelValues); 363 374 364 375 auto result = CSSFilterImageValue::create(WTFMove(imageValue), WTFMove(filterValue)); … … 367 378 } 368 379 369 static inline Visibility blendFunc( const CSSPropertyBlendingClient* client, Visibility from, Visibility to, double progress)380 static inline Visibility blendFunc(Visibility from, Visibility to, const CSSPropertyBlendingContext& context) 370 381 { 371 382 // Any non-zero result means we consider the object to be visible. Only at 0 do we consider the object to be … … 375 386 if (fromVal == toVal) 376 387 return to; 377 double result = blendFunc( client, fromVal, toVal, progress);388 double result = blendFunc(fromVal, toVal, context); 378 389 return result > 0. ? Visibility::Visible : (to != Visibility::Visible ? to : from); 379 390 } 380 391 381 static inline TextUnderlineOffset blendFunc(const CSSPropertyBlendingClient* client, const TextUnderlineOffset& from, const TextUnderlineOffset& to, double progress)392 static inline TextUnderlineOffset blendFunc(const TextUnderlineOffset& from, const TextUnderlineOffset& to, const CSSPropertyBlendingContext& context) 382 393 { 383 394 if (from.isLength() && to.isLength()) 384 return TextUnderlineOffset::createWithLength(blendFunc( client, from.lengthValue(), to.lengthValue(), progress));395 return TextUnderlineOffset::createWithLength(blendFunc(from.lengthValue(), to.lengthValue(), context)); 385 396 return TextUnderlineOffset::createWithAuto(); 386 397 } 387 398 388 static inline TextDecorationThickness blendFunc(const CSSPropertyBlendingClient* client, const TextDecorationThickness& from, const TextDecorationThickness& to, double progress)399 static inline TextDecorationThickness blendFunc(const TextDecorationThickness& from, const TextDecorationThickness& to, const CSSPropertyBlendingContext& context) 389 400 { 390 401 if (from.isLength() && to.isLength()) 391 return TextDecorationThickness::createWithLength(blendFunc( client, from.lengthValue(), to.lengthValue(), progress));402 return TextDecorationThickness::createWithLength(blendFunc(from.lengthValue(), to.lengthValue(), context)); 392 403 return TextDecorationThickness::createWithAuto(); 393 404 } 394 405 395 static inline LengthBox blendFunc(const CSSPropertyBlendingClient* client, const LengthBox& from, const LengthBox& to, double progress, ValueRange valueRange = ValueRangeNonNegative)396 { 397 LengthBox result(blendFunc( client, from.top(), to.top(), progress, valueRange),398 blendFunc( client, from.right(), to.right(), progress, valueRange),399 blendFunc( client, from.bottom(), to.bottom(), progress, valueRange),400 blendFunc( client, from.left(), to.left(), progress, valueRange));406 static inline LengthBox blendFunc(const LengthBox& from, const LengthBox& to, const CSSPropertyBlendingContext& context, ValueRange valueRange = ValueRangeNonNegative) 407 { 408 LengthBox result(blendFunc(from.top(), to.top(), context, valueRange), 409 blendFunc(from.right(), to.right(), context, valueRange), 410 blendFunc(from.bottom(), to.bottom(), context, valueRange), 411 blendFunc(from.left(), to.left(), context, valueRange)); 401 412 return result; 402 413 } 403 414 404 static inline SVGLengthValue blendFunc(const CSSPropertyBlendingClient*, const SVGLengthValue& from, const SVGLengthValue& to, double progress)405 { 406 return SVGLengthValue::blend(from, to, narrowPrecisionToFloat( progress));407 } 408 409 static inline Vector<SVGLengthValue> blendFunc(const CSSPropertyBlendingClient*, const Vector<SVGLengthValue>& from, const Vector<SVGLengthValue>& to, double progress)415 static inline SVGLengthValue blendFunc(const SVGLengthValue& from, const SVGLengthValue& to, const CSSPropertyBlendingContext& context) 416 { 417 return SVGLengthValue::blend(from, to, narrowPrecisionToFloat(context.progress)); 418 } 419 420 static inline Vector<SVGLengthValue> blendFunc(const Vector<SVGLengthValue>& from, const Vector<SVGLengthValue>& to, const CSSPropertyBlendingContext& context) 410 421 { 411 422 size_t fromLength = from.size(); 412 423 size_t toLength = to.size(); 413 424 if (!fromLength) 414 return ! progress ? from : to;425 return !context.progress ? from : to; 415 426 if (!toLength) 416 return progress == 1 ? from : to;427 return context.progress == 1 ? from : to; 417 428 size_t resultLength = fromLength; 418 429 if (fromLength != toLength) { … … 424 435 Vector<SVGLengthValue> result(resultLength); 425 436 for (size_t i = 0; i < resultLength; ++i) 426 result[i] = SVGLengthValue::blend(from[i % fromLength], to[i % toLength], narrowPrecisionToFloat( progress));437 result[i] = SVGLengthValue::blend(from[i % fromLength], to[i % toLength], narrowPrecisionToFloat(context.progress)); 427 438 return result; 428 439 } 429 440 430 static inline RefPtr<StyleImage> crossfadeBlend( const CSSPropertyBlendingClient*, StyleCachedImage* fromStyleImage, StyleCachedImage* toStyleImage, double progress)441 static inline RefPtr<StyleImage> crossfadeBlend(StyleCachedImage* fromStyleImage, StyleCachedImage* toStyleImage, const CSSPropertyBlendingContext& context) 431 442 { 432 443 // If progress is at one of the extremes, we want getComputedStyle to show the image, 433 444 // not a completed cross-fade, so we hand back one of the existing images. 434 if (! progress)445 if (!context.progress) 435 446 return fromStyleImage; 436 if ( progress == 1)447 if (context.progress == 1) 437 448 return toStyleImage; 438 449 if (!fromStyleImage->cachedImage() || !toStyleImage->cachedImage()) … … 441 452 auto fromImageValue = CSSImageValue::create(*fromStyleImage->cachedImage()); 442 453 auto toImageValue = CSSImageValue::create(*toStyleImage->cachedImage()); 443 auto percentageValue = CSSPrimitiveValue::create( progress, CSSUnitType::CSS_NUMBER);454 auto percentageValue = CSSPrimitiveValue::create(context.progress, CSSUnitType::CSS_NUMBER); 444 455 445 456 auto crossfadeValue = CSSCrossfadeValue::create(WTFMove(fromImageValue), WTFMove(toImageValue), WTFMove(percentageValue)); … … 447 458 } 448 459 449 static inline RefPtr<StyleImage> blendFunc( const CSSPropertyBlendingClient* client, StyleImage* from, StyleImage* to, double progress)450 { 451 if (! progress)460 static inline RefPtr<StyleImage> blendFunc(StyleImage* from, StyleImage* to, const CSSPropertyBlendingContext& context) 461 { 462 if (!context.progress) 452 463 return from; 453 464 454 if ( progress == 1.0)465 if (context.progress == 1.0) 455 466 return to; 456 467 … … 474 485 CSSFilterImageValue& toFilter = downcast<CSSFilterImageValue>(toGenerated); 475 486 if (fromFilter.equalInputImages(toFilter) && fromFilter.cachedImage()) 476 return blendFilter( client, fromFilter.cachedImage(), fromFilter.filterOperations(), toFilter.filterOperations(), progress);487 return blendFilter(fromFilter.cachedImage(), fromFilter.filterOperations(), toFilter.filterOperations(), context); 477 488 } 478 489 … … 481 492 CSSCrossfadeValue& toCrossfade = downcast<CSSCrossfadeValue>(toGenerated); 482 493 if (fromCrossfade.equalInputImages(toCrossfade)) { 483 if (auto crossfadeBlend = toCrossfade.blend(fromCrossfade, progress))494 if (auto crossfadeBlend = toCrossfade.blend(fromCrossfade, context)) 484 495 return StyleGeneratedImage::create(*crossfadeBlend); 485 496 } … … 493 504 CSSFilterImageValue& fromFilter = downcast<CSSFilterImageValue>(fromGenerated); 494 505 if (fromFilter.cachedImage() && downcast<StyleCachedImage>(*to).cachedImage() == fromFilter.cachedImage()) 495 return blendFilter( client, fromFilter.cachedImage(), fromFilter.filterOperations(), FilterOperations(), progress);506 return blendFilter(fromFilter.cachedImage(), fromFilter.filterOperations(), FilterOperations(), context); 496 507 } 497 508 // FIXME: Add interpolation between cross-fade and image source. … … 501 512 CSSFilterImageValue& toFilter = downcast<CSSFilterImageValue>(toGenerated); 502 513 if (toFilter.cachedImage() && downcast<StyleCachedImage>(*from).cachedImage() == toFilter.cachedImage()) 503 return blendFilter( client, toFilter.cachedImage(), FilterOperations(), toFilter.filterOperations(), progress);514 return blendFilter(toFilter.cachedImage(), FilterOperations(), toFilter.filterOperations(), context); 504 515 } 505 516 // FIXME: Add interpolation between image source and cross-fade. … … 509 520 // https://bugs.webkit.org/show_bug.cgi?id=78293 510 521 if (is<StyleCachedImage>(*from) && is<StyleCachedImage>(*to)) 511 return crossfadeBlend( client, downcast<StyleCachedImage>(from), downcast<StyleCachedImage>(to), progress);522 return crossfadeBlend(downcast<StyleCachedImage>(from), downcast<StyleCachedImage>(to), context); 512 523 513 524 return to; 514 525 } 515 526 516 static inline NinePieceImage blendFunc(const CSSPropertyBlendingClient* client, const NinePieceImage& from, const NinePieceImage& to, double progress)527 static inline NinePieceImage blendFunc(const NinePieceImage& from, const NinePieceImage& to, const CSSPropertyBlendingContext& context) 517 528 { 518 529 if (!from.hasImage() || !to.hasImage()) … … 524 535 return to; 525 536 526 if (auto* renderer = c lient->renderer()) {537 if (auto* renderer = context.client->renderer()) { 527 538 if (from.image()->imageSize(renderer, 1.0) != to.image()->imageSize(renderer, 1.0)) 528 539 return to; 529 540 } 530 541 531 return NinePieceImage(blendFunc( client, from.image(), to.image(), progress),542 return NinePieceImage(blendFunc(from.image(), to.image(), context), 532 543 from.imageSlices(), from.fill(), from.borderSlices(), from.outset(), from.horizontalRule(), from.verticalRule()); 533 544 } … … 535 546 #if ENABLE(VARIATION_FONTS) 536 547 537 static inline FontVariationSettings blendFunc(const CSSPropertyBlendingClient* client, const FontVariationSettings& from, const FontVariationSettings& to, double progress)538 { 539 if (! progress)548 static inline FontVariationSettings blendFunc(const FontVariationSettings& from, const FontVariationSettings& to, const CSSPropertyBlendingContext& context) 549 { 550 if (!context.progress) 540 551 return from; 541 552 542 if ( progress == 1.0)553 if (context.progress == 1.0) 543 554 return to; 544 555 … … 550 561 auto& toItem = to.at(i); 551 562 ASSERT(fromItem.tag() == toItem.tag()); 552 float interpolated = blendFunc( client, fromItem.value(), toItem.value(), progress);563 float interpolated = blendFunc(fromItem.value(), toItem.value(), context); 553 564 result.insert({ fromItem.tag(), interpolated }); 554 565 } … … 558 569 #endif 559 570 560 static inline FontSelectionValue blendFunc( const CSSPropertyBlendingClient* client, FontSelectionValue from, FontSelectionValue to, double progress)561 { 562 return FontSelectionValue(std::max(0.0f, blendFunc( client, static_cast<float>(from), static_cast<float>(to), progress)));563 } 564 565 static inline Optional<FontSelectionValue> blendFunc( const CSSPropertyBlendingClient* client, Optional<FontSelectionValue> from, Optional<FontSelectionValue> to, double progress)566 { 567 return blendFunc( client, *from, *to, progress);571 static inline FontSelectionValue blendFunc(FontSelectionValue from, FontSelectionValue to, const CSSPropertyBlendingContext& context) 572 { 573 return FontSelectionValue(std::max(0.0f, blendFunc(static_cast<float>(from), static_cast<float>(to), context))); 574 } 575 576 static inline Optional<FontSelectionValue> blendFunc(Optional<FontSelectionValue> from, Optional<FontSelectionValue> to, const CSSPropertyBlendingContext& context) 577 { 578 return blendFunc(*from, *to, context); 568 579 } 569 580 … … 579 590 580 591 virtual bool isShorthandWrapper() const { return false; } 581 virtual bool equals(const RenderStyle *, const RenderStyle*) const = 0;582 virtual bool canInterpolate(const RenderStyle *, const RenderStyle*) const { return true; }583 virtual void blend( const CSSPropertyBlendingClient*, RenderStyle*, const RenderStyle*, const RenderStyle*, double) const = 0;592 virtual bool equals(const RenderStyle&, const RenderStyle&) const = 0; 593 virtual bool canInterpolate(const RenderStyle&, const RenderStyle&) const { return true; } 594 virtual void blend(RenderStyle&, const RenderStyle&, const RenderStyle&, const CSSPropertyBlendingContext&) const = 0; 584 595 585 596 #if !LOG_DISABLED 586 virtual void logBlend(const RenderStyle *, const RenderStyle*, const RenderStyle*, double) const = 0;597 virtual void logBlend(const RenderStyle&, const RenderStyle&, const RenderStyle&, double) const = 0; 587 598 #endif 588 599 … … 605 616 } 606 617 607 T value(const RenderStyle *style) const608 { 609 return (style ->*m_getter)();610 } 611 612 private: 613 bool equals(const RenderStyle * a, const RenderStyle*b) const override614 { 615 if ( a ==b)618 T value(const RenderStyle& style) const 619 { 620 return (style.*m_getter)(); 621 } 622 623 private: 624 bool equals(const RenderStyle& a, const RenderStyle& b) const override 625 { 626 if (&a == &b) 616 627 return true; 617 if (!a || !b)618 return false;619 628 return value(a) == value(b); 620 629 } 621 630 622 631 #if !LOG_DISABLED 623 void logBlend(const RenderStyle * from, const RenderStyle* to, const RenderStyle* result, double progress) const final624 { 625 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value( result));632 void logBlend(const RenderStyle& from, const RenderStyle& to, const RenderStyle& destination, double progress) const final 633 { 634 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(destination)); 626 635 } 627 636 #endif … … 640 649 } 641 650 642 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const override643 { 644 (destination ->*m_setter)(blendFunc(client, this->value(from), this->value(to), progress));651 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const override 652 { 653 (destination.*m_setter)(blendFunc(this->value(from), this->value(to), context)); 645 654 } 646 655 … … 659 668 660 669 private: 661 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final662 { 663 auto blendedValue = blendFunc( client, this->value(from), this->value(to), progress);664 (destination ->*this->m_setter)(blendedValue > 1 ? blendedValue : 1);670 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 671 { 672 auto blendedValue = blendFunc(this->value(from), this->value(to), context); 673 (destination.*this->m_setter)(blendedValue > 1 ? blendedValue : 1); 665 674 } 666 675 }; … … 677 686 678 687 private: 679 bool canInterpolate(const RenderStyle *, const RenderStyle*) const final { return false; }680 681 void blend( const CSSPropertyBlendingClient*, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final682 { 683 ASSERT(! progress ||progress == 1.0);684 (destination ->*this->m_setter)(this->value(progress ? to : from));688 bool canInterpolate(const RenderStyle&, const RenderStyle&) const final { return false; } 689 690 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 691 { 692 ASSERT(!context.progress || context.progress == 1.0); 693 (destination.*this->m_setter)(this->value(context.progress ? to : from)); 685 694 } 686 695 … … 699 708 700 709 private: 701 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final702 { 703 (destination ->*this->m_setter)(blendFunc(client, this->value(from), this->value(to), progress));710 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 711 { 712 (destination.*this->m_setter)(blendFunc(this->value(from), this->value(to), context)); 704 713 } 705 714 … … 740 749 741 750 protected: 742 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const override751 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const override 743 752 { 744 753 return canInterpolateLengths(value(from), value(to), m_flags.contains(Flags::IsLengthPercentage)); 745 754 } 746 755 747 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const override756 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const override 748 757 { 749 758 auto valueRange = m_flags.contains(Flags::NegativeLengthsAreInvalid) ? ValueRangeNonNegative : ValueRangeAll; 750 (destination ->*m_setter)(blendFunc(client, value(from), value(to), progress, valueRange));759 (destination.*m_setter)(blendFunc(value(from), value(to), context, valueRange)); 751 760 } 752 761 … … 781 790 782 791 private: 783 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final784 { 785 (destination ->*m_setter)(blendFunc(client, value(from), value(to), progress));792 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 793 { 794 (destination.*m_setter)(blendFunc(value(from), value(to), context)); 786 795 } 787 796 … … 800 809 801 810 private: 802 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final811 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 803 812 { 804 813 return canInterpolateLengthVariants(this->value(from), this->value(to)); 805 814 } 806 815 807 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final808 { 809 (destination ->*m_setter)(blendFunc(client, this->value(from), this->value(to), progress));816 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 817 { 818 (destination.*m_setter)(blendFunc(this->value(from), this->value(to), context)); 810 819 } 811 820 … … 829 838 830 839 private: 831 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final832 { 833 if (m_flags.contains(Flags::UsesFillKeyword) && from ->borderImage().fill() != to->borderImage().fill())840 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 841 { 842 if (m_flags.contains(Flags::UsesFillKeyword) && from.borderImage().fill() != to.borderImage().fill()) 834 843 return false; 835 844 … … 843 852 } 844 853 845 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final854 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 846 855 { 847 856 if (m_flags.contains(Flags::UsesFillKeyword)) 848 destination ->setBorderImageSliceFill((!progress || canInterpolate(from, to) ? from : to)->borderImage().fill());849 if ( !canInterpolate(from, to)) {857 destination.setBorderImageSliceFill((!context.progress || !context.isDiscrete ? from : to).borderImage().fill()); 858 if (context.isDiscrete) { 850 859 // It is important we have this non-interpolated shortcut because certain CSS properties 851 860 // represented as a LengthBox, such as border-image-slice, don't know how to deal with 852 861 // calculated Length values, see for instance valueForImageSliceSide(const Length&). 853 (destination ->*m_setter)(progress ? LengthBox(value(to)) : LengthBox(value(from)));862 (destination.*m_setter)(context.progress ? LengthBox(value(to)) : LengthBox(value(from))); 854 863 return; 855 864 } 856 865 auto valueRange = m_flags.contains(Flags::AllowsNegativeValues) ? ValueRangeAll : ValueRangeNonNegative; 857 (destination ->*m_setter)(blendFunc(client, value(from), value(to), progress, valueRange));866 (destination.*m_setter)(blendFunc(value(from), value(to), context, valueRange)); 858 867 } 859 868 … … 871 880 872 881 private: 873 bool equals(const RenderStyle * a, const RenderStyle*b) const final882 bool equals(const RenderStyle& a, const RenderStyle& b) const final 874 883 { 875 884 // If the style pointers are the same, don't bother doing the test. 876 // If either is null, return false. If both are null, return true. 877 if (a == b) 885 if (&a == &b) 878 886 return true; 879 if (!a || !b)880 return false;881 887 882 888 auto* clipPathA = value(a); … … 900 906 901 907 private: 902 bool equals(const RenderStyle * a, const RenderStyle*b) const final908 bool equals(const RenderStyle& a, const RenderStyle& b) const final 903 909 { 904 910 // If the style pointers are the same, don't bother doing the test. 905 // If either is null, return false. If both are null, return true. 906 if (a == b) 911 if (&a == &b) 907 912 return true; 908 if (!a || !b)909 return false;910 913 return value(a) == value(b); 911 914 } 912 915 913 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final916 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 914 917 { 915 918 auto fromVariationSettings = value(from); … … 939 942 940 943 private: 941 bool equals(const RenderStyle * a, const RenderStyle*b) const final944 bool equals(const RenderStyle& a, const RenderStyle& b) const final 942 945 { 943 946 // If the style pointers are the same, don't bother doing the test. 944 // If either is null, return false. If both are null, return true. 945 if (a == b) 947 if (&a == &b) 946 948 return true; 947 if (!a || !b)948 return false;949 949 950 950 auto* shapeA = value(a); … … 957 957 } 958 958 959 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final959 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 960 960 { 961 961 auto* fromShape = value(from); … … 984 984 985 985 private: 986 bool equals(const RenderStyle * a, const RenderStyle*b) const final987 { 988 if ( a ==b)986 bool equals(const RenderStyle& a, const RenderStyle& b) const final 987 { 988 if (&a == &b) 989 989 return true; 990 if (!a || !b)991 return false;992 990 993 991 auto* imageA = value(a); … … 996 994 } 997 995 998 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final996 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 999 997 { 1000 998 return value(from) && value(to); … … 1027 1025 bool animationIsAccelerated() const final { return true; } 1028 1026 1029 bool equals(const RenderStyle * a, const RenderStyle*b) const final1027 bool equals(const RenderStyle& a, const RenderStyle& b) const final 1030 1028 { 1031 1029 return arePointingToEqualData(this->value(a), this->value(b)); … … 1051 1049 } 1052 1050 1053 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final1054 { 1055 (destination ->*m_setter)(blendFunc(client, value(from), value(to), progress, property()));1051 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 1052 { 1053 (destination.*m_setter)(blendFunc(value(from), value(to), context, property())); 1056 1054 } 1057 1055 }; … … 1092 1090 1093 1091 private: 1094 bool equals(const RenderStyle * a, const RenderStyle*b) const final1095 { 1096 if ( a ==b)1092 bool equals(const RenderStyle& a, const RenderStyle& b) const final 1093 { 1094 if (&a == &b) 1097 1095 return true; 1098 if (!a || !b) 1099 return false; 1100 1101 const ShadowData* shadowA = (a->*m_getter)(); 1102 const ShadowData* shadowB = (b->*m_getter)(); 1096 1097 const ShadowData* shadowA = (a.*m_getter)(); 1098 const ShadowData* shadowB = (b.*m_getter)(); 1103 1099 1104 1100 while (true) { … … 1121 1117 } 1122 1118 1123 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final1124 { 1125 const ShadowData* fromShadow = (from ->*m_getter)();1126 const ShadowData* toShadow = (to ->*m_getter)();1119 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 1120 { 1121 const ShadowData* fromShadow = (from.*m_getter)(); 1122 const ShadowData* toShadow = (to.*m_getter)(); 1127 1123 1128 1124 // The only scenario where we can't interpolate is if specified items don't have the same shadow style. … … 1137 1133 } 1138 1134 1139 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final1140 { 1141 const ShadowData* fromShadow = (from ->*m_getter)();1142 const ShadowData* toShadow = (to ->*m_getter)();1143 1144 if ( !canInterpolate(from, to)) {1145 ASSERT(! progress ||progress == 1.0);1146 auto* shadow = progress ? toShadow : fromShadow;1147 (destination ->*m_setter)(shadow ? makeUnique<ShadowData>(*shadow) : nullptr, false);1135 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 1136 { 1137 const ShadowData* fromShadow = (from.*m_getter)(); 1138 const ShadowData* toShadow = (to.*m_getter)(); 1139 1140 if (context.isDiscrete) { 1141 ASSERT(!context.progress || context.progress == 1.0); 1142 auto* shadow = context.progress ? toShadow : fromShadow; 1143 (destination.*m_setter)(shadow ? makeUnique<ShadowData>(*shadow) : nullptr, false); 1148 1144 return; 1149 1145 } … … 1153 1149 1154 1150 if (fromLength == toLength || (fromLength <= 1 && toLength <= 1)) { 1155 (destination ->*m_setter)(blendSimpleOrMatchedShadowLists(client, progress, fromShadow, toShadow), false);1151 (destination.*m_setter)(blendSimpleOrMatchedShadowLists(fromShadow, toShadow, context), false); 1156 1152 return; 1157 1153 } 1158 1154 1159 (destination ->*m_setter)(blendMismatchedShadowLists(client, progress, fromShadow, toShadow, fromLength, toLength), false);1155 (destination.*m_setter)(blendMismatchedShadowLists(fromShadow, toShadow, fromLength, toLength, context), false); 1160 1156 } 1161 1157 1162 1158 #if !LOG_DISABLED 1163 void logBlend(const RenderStyle *, const RenderStyle*, const RenderStyle*, double progress) const final1159 void logBlend(const RenderStyle&, const RenderStyle&, const RenderStyle&, double progress) const final 1164 1160 { 1165 1161 // FIXME: better logging. … … 1168 1164 #endif 1169 1165 1170 std::unique_ptr<ShadowData> blendSimpleOrMatchedShadowLists(const CSSPropertyBlendingClient* client, double progress, const ShadowData* shadowA, const ShadowData* shadowB) const1166 std::unique_ptr<ShadowData> blendSimpleOrMatchedShadowLists(const ShadowData* shadowA, const ShadowData* shadowB, const CSSPropertyBlendingContext& context) const 1171 1167 { 1172 1168 std::unique_ptr<ShadowData> newShadowData; … … 1177 1173 const ShadowData* dstShadow = shadowForBlending(shadowB, shadowA); 1178 1174 1179 std::unique_ptr<ShadowData> blendedShadow = blendFunc( client, srcShadow, dstShadow, progress);1175 std::unique_ptr<ShadowData> blendedShadow = blendFunc(srcShadow, dstShadow, context); 1180 1176 ShadowData* blendedShadowPtr = blendedShadow.get(); 1181 1177 … … 1194 1190 } 1195 1191 1196 std::unique_ptr<ShadowData> blendMismatchedShadowLists(const CSSPropertyBlendingClient* client, double progress, const ShadowData* shadowA, const ShadowData* shadowB, int fromLength, int toLength) const1192 std::unique_ptr<ShadowData> blendMismatchedShadowLists(const ShadowData* shadowA, const ShadowData* shadowB, int fromLength, int toLength, const CSSPropertyBlendingContext& context) const 1197 1193 { 1198 1194 // The shadows in ShadowData are stored in reverse order, so when animating mismatched lists, … … 1220 1216 const ShadowData* dstShadow = shadowForBlending(toShadow, fromShadow); 1221 1217 1222 std::unique_ptr<ShadowData> blendedShadow = blendFunc( client, srcShadow, dstShadow, progress);1218 std::unique_ptr<ShadowData> blendedShadow = blendFunc(srcShadow, dstShadow, context); 1223 1219 // Insert at the start of the list to preserve the order. 1224 1220 blendedShadow->setNext(WTFMove(newShadowData)); … … 1244 1240 1245 1241 private: 1246 bool equals(const RenderStyle * a, const RenderStyle*b) const final1247 { 1248 if ( a ==b)1242 bool equals(const RenderStyle& a, const RenderStyle& b) const final 1243 { 1244 if (&a == &b) 1249 1245 return true; 1250 if (!a || !b)1251 return false;1252 1246 1253 1247 Color fromColor = value(a); … … 1258 1252 1259 1253 if (!fromColor.isValid()) 1260 fromColor = a ->color();1254 fromColor = a.color(); 1261 1255 if (!toColor.isValid()) 1262 toColor = b ->color();1256 toColor = b.color(); 1263 1257 1264 1258 return fromColor == toColor; 1265 1259 } 1266 1260 1267 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final1261 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 1268 1262 { 1269 1263 Color fromColor = value(from); … … 1274 1268 1275 1269 if (!fromColor.isValid()) 1276 fromColor = from ->color();1270 fromColor = from.color(); 1277 1271 if (!toColor.isValid()) 1278 toColor = to ->color();1279 (destination ->*m_setter)(blendFunc(client, fromColor, toColor, progress));1280 } 1281 1282 Color value(const RenderStyle *style) const1283 { 1284 return (style ->*m_getter)();1272 toColor = to.color(); 1273 (destination.*m_setter)(blendFunc(fromColor, toColor, context)); 1274 } 1275 1276 Color value(const RenderStyle& style) const 1277 { 1278 return (style.*m_getter)(); 1285 1279 } 1286 1280 1287 1281 #if !LOG_DISABLED 1288 void logBlend(const RenderStyle * from, const RenderStyle* to, const RenderStyle* result, double progress) const final1282 void logBlend(const RenderStyle& from, const RenderStyle& to, const RenderStyle& destination, double progress) const final 1289 1283 { 1290 1284 // FIXME: better logging. 1291 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value( result));1285 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(destination)); 1292 1286 } 1293 1287 #endif … … 1316 1310 1317 1311 protected: 1318 bool equals(const RenderStyle * a, const RenderStyle*b) const override1312 bool equals(const RenderStyle& a, const RenderStyle& b) const override 1319 1313 { 1320 1314 return m_wrapper->equals(a, b) && m_visitedWrapper->equals(a, b); 1321 1315 } 1322 1316 1323 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const override1324 { 1325 m_wrapper->blend( client, destination, from, to, progress);1326 m_visitedWrapper->blend( client, destination, from, to, progress);1317 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const override 1318 { 1319 m_wrapper->blend(destination, from, to, context); 1320 m_visitedWrapper->blend(destination, from, to, context); 1327 1321 } 1328 1322 … … 1332 1326 private: 1333 1327 #if !LOG_DISABLED 1334 void logBlend(const RenderStyle * from, const RenderStyle* to, const RenderStyle* result, double progress) const final1335 { 1336 m_wrapper->logBlend(from, to, result, progress);1337 m_visitedWrapper->logBlend(from, to, result, progress);1328 void logBlend(const RenderStyle& from, const RenderStyle& to, const RenderStyle& destination, double progress) const final 1329 { 1330 m_wrapper->logBlend(from, to, destination, progress); 1331 m_visitedWrapper->logBlend(from, to, destination, progress); 1338 1332 } 1339 1333 #endif 1340 1334 }; 1341 1335 1342 static bool canInterpolateCaretColor(const RenderStyle * from, const RenderStyle*to, bool visited)1336 static bool canInterpolateCaretColor(const RenderStyle& from, const RenderStyle& to, bool visited) 1343 1337 { 1344 1338 if (visited) 1345 return !from ->hasVisitedLinkAutoCaretColor() && !to->hasVisitedLinkAutoCaretColor();1346 return !from ->hasAutoCaretColor() && !to->hasAutoCaretColor();1339 return !from.hasVisitedLinkAutoCaretColor() && !to.hasVisitedLinkAutoCaretColor(); 1340 return !from.hasAutoCaretColor() && !to.hasAutoCaretColor(); 1347 1341 } 1348 1342 … … 1356 1350 1357 1351 private: 1358 bool equals(const RenderStyle * a, const RenderStyle*b) const final1359 { 1360 return a ->hasAutoCaretColor() == b->hasAutoCaretColor()1361 && a ->hasVisitedLinkAutoCaretColor() == b->hasVisitedLinkAutoCaretColor()1352 bool equals(const RenderStyle& a, const RenderStyle& b) const final 1353 { 1354 return a.hasAutoCaretColor() == b.hasAutoCaretColor() 1355 && a.hasVisitedLinkAutoCaretColor() == b.hasVisitedLinkAutoCaretColor() 1362 1356 && PropertyWrapperVisitedAffectedColor::equals(a, b); 1363 1357 } 1364 1358 1365 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final1359 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 1366 1360 { 1367 1361 return canInterpolateCaretColor(from, to, false) || canInterpolateCaretColor(from, to, true); 1368 1362 } 1369 1363 1370 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final1364 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 1371 1365 { 1372 1366 if (canInterpolateCaretColor(from, to, false)) 1373 m_wrapper->blend( client, destination, from, to, progress);1367 m_wrapper->blend(destination, from, to, context); 1374 1368 else { 1375 auto * blendingRenderStyle =progress < 0.5 ? from : to;1376 if (blendingRenderStyle ->hasAutoCaretColor())1377 destination ->setHasAutoCaretColor();1369 auto& blendingRenderStyle = context.progress < 0.5 ? from : to; 1370 if (blendingRenderStyle.hasAutoCaretColor()) 1371 destination.setHasAutoCaretColor(); 1378 1372 else 1379 destination ->setCaretColor(blendingRenderStyle->caretColor());1373 destination.setCaretColor(blendingRenderStyle.caretColor()); 1380 1374 } 1381 1375 1382 1376 if (canInterpolateCaretColor(from, to, true)) 1383 m_visitedWrapper->blend( client, destination, from, to, progress);1377 m_visitedWrapper->blend(destination, from, to, context); 1384 1378 else { 1385 auto * blendingRenderStyle =progress < 0.5 ? from : to;1386 if (blendingRenderStyle ->hasVisitedLinkAutoCaretColor())1387 destination ->setHasVisitedLinkAutoCaretColor();1379 auto& blendingRenderStyle = context.progress < 0.5 ? from : to; 1380 if (blendingRenderStyle.hasVisitedLinkAutoCaretColor()) 1381 destination.setHasVisitedLinkAutoCaretColor(); 1388 1382 else 1389 destination ->setVisitedLinkCaretColor(blendingRenderStyle->visitedLinkCaretColor());1383 destination.setVisitedLinkCaretColor(blendingRenderStyle.visitedLinkCaretColor()); 1390 1384 } 1391 1385 } … … 1405 1399 1406 1400 virtual bool equals(const FillLayer*, const FillLayer*) const = 0; 1407 virtual void blend( const CSSPropertyBlendingClient*, FillLayer*, const FillLayer*, const FillLayer*, double) const = 0;1401 virtual void blend(FillLayer*, const FillLayer*, const FillLayer*, const CSSPropertyBlendingContext&) const = 0; 1408 1402 virtual bool canInterpolate(const FillLayer*, const FillLayer*) const { return true; } 1409 1403 1410 1404 #if !LOG_DISABLED 1411 virtual void logBlend(const FillLayer* result, const FillLayer*, const FillLayer*, double) const = 0;1405 virtual void logBlend(const FillLayer* destination, const FillLayer*, const FillLayer*, double) const = 0; 1412 1406 #endif 1413 1407 … … 1443 1437 1444 1438 #if !LOG_DISABLED 1445 void logBlend(const FillLayer* result, const FillLayer* from, const FillLayer* to, double progress) const override1446 { 1447 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value( result));1439 void logBlend(const FillLayer* destination, const FillLayer* from, const FillLayer* to, double progress) const override 1440 { 1441 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(destination)); 1448 1442 } 1449 1443 #endif … … 1464 1458 1465 1459 private: 1466 void blend( const CSSPropertyBlendingClient* client, FillLayer* destination, const FillLayer* from, const FillLayer* to, double progress) const final1467 { 1468 (destination->*this->m_setter)(blendFunc( client, this->value(from), this->value(to), progress));1460 void blend(FillLayer* destination, const FillLayer* from, const FillLayer* to, const CSSPropertyBlendingContext& context) const final 1461 { 1462 (destination->*this->m_setter)(blendFunc(this->value(from), this->value(to), context)); 1469 1463 } 1470 1464 … … 1475 1469 1476 1470 #if !LOG_DISABLED 1477 void logBlend(const FillLayer* result, const FillLayer* from, const FillLayer* to, double progress) const final1471 void logBlend(const FillLayer* destination, const FillLayer* from, const FillLayer* to, double progress) const final 1478 1472 { 1479 1473 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(FillLayerPropertyWrapperGetter<const T&>::property()) 1480 1474 << " from " << FillLayerPropertyWrapperGetter<const T&>::value(from) 1481 1475 << " to " << FillLayerPropertyWrapperGetter<const T&>::value(to) 1482 << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << FillLayerPropertyWrapperGetter<const T&>::value( result));1476 << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << FillLayerPropertyWrapperGetter<const T&>::value(destination)); 1483 1477 } 1484 1478 #endif … … 1516 1510 } 1517 1511 1518 void blend( const CSSPropertyBlendingClient* client, FillLayer* destination, const FillLayer* from, const FillLayer* to, double progress) const final1512 void blend(FillLayer* destination, const FillLayer* from, const FillLayer* to, const CSSPropertyBlendingContext& context) const final 1519 1513 { 1520 1514 auto fromLength = value(from); … … 1534 1528 } 1535 1529 1536 (destination->*m_lengthSetter)(blendFunc( client, fromLength, toLength, progress));1530 (destination->*m_lengthSetter)(blendFunc(fromLength, toLength, context)); 1537 1531 } 1538 1532 1539 1533 #if !LOG_DISABLED 1540 void logBlend(const FillLayer* result, const FillLayer* from, const FillLayer* to, double progress) const final1541 { 1542 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value( result));1534 void logBlend(const FillLayer* destination, const FillLayer* from, const FillLayer* to, double progress) const final 1535 { 1536 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(destination)); 1543 1537 } 1544 1538 #endif … … 1561 1555 1562 1556 private: 1563 void blend( const CSSPropertyBlendingClient* client, FillLayer* destination, const FillLayer* from, const FillLayer* to, double progress) const final1564 { 1565 (destination->*this->m_setter)(blendFunc( client, this->value(from), this->value(to), progress));1557 void blend(FillLayer* destination, const FillLayer* from, const FillLayer* to, const CSSPropertyBlendingContext& context) const final 1558 { 1559 (destination->*this->m_setter)(blendFunc(this->value(from), this->value(to), context)); 1566 1560 } 1567 1561 1568 1562 #if !LOG_DISABLED 1569 void logBlend(const FillLayer* result, const FillLayer* from, const FillLayer* to, double progress) const override1563 void logBlend(const FillLayer* destination, const FillLayer* from, const FillLayer* to, double progress) const override 1570 1564 { 1571 1565 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(FillLayerPropertyWrapperGetter<T*>::property()) 1572 1566 << " from " << FillLayerPropertyWrapperGetter<T*>::value(from) 1573 1567 << " to " << FillLayerPropertyWrapperGetter<T*>::value(to) 1574 << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << FillLayerPropertyWrapperGetter<T*>::value( result));1568 << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << FillLayerPropertyWrapperGetter<T*>::value(destination)); 1575 1569 } 1576 1570 #endif … … 1603 1597 1604 1598 #if !LOG_DISABLED 1605 void logBlend(const FillLayer* result, const FillLayer* from, const FillLayer* to, double progress) const final1606 { 1607 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName( property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(result));1599 void logBlend(const FillLayer* destination, const FillLayer* from, const FillLayer* to, double progress) const final 1600 { 1601 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(this->property()) << " from " << this->value(from) << " to " << this->value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(destination)); 1608 1602 } 1609 1603 #endif … … 1644 1638 1645 1639 private: 1646 bool equals(const RenderStyle * a, const RenderStyle*b) const final1647 { 1648 if ( a ==b)1640 bool equals(const RenderStyle& a, const RenderStyle& b) const final 1641 { 1642 if (&a == &b) 1649 1643 return true; 1650 if (!a || !b) 1651 return false; 1652 1653 auto* fromLayer = &(a->*m_layersGetter)(); 1654 auto* toLayer = &(b->*m_layersGetter)(); 1644 1645 auto* fromLayer = &(a.*m_layersGetter)(); 1646 auto* toLayer = &(b.*m_layersGetter)(); 1655 1647 1656 1648 while (fromLayer && toLayer) { … … 1665 1657 } 1666 1658 1667 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final1668 { 1669 auto* fromLayer = &(from ->*m_layersGetter)();1670 auto* toLayer = &(to ->*m_layersGetter)();1659 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 1660 { 1661 auto* fromLayer = &(from.*m_layersGetter)(); 1662 auto* toLayer = &(to.*m_layersGetter)(); 1671 1663 1672 1664 while (fromLayer && toLayer) { … … 1684 1676 } 1685 1677 1686 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final1687 { 1688 auto* fromLayer = &(from ->*m_layersGetter)();1689 auto* toLayer = &(to ->*m_layersGetter)();1690 auto* dstLayer = &(destination ->*m_layersAccessor)();1678 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 1679 { 1680 auto* fromLayer = &(from.*m_layersGetter)(); 1681 auto* toLayer = &(to.*m_layersGetter)(); 1682 auto* dstLayer = &(destination.*m_layersAccessor)(); 1691 1683 1692 1684 while (fromLayer && toLayer && dstLayer) { 1693 dstLayer->setSizeType(( progress ? toLayer : fromLayer)->sizeType());1694 m_fillLayerPropertyWrapper->blend( client, dstLayer, fromLayer, toLayer, progress);1685 dstLayer->setSizeType((context.progress ? toLayer : fromLayer)->sizeType()); 1686 m_fillLayerPropertyWrapper->blend(dstLayer, fromLayer, toLayer, context); 1695 1687 fromLayer = fromLayer->next(); 1696 1688 toLayer = toLayer->next(); … … 1700 1692 1701 1693 #if !LOG_DISABLED 1702 void logBlend(const RenderStyle * from, const RenderStyle* to, const RenderStyle* result, double progress) const final1703 { 1704 auto* fromLayer = &(from ->*m_layersGetter)();1705 auto* toLayer = &(to ->*m_layersGetter)();1706 auto* dstLayer = &( result->*m_layersGetter)();1694 void logBlend(const RenderStyle& from, const RenderStyle& to, const RenderStyle& destination, double progress) const final 1695 { 1696 auto* fromLayer = &(from.*m_layersGetter)(); 1697 auto* toLayer = &(to.*m_layersGetter)(); 1698 auto* dstLayer = &(destination.*m_layersGetter)(); 1707 1699 1708 1700 while (fromLayer && toLayer && dstLayer) { … … 1734 1726 1735 1727 private: 1736 bool equals(const RenderStyle * a, const RenderStyle*b) const final1737 { 1738 if ( a ==b)1728 bool equals(const RenderStyle& a, const RenderStyle& b) const final 1729 { 1730 if (&a == &b) 1739 1731 return true; 1740 if (!a || !b)1741 return false;1742 1732 1743 1733 for (auto& wrapper : m_propertyWrappers) { … … 1748 1738 } 1749 1739 1750 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final1740 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 1751 1741 { 1752 1742 for (auto& wrapper : m_propertyWrappers) 1753 wrapper->blend( client, destination, from, to, progress);1743 wrapper->blend(destination, from, to, context); 1754 1744 } 1755 1745 1756 1746 #if !LOG_DISABLED 1757 void logBlend(const RenderStyle * from, const RenderStyle* to, const RenderStyle*destination, double progress) const final1747 void logBlend(const RenderStyle& from, const RenderStyle& to, const RenderStyle& destination, double progress) const final 1758 1748 { 1759 1749 for (auto& wrapper : m_propertyWrappers) … … 1774 1764 1775 1765 private: 1776 bool equals(const RenderStyle * a, const RenderStyle*b) const final1777 { 1778 if ( a ==b)1766 bool equals(const RenderStyle& a, const RenderStyle& b) const final 1767 { 1768 if (&a == &b) 1779 1769 return true; 1780 if (!a || !b) 1781 return false; 1782 1783 return a->flexBasis() == b->flexBasis() && a->flexGrow() == b->flexGrow() && a->flexShrink() == b->flexShrink(); 1784 } 1785 1786 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const final 1787 { 1788 return from->flexGrow() != to->flexGrow() && from->flexShrink() != to->flexShrink() && canInterpolateLengths(from->flexBasis(), to->flexBasis(), false); 1789 } 1790 1791 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 1792 { 1793 destination->setFlexBasis(blendFunc(client, from->flexBasis(), to->flexBasis(), progress)); 1794 destination->setFlexGrow(blendFunc(client, from->flexGrow(), to->flexGrow(), progress)); 1795 destination->setFlexShrink(blendFunc(client, from->flexShrink(), to->flexShrink(), progress)); 1770 1771 return a.flexBasis() == b.flexBasis() && a.flexGrow() == b.flexGrow() && a.flexShrink() == b.flexShrink(); 1772 } 1773 1774 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 1775 { 1776 return from.flexGrow() != to.flexGrow() && from.flexShrink() != to.flexShrink() && canInterpolateLengths(from.flexBasis(), to.flexBasis(), false); 1777 } 1778 1779 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 1780 { 1781 destination.setFlexBasis(blendFunc(from.flexBasis(), to.flexBasis(), context)); 1782 destination.setFlexGrow(blendFunc(from.flexGrow(), to.flexGrow(), context)); 1783 destination.setFlexShrink(blendFunc(from.flexShrink(), to.flexShrink(), context)); 1796 1784 } 1797 1785 1798 1786 #if !LOG_DISABLED 1799 void logBlend(const RenderStyle *, const RenderStyle*, const RenderStyle*, double progress) const final1787 void logBlend(const RenderStyle&, const RenderStyle&, const RenderStyle&, double progress) const final 1800 1788 { 1801 1789 // FIXME: better logging. … … 1817 1805 1818 1806 private: 1819 bool equals(const RenderStyle * a, const RenderStyle*b) const final1820 { 1821 if ( a ==b)1807 bool equals(const RenderStyle& a, const RenderStyle& b) const final 1808 { 1809 if (&a == &b) 1822 1810 return true; 1823 if (!a || !b) 1824 return false; 1825 1826 if ((a->*m_paintTypeGetter)() != (b->*m_paintTypeGetter)()) 1811 1812 if ((a.*m_paintTypeGetter)() != (b.*m_paintTypeGetter)()) 1827 1813 return false; 1828 1814 … … 1830 1816 // For everything else we must return true for this method, otherwise 1831 1817 // we will try to animate between values forever. 1832 if ((a ->*m_paintTypeGetter)() == SVGPaintType::RGBColor) {1833 Color fromColor = (a ->*m_getter)();1834 Color toColor = (b ->*m_getter)();1818 if ((a.*m_paintTypeGetter)() == SVGPaintType::RGBColor) { 1819 Color fromColor = (a.*m_getter)(); 1820 Color toColor = (b.*m_getter)(); 1835 1821 1836 1822 if (!fromColor.isValid() && !toColor.isValid()) … … 1847 1833 } 1848 1834 1849 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final1850 { 1851 if ((from ->*m_paintTypeGetter)() != SVGPaintType::RGBColor1852 || (to ->*m_paintTypeGetter)() != SVGPaintType::RGBColor)1835 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 1836 { 1837 if ((from.*m_paintTypeGetter)() != SVGPaintType::RGBColor 1838 || (to.*m_paintTypeGetter)() != SVGPaintType::RGBColor) 1853 1839 return; 1854 1840 1855 Color fromColor = (from ->*m_getter)();1856 Color toColor = (to ->*m_getter)();1841 Color fromColor = (from.*m_getter)(); 1842 Color toColor = (to.*m_getter)(); 1857 1843 1858 1844 if (!fromColor.isValid() && !toColor.isValid()) … … 1863 1849 if (!toColor.isValid()) 1864 1850 toColor = Color(); 1865 (destination ->*m_setter)(blendFunc(client, fromColor, toColor, progress));1851 (destination.*m_setter)(blendFunc(fromColor, toColor, context)); 1866 1852 } 1867 1853 1868 1854 #if !LOG_DISABLED 1869 void logBlend(const RenderStyle *, const RenderStyle*, const RenderStyle*, double progress) const final1855 void logBlend(const RenderStyle&, const RenderStyle&, const RenderStyle&, double progress) const final 1870 1856 { 1871 1857 // FIXME: better logging. … … 1888 1874 1889 1875 private: 1890 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const final 1891 { 1892 return from->fontItalic() && to->fontItalic() && from->fontDescription().fontStyleAxis() == FontStyleAxis::slnt && to->fontDescription().fontStyleAxis() == FontStyleAxis::slnt; 1893 } 1894 1895 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 1896 { 1897 auto discrete = !canInterpolate(from, to); 1898 1876 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 1877 { 1878 return from.fontItalic() && to.fontItalic() && from.fontDescription().fontStyleAxis() == FontStyleAxis::slnt && to.fontDescription().fontStyleAxis() == FontStyleAxis::slnt; 1879 } 1880 1881 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 1882 { 1899 1883 auto blendedStyleAxis = FontStyleAxis::slnt; 1900 if ( discrete)1901 blendedStyleAxis = ( progress < 0.5 ? from : to)->fontDescription().fontStyleAxis();1902 1903 auto fromFontItalic = from ->fontItalic();1904 auto toFontItalic = to ->fontItalic();1905 auto blendedFontItalic = progress < 0.5 ? fromFontItalic : toFontItalic;1906 if (! discrete)1907 blendedFontItalic = blendFunc( client, fromFontItalic, toFontItalic, progress);1908 1909 FontSelector* currentFontSelector = destination->fontCascade().fontSelector();1910 auto description = destination ->fontDescription();1884 if (context.isDiscrete) 1885 blendedStyleAxis = (context.progress < 0.5 ? from : to).fontDescription().fontStyleAxis(); 1886 1887 auto fromFontItalic = from.fontItalic(); 1888 auto toFontItalic = to.fontItalic(); 1889 auto blendedFontItalic = context.progress < 0.5 ? fromFontItalic : toFontItalic; 1890 if (!context.isDiscrete) 1891 blendedFontItalic = blendFunc(fromFontItalic, toFontItalic, context); 1892 1893 auto* currentFontSelector = destination.fontCascade().fontSelector(); 1894 auto description = destination.fontDescription(); 1911 1895 description.setItalic(blendedFontItalic); 1912 1896 description.setFontStyleAxis(blendedStyleAxis); 1913 destination ->setFontDescription(WTFMove(description));1914 destination ->fontCascade().update(currentFontSelector);1897 destination.setFontDescription(WTFMove(description)); 1898 destination.fontCascade().update(currentFontSelector); 1915 1899 } 1916 1900 }; … … 1929 1913 1930 1914 private: 1931 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final1932 { 1933 return !(from ->*m_autoGetter)() && !(to->*m_autoGetter)();1934 } 1935 1936 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final1937 { 1938 auto blendedValue = blendFunc( client, this->value(from), this->value(to), progress);1915 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 1916 { 1917 return !(from.*m_autoGetter)() && !(to.*m_autoGetter)(); 1918 } 1919 1920 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 1921 { 1922 auto blendedValue = blendFunc(this->value(from), this->value(to), context); 1939 1923 if (m_minValue) 1940 1924 blendedValue = blendedValue > *m_minValue ? blendedValue : *m_minValue; 1941 (destination ->*this->m_setter)(blendedValue);1942 1943 if ( canInterpolate(from, to))1925 (destination.*this->m_setter)(blendedValue); 1926 1927 if (!context.isDiscrete) 1944 1928 return; 1945 1929 1946 ASSERT(! progress ||progress == 1.0);1947 if (! progress) {1948 if ((from ->*m_autoGetter)())1949 (destination ->*m_autoSetter)();1930 ASSERT(!context.progress || context.progress == 1.0); 1931 if (!context.progress) { 1932 if ((from.*m_autoGetter)()) 1933 (destination.*m_autoSetter)(); 1950 1934 } else { 1951 if ((to ->*m_autoGetter)())1952 (destination ->*m_autoSetter)();1935 if ((to.*m_autoGetter)()) 1936 (destination.*m_autoSetter)(); 1953 1937 } 1954 1938 } … … 1968 1952 1969 1953 protected: 1970 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const override1971 { 1972 auto blendedValue = blendFunc( client, value(from), value(to), progress);1973 (destination ->*m_setter)(blendedValue > 0 ? blendedValue : 0);1954 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const override 1955 { 1956 auto blendedValue = blendFunc(value(from), value(to), context); 1957 (destination.*m_setter)(blendedValue > 0 ? blendedValue : 0); 1974 1958 } 1975 1959 }; … … 1984 1968 1985 1969 private: 1986 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final1987 { 1988 return from ->verticalAlign() == VerticalAlign::Length && to->verticalAlign() == VerticalAlign::Length && LengthPropertyWrapper::canInterpolate(from, to);1989 } 1990 1991 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final1992 { 1993 LengthPropertyWrapper::blend( client, destination, from, to, progress);1994 auto * blendingStyle = !canInterpolate(from, to) &&progress ? to : from;1995 destination ->setVerticalAlign(blendingStyle->verticalAlign());1970 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 1971 { 1972 return from.verticalAlign() == VerticalAlign::Length && to.verticalAlign() == VerticalAlign::Length && LengthPropertyWrapper::canInterpolate(from, to); 1973 } 1974 1975 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 1976 { 1977 LengthPropertyWrapper::blend(destination, from, to, context); 1978 auto& blendingStyle = context.isDiscrete && context.progress ? to : from; 1979 destination.setVerticalAlign(blendingStyle.verticalAlign()); 1996 1980 } 1997 1981 }; … … 2006 1990 2007 1991 private: 2008 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final2009 { 2010 if (from ->textIndentLine() != to->textIndentLine())1992 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 1993 { 1994 if (from.textIndentLine() != to.textIndentLine()) 2011 1995 return false; 2012 if (from ->textIndentType() != to->textIndentType())1996 if (from.textIndentType() != to.textIndentType()) 2013 1997 return false; 2014 1998 return LengthPropertyWrapper::canInterpolate(from, to); 2015 1999 } 2016 2000 2017 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final2018 { 2019 auto * blendingStyle = !canInterpolate(from, to) &&progress ? to : from;2020 destination ->setTextIndentLine(blendingStyle->textIndentLine());2021 destination ->setTextIndentType(blendingStyle->textIndentType());2022 LengthPropertyWrapper::blend( client, destination, from, to, progress);2001 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 2002 { 2003 auto& blendingStyle = context.isDiscrete && context.progress ? to : from; 2004 destination.setTextIndentLine(blendingStyle.textIndentLine()); 2005 destination.setTextIndentType(blendingStyle.textIndentType()); 2006 LengthPropertyWrapper::blend(destination, from, to, context); 2023 2007 } 2024 2008 }; … … 2033 2017 2034 2018 private: 2035 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final2036 { 2037 if (!from ->hasPerspective() || !to->hasPerspective())2019 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 2020 { 2021 if (!from.hasPerspective() || !to.hasPerspective()) 2038 2022 return false; 2039 2023 return NonNegativeFloatPropertyWrapper::canInterpolate(from, to); 2040 2024 } 2041 2025 2042 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final2043 { 2044 if ( !canInterpolate(from, to))2045 (destination ->*m_setter)(progress ? value(to) : value(from));2026 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 2027 { 2028 if (context.isDiscrete) 2029 (destination.*m_setter)(context.progress ? value(to) : value(from)); 2046 2030 else 2047 NonNegativeFloatPropertyWrapper::blend( client, destination, from, to, progress);2031 NonNegativeFloatPropertyWrapper::blend(destination, from, to, context); 2048 2032 } 2049 2033 }; … … 2058 2042 2059 2043 private: 2060 bool canInterpolate(const RenderStyle * from, const RenderStyle*to) const final2044 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 2061 2045 { 2062 2046 return value(from).isSpaces() == value(to).isSpaces(); 2063 2047 } 2064 2048 2065 void blend( const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final2066 { 2067 if ( !canInterpolate(from, to))2068 (destination ->*m_setter)(progress ? value(to) : value(from));2049 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 2050 { 2051 if (context.isDiscrete) 2052 (destination.*m_setter)(context.progress ? value(to) : value(from)); 2069 2053 else 2070 PropertyWrapper::blend( client, destination, from, to, progress);2054 PropertyWrapper::blend(destination, from, to, context); 2071 2055 } 2072 2056 }; … … 2080 2064 } 2081 2065 2082 bool equals(const RenderStyle * a, const RenderStyle*b) const final2083 { 2084 if ( a ==b)2066 bool equals(const RenderStyle& a, const RenderStyle& b) const final 2067 { 2068 if (&a == &b) 2085 2069 return true; 2086 if (!a || !b) 2087 return false; 2088 2089 return a->aspectRatioType() == b->aspectRatioType() && a->aspectRatioWidth() == b->aspectRatioWidth() && a->aspectRatioHeight() == b->aspectRatioHeight(); 2090 } 2091 2092 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const final 2093 { 2094 return (from->aspectRatioType() == AspectRatioType::Ratio && to->aspectRatioType() == AspectRatioType::Ratio) || (from->aspectRatioType() == AspectRatioType::AutoAndRatio && to->aspectRatioType() == AspectRatioType::AutoAndRatio); 2070 2071 return a.aspectRatioType() == b.aspectRatioType() && a.aspectRatioWidth() == b.aspectRatioWidth() && a.aspectRatioHeight() == b.aspectRatioHeight(); 2072 } 2073 2074 bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final 2075 { 2076 return (from.aspectRatioType() == AspectRatioType::Ratio && to.aspectRatioType() == AspectRatioType::Ratio) || (from.aspectRatioType() == AspectRatioType::AutoAndRatio && to.aspectRatioType() == AspectRatioType::AutoAndRatio); 2095 2077 } 2096 2078 2097 2079 #if !LOG_DISABLED 2098 void logBlend(const RenderStyle * from, const RenderStyle* to, const RenderStyle* result, double progress) const final2099 { 2100 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << from ->logicalAspectRatio() << " to " << to->logicalAspectRatio() << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << result->logicalAspectRatio());2080 void logBlend(const RenderStyle& from, const RenderStyle& to, const RenderStyle& destination, double progress) const final 2081 { 2082 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << from.logicalAspectRatio() << " to " << to.logicalAspectRatio() << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << destination.logicalAspectRatio()); 2101 2083 } 2102 2084 #endif 2103 2085 2104 void blend( const CSSPropertyBlendingClient*, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final2105 { 2106 destination ->setAspectRatioType(progress < 0.5 ? from->aspectRatioType() : to->aspectRatioType());2107 if ( canInterpolate(from, to)) {2108 auto aspectRatioDst = WebCore::blend(log(from ->logicalAspectRatio()), log(to->logicalAspectRatio()), progress);2109 destination ->setAspectRatio(exp(aspectRatioDst), 1);2086 void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final 2087 { 2088 destination.setAspectRatioType(context.progress < 0.5 ? from.aspectRatioType() : to.aspectRatioType()); 2089 if (!context.isDiscrete) { 2090 auto aspectRatioDst = WebCore::blend(log(from.logicalAspectRatio()), log(to.logicalAspectRatio()), context); 2091 destination.setAspectRatio(exp(aspectRatioDst), 1); 2110 2092 return; 2111 2093 } 2112 2094 // For auto/auto-zero aspect-ratio we use discrete values, we can't use general 2113 2095 // logic since logicalAspectRatio asserts on aspect-ratio type. 2114 ASSERT(! progress ||progress == 1);2115 auto * applicableStyle =progress ? to : from;2116 destination ->setAspectRatio(applicableStyle->aspectRatioWidth(), applicableStyle->aspectRatioHeight());2096 ASSERT(!context.progress || context.progress == 1); 2097 auto& applicableStyle = context.progress ? to : from; 2098 destination.setAspectRatio(applicableStyle.aspectRatioWidth(), applicableStyle.aspectRatioHeight()); 2117 2099 } 2118 2100 }; … … 2514 2496 } 2515 2497 2516 void CSSPropertyAnimation::blendProperties(const CSSPropertyBlendingClient* client, CSSPropertyID property, RenderStyle * destination, const RenderStyle* from, const RenderStyle*to, double progress)2498 void CSSPropertyAnimation::blendProperties(const CSSPropertyBlendingClient* client, CSSPropertyID property, RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, double progress) 2517 2499 { 2518 2500 ASSERT(property != CSSPropertyInvalid); … … 2521 2503 if (wrapper) { 2522 2504 // https://drafts.csswg.org/web-animations-1/#discrete 2523 // The property ’s values cannot be meaningfully combined, thus it is not additive and2505 // The property's values cannot be meaningfully combined, thus it is not additive and 2524 2506 // interpolation swaps from Va to Vb at 50% (p=0.5). 2525 if (!wrapper->canInterpolate(from, to)) 2507 auto isDiscrete = !wrapper->canInterpolate(from, to); 2508 if (isDiscrete) 2526 2509 progress = progress < 0.5 ? 0 : 1; 2527 wrapper->blend( client, destination, from, to, progress);2510 wrapper->blend(destination, from, to, { progress, isDiscrete, client }); 2528 2511 #if !LOG_DISABLED 2529 2512 wrapper->logBlend(from, to, destination, progress); … … 2555 2538 } 2556 2539 2557 bool CSSPropertyAnimation::propertiesEqual(CSSPropertyID property, const RenderStyle * a, const RenderStyle*b)2540 bool CSSPropertyAnimation::propertiesEqual(CSSPropertyID property, const RenderStyle& a, const RenderStyle& b) 2558 2541 { 2559 2542 AnimationPropertyWrapperBase* wrapper = CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(property); … … 2563 2546 } 2564 2547 2565 bool CSSPropertyAnimation::canPropertyBeInterpolated(CSSPropertyID property, const RenderStyle * from, const RenderStyle*to)2548 bool CSSPropertyAnimation::canPropertyBeInterpolated(CSSPropertyID property, const RenderStyle& from, const RenderStyle& to) 2566 2549 { 2567 2550 AnimationPropertyWrapperBase* wrapper = CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(property); -
trunk/Source/WebCore/animation/CSSPropertyAnimation.h
r267188 r276141 41 41 static bool isPropertyAnimatable(CSSPropertyID); 42 42 static bool animationOfPropertyIsAccelerated(CSSPropertyID); 43 static bool propertiesEqual(CSSPropertyID, const RenderStyle * a, const RenderStyle*b);44 static bool canPropertyBeInterpolated(CSSPropertyID, const RenderStyle * a, const RenderStyle*b);43 static bool propertiesEqual(CSSPropertyID, const RenderStyle& a, const RenderStyle& b); 44 static bool canPropertyBeInterpolated(CSSPropertyID, const RenderStyle& a, const RenderStyle& b); 45 45 static CSSPropertyID getPropertyAtIndex(int, Optional<bool>& isShorthand); 46 46 static int getNumProperties(); … … 48 48 static HashSet<CSSPropertyID> animatableShorthandsAffectingProperty(CSSPropertyID); 49 49 50 // Return true if we need to start software animation timers 51 static void blendProperties(const CSSPropertyBlendingClient*, CSSPropertyID, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress); 50 static void blendProperties(const CSSPropertyBlendingClient*, CSSPropertyID, RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, double progress); 52 51 }; 53 52 -
trunk/Source/WebCore/animation/KeyframeEffect.cpp
r274165 r276141 1419 1419 if (m_blendingKeyframesSource == BlendingKeyframesSource::CSSTransition) { 1420 1420 ASSERT(properties.size() == 1); 1421 CSSPropertyAnimation::blendProperties(this, *properties.begin(), &targetStyle, m_blendingKeyframes[0].style(),m_blendingKeyframes[1].style(), iterationProgress);1421 CSSPropertyAnimation::blendProperties(this, *properties.begin(), targetStyle, *m_blendingKeyframes[0].style(), *m_blendingKeyframes[1].style(), iterationProgress); 1422 1422 return; 1423 1423 } … … 1533 1533 auto keyframeIndex = intervalEndpoints[0]; 1534 1534 auto keyframeStyle = !keyframeIndex ? &targetStyle : m_blendingKeyframes[keyframeIndex.value()].style(); 1535 CSSPropertyAnimation::blendProperties(this, cssPropertyId, &targetStyle, keyframeStyle,keyframeStyle, 0);1535 CSSPropertyAnimation::blendProperties(this, cssPropertyId, targetStyle, *keyframeStyle, *keyframeStyle, 0); 1536 1536 continue; 1537 1537 } … … 1564 1564 auto startStyle = !startKeyframeIndex ? &targetStyle : m_blendingKeyframes[startKeyframeIndex.value()].style(); 1565 1565 auto endStyle = !endKeyframeIndex ? &targetStyle : m_blendingKeyframes[endKeyframeIndex.value()].style(); 1566 CSSPropertyAnimation::blendProperties(this, cssPropertyId, &targetStyle, startStyle,endStyle, transformedDistance);1566 CSSPropertyAnimation::blendProperties(this, cssPropertyId, targetStyle, *startStyle, *endStyle, transformedDistance); 1567 1567 } 1568 1568 } -
trunk/Source/WebCore/css/CSSCrossfadeValue.cpp
r252392 r276141 39 39 namespace WebCore { 40 40 41 static inline double blendFunc(double from, double to, double progress)42 { 43 return blend(from, to, progress);41 static inline double blendFunc(double from, double to, const BlendingContext& context) 42 { 43 return blend(from, to, context); 44 44 } 45 45 … … 203 203 } 204 204 205 RefPtr<CSSCrossfadeValue> CSSCrossfadeValue::blend(const CSSCrossfadeValue& from, double progress) const205 RefPtr<CSSCrossfadeValue> CSSCrossfadeValue::blend(const CSSCrossfadeValue& from, const BlendingContext& context) const 206 206 { 207 207 ASSERT(equalInputImages(from)); … … 219 219 if (m_percentageValue->isPercentage()) 220 220 toPercentage /= 100.0; 221 auto percentageValue = CSSPrimitiveValue::create(blendFunc(fromPercentage, toPercentage, progress), CSSUnitType::CSS_NUMBER);221 auto percentageValue = CSSPrimitiveValue::create(blendFunc(fromPercentage, toPercentage, context), CSSUnitType::CSS_NUMBER); 222 222 223 223 return CSSCrossfadeValue::create(WTFMove(fromImageValue), WTFMove(toImageValue), WTFMove(percentageValue), from.isPrefixed() && isPrefixed()); -
trunk/Source/WebCore/css/CSSCrossfadeValue.h
r218501 r276141 33 33 namespace WebCore { 34 34 35 struct BlendingContext; 35 36 class CSSPrimitiveValue; 36 37 … … 55 56 bool traverseSubresources(const WTF::Function<bool (const CachedResource&)>& handler) const; 56 57 57 RefPtr<CSSCrossfadeValue> blend(const CSSCrossfadeValue&, double) const;58 RefPtr<CSSCrossfadeValue> blend(const CSSCrossfadeValue&, const BlendingContext&) const; 58 59 59 60 bool equals(const CSSCrossfadeValue&) const; -
trunk/Source/WebCore/css/CSSGradientValue.cpp
r276002 r276141 27 27 #include "CSSGradientValue.h" 28 28 29 #include "AnimationUtilities.h" 29 30 #include "CSSCalculationValue.h" 30 31 #include "CSSToLengthConversionData.h" … … 206 207 float interStopProportion = -prevOffset / (nextOffset - prevOffset); 207 208 // FIXME: when we interpolate gradients using premultiplied colors, this should do premultiplication. 208 Color blendedColor = blend(stops[firstZeroOrGreaterIndex - 1].color, stops[firstZeroOrGreaterIndex].color, interStopProportion);209 Color blendedColor = blend(stops[firstZeroOrGreaterIndex - 1].color, stops[firstZeroOrGreaterIndex].color, { interStopProportion }); 209 210 210 211 // Clamp the positions to 0 and set the color. … … 257 258 float interStopProportion = -previousOffset / (nextOffset - previousOffset); 258 259 // FIXME: when we interpolate gradients using premultiplied colors, this should do premultiplication. 259 Color blendedColor = blend(stops[index - 1].color, stops[index].color, interStopProportion);260 Color blendedColor = blend(stops[index - 1].color, stops[index].color, { interStopProportion }); 260 261 261 262 // Clamp the positions to 0 and set the color. … … 287 288 float interStopProportion = (1 - previousOffset) / (nextOffset - previousOffset); 288 289 // FIXME: when we interpolate gradients using premultiplied colors, this should do premultiplication. 289 Color blendedColor = blend(stops[index].color, stops[index + 1].color, interStopProportion);290 Color blendedColor = blend(stops[index].color, stops[index + 1].color, { interStopProportion }); 290 291 291 292 // Clamp the positions to 1 and set the color. … … 486 487 float multiplier = std::pow(relativeOffset, std::log(.5f) / std::log(midpoint)); 487 488 // FIXME: Why not premultiply here? 488 newStops[y].color = blendWithoutPremultiply(color1, color2, multiplier);489 newStops[y].color = blendWithoutPremultiply(color1, color2, { multiplier }); 489 490 } 490 491 -
trunk/Source/WebCore/platform/Length.cpp
r276138 r276141 26 26 #include "Length.h" 27 27 28 #include "AnimationUtilities.h" 28 29 #include "CalculationValue.h" 29 30 #include <wtf/ASCIICType.h> … … 295 296 } 296 297 297 static Length blendMixedTypes(const Length& from, const Length& to, double progress)298 { 299 if (!to.isCalculated() && !from.isPercent() && ( progress == 1 || from.isZero()))300 return blend(Length(0, to.type()), to, progress);301 302 if (!from.isCalculated() && !to.isPercent() && (! progress || to.isZero()))303 return blend(from, Length(0, from.type()), progress);304 305 auto blend = makeUnique<CalcExpressionBlendLength>(from, to, progress);298 static Length blendMixedTypes(const Length& from, const Length& to, const BlendingContext& context) 299 { 300 if (!to.isCalculated() && !from.isPercent() && (context.progress == 1 || from.isZero())) 301 return blend(Length(0, to.type()), to, context); 302 303 if (!from.isCalculated() && !to.isPercent() && (!context.progress || to.isZero())) 304 return blend(from, Length(0, from.type()), context); 305 306 auto blend = makeUnique<CalcExpressionBlendLength>(from, to, context.progress); 306 307 return Length(CalculationValue::create(WTFMove(blend), ValueRangeAll)); 307 308 } 308 309 309 Length blend(const Length& from, const Length& to, double progress)310 Length blend(const Length& from, const Length& to, const BlendingContext& context) 310 311 { 311 312 if ((from.isAuto() || to.isAuto()) || (from.isUndefined() || to.isUndefined())) 312 return progress < 0.5 ? from : to;313 return context.progress < 0.5 ? from : to; 313 314 314 315 if (from.isCalculated() || to.isCalculated() || (from.type() != to.type())) 315 return blendMixedTypes(from, to, progress);316 317 if (! progress)316 return blendMixedTypes(from, to, context); 317 318 if (!context.progress) 318 319 return from; 319 320 320 if ( progress == 1)321 if (context.progress == 1) 321 322 return to; 322 323 … … 328 329 float fromPercent = from.isZero() ? 0 : from.percent(); 329 330 float toPercent = to.isZero() ? 0 : to.percent(); 330 return Length(WebCore::blend(fromPercent, toPercent, progress), LengthType::Percent);331 return Length(WebCore::blend(fromPercent, toPercent, context), LengthType::Percent); 331 332 } 332 333 333 334 float fromValue = from.isZero() ? 0 : from.value(); 334 335 float toValue = to.isZero() ? 0 : to.value(); 335 return Length(WebCore::blend(fromValue, toValue, progress), resultType);336 } 337 338 Length blend(const Length& from, const Length& to, double progress, ValueRange valueRange)339 { 340 auto blended = blend(from, to, progress);336 return Length(WebCore::blend(fromValue, toValue, context), resultType); 337 } 338 339 Length blend(const Length& from, const Length& to, const BlendingContext& context, ValueRange valueRange) 340 { 341 auto blended = blend(from, to, context); 341 342 if (valueRange == ValueRangeNonNegative && blended.isNegative()) 342 343 return { 0, from.isZero () ? to.type() : from.type() }; -
trunk/Source/WebCore/platform/Length.h
r273635 r276141 50 50 }; 51 51 52 struct BlendingContext; 52 53 class CalculationValue; 53 54 … … 138 139 139 140 // Blend two lengths to produce a new length that is in between them. Used for animation. 140 Length blend(const Length& from, const Length& to, double progress);141 Length blend(const Length& from, const Length& to, double progress, ValueRange);141 Length blend(const Length& from, const Length& to, const BlendingContext&); 142 Length blend(const Length& from, const Length& to, const BlendingContext&, ValueRange); 142 143 143 144 UniqueArray<Length> newCoordsArray(const String&, int& length); -
trunk/Source/WebCore/platform/LengthPoint.h
r261585 r276141 29 29 30 30 namespace WebCore { 31 32 struct BlendingContext; 31 33 32 34 struct LengthPoint { … … 64 66 }; 65 67 66 inline LengthPoint blend(const LengthPoint& from, const LengthPoint& to, double progress)68 inline LengthPoint blend(const LengthPoint& from, const LengthPoint& to, const BlendingContext& context) 67 69 { 68 return LengthPoint(blend(from.x(), to.x(), progress), blend(from.y(), to.y(), progress));70 return LengthPoint(blend(from.x(), to.x(), context), blend(from.y(), to.y(), context)); 69 71 } 70 72 -
trunk/Source/WebCore/platform/LengthSize.h
r251207 r276141 24 24 namespace WebCore { 25 25 26 struct BlendingContext; 27 26 28 struct LengthSize { 27 29 Length width; … … 37 39 } 38 40 39 inline LengthSize blend(const LengthSize& from, const LengthSize& to, double progress)41 inline LengthSize blend(const LengthSize& from, const LengthSize& to, const BlendingContext& context) 40 42 { 41 return { blend(from.width, to.width, progress), blend(from.height, to.height, progress) };43 return { blend(from.width, to.width, context), blend(from.height, to.height, context) }; 42 44 } 43 45 -
trunk/Source/WebCore/platform/animation/AnimationUtilities.h
r275272 r276141 31 31 namespace WebCore { 32 32 33 inline int blend(int from, int to, double progress) 33 struct BlendingContext { 34 double progress { 0 }; 35 bool isDiscrete { false }; 36 }; 37 38 inline int blend(int from, int to, const BlendingContext& context) 34 39 { 35 return static_cast<int>(lround(static_cast<double>(from) + static_cast<double>(to - from) * progress));40 return static_cast<int>(lround(static_cast<double>(from) + static_cast<double>(to - from) * context.progress)); 36 41 } 37 42 38 inline unsigned blend(unsigned from, unsigned to, double progress)43 inline unsigned blend(unsigned from, unsigned to, const BlendingContext& context) 39 44 { 40 return static_cast<unsigned>(lround(to > from ? static_cast<double>(from) + static_cast<double>(to - from) * progress : static_cast<double>(from) - static_cast<double>(from - to) *progress));45 return static_cast<unsigned>(lround(to > from ? static_cast<double>(from) + static_cast<double>(to - from) * context.progress : static_cast<double>(from) - static_cast<double>(from - to) * context.progress)); 41 46 } 42 47 43 inline double blend(double from, double to, double progress)48 inline double blend(double from, double to, const BlendingContext& context) 44 49 { 45 return from + (to - from) * progress;50 return from + (to - from) * context.progress; 46 51 } 47 52 48 inline float blend(float from, float to, double progress)53 inline float blend(float from, float to, const BlendingContext& context) 49 54 { 50 return static_cast<float>(from + (to - from) * progress);55 return static_cast<float>(from + (to - from) * context.progress); 51 56 } 52 57 53 inline LayoutUnit blend(LayoutUnit from, LayoutUnit to, double progress)58 inline LayoutUnit blend(LayoutUnit from, LayoutUnit to, const BlendingContext& context) 54 59 { 55 return LayoutUnit(blend(from.toFloat(), to.toFloat(), progress));60 return LayoutUnit(blend(from.toFloat(), to.toFloat(), context)); 56 61 } 57 62 58 inline IntPoint blend(const IntPoint& from, const IntPoint& to, double progress)63 inline IntPoint blend(const IntPoint& from, const IntPoint& to, const BlendingContext& context) 59 64 { 60 return IntPoint(blend(from.x(), to.x(), progress),61 blend(from.y(), to.y(), progress));65 return IntPoint(blend(from.x(), to.x(), context), 66 blend(from.y(), to.y(), context)); 62 67 } 63 68 64 inline LayoutPoint blend(const LayoutPoint& from, const LayoutPoint& to, double progress)69 inline LayoutPoint blend(const LayoutPoint& from, const LayoutPoint& to, const BlendingContext& context) 65 70 { 66 return LayoutPoint(blend(from.x(), to.x(), progress),67 blend(from.y(), to.y(), progress));71 return LayoutPoint(blend(from.x(), to.x(), context), 72 blend(from.y(), to.y(), context)); 68 73 } 69 74 -
trunk/Source/WebCore/platform/graphics/ColorBlending.cpp
r274408 r276141 91 91 } 92 92 93 Color blend(const Color& from, const Color& to, double progress)93 Color blend(const Color& from, const Color& to, const BlendingContext& context) 94 94 { 95 95 // FIXME: ExtendedColor - needs to handle color spaces. 96 96 // We need to preserve the state of the valid flag at the end of the animation 97 if ( progress == 1 && !to.isValid())97 if (context.progress == 1 && !to.isValid()) 98 98 return { }; 99 99 … … 102 102 103 103 auto premultipliedBlended = makeFromComponentsClamping<SRGBA<float>>( 104 WebCore::blend(premultipliedFrom.red, premultipliedTo.red, progress),105 WebCore::blend(premultipliedFrom.green, premultipliedTo.green, progress),106 WebCore::blend(premultipliedFrom.blue, premultipliedTo.blue, progress),107 WebCore::blend(premultipliedFrom.alpha, premultipliedTo.alpha, progress)104 WebCore::blend(premultipliedFrom.red, premultipliedTo.red, context), 105 WebCore::blend(premultipliedFrom.green, premultipliedTo.green, context), 106 WebCore::blend(premultipliedFrom.blue, premultipliedTo.blue, context), 107 WebCore::blend(premultipliedFrom.alpha, premultipliedTo.alpha, context) 108 108 ); 109 109 … … 111 111 } 112 112 113 Color blendWithoutPremultiply(const Color& from, const Color& to, double progress)113 Color blendWithoutPremultiply(const Color& from, const Color& to, const BlendingContext& context) 114 114 { 115 115 // FIXME: ExtendedColor - needs to handle color spaces. 116 116 // We need to preserve the state of the valid flag at the end of the animation 117 if ( progress == 1 && !to.isValid())117 if (context.progress == 1 && !to.isValid()) 118 118 return { }; 119 119 … … 122 122 123 123 auto blended = makeFromComponentsClamping<SRGBA<float>>( 124 WebCore::blend(fromSRGB.red, toSRGB.red, progress),125 WebCore::blend(fromSRGB.green, toSRGB.green, progress),126 WebCore::blend(fromSRGB.blue, toSRGB.blue, progress),127 WebCore::blend(fromSRGB.alpha, toSRGB.alpha, progress)124 WebCore::blend(fromSRGB.red, toSRGB.red, context), 125 WebCore::blend(fromSRGB.green, toSRGB.green, context), 126 WebCore::blend(fromSRGB.blue, toSRGB.blue, context), 127 WebCore::blend(fromSRGB.alpha, toSRGB.alpha, context) 128 128 ); 129 129 -
trunk/Source/WebCore/platform/graphics/ColorBlending.h
r263776 r276141 28 28 namespace WebCore { 29 29 30 struct BlendingContext; 30 31 class Color; 31 32 … … 38 39 Color blendWithWhite(const Color&); 39 40 40 Color blend(const Color& from, const Color& to, double progress);41 Color blendWithoutPremultiply(const Color& from, const Color& to, double progress);41 Color blend(const Color& from, const Color& to, const BlendingContext&); 42 Color blendWithoutPremultiply(const Color& from, const Color& to, const BlendingContext&); 42 43 43 44 } -
trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm
r272760 r276141 464 464 double t = filterOperation ? downcast<BasicColorMatrixFilterOperation>(*filterOperation).amount() : 0; 465 465 t = std::min(std::max(0.0, t), 1.0); 466 BlendingContext context { t }; 466 467 CAColorMatrix colorMatrix = { 467 static_cast<float>(WebCore::blend(sepiaNoneConstants[0][0], sepiaFullConstants[0][0], t)),468 static_cast<float>(WebCore::blend(sepiaNoneConstants[0][1], sepiaFullConstants[0][1], t)),469 static_cast<float>(WebCore::blend(sepiaNoneConstants[0][2], sepiaFullConstants[0][2], t)), 0, 0,468 static_cast<float>(WebCore::blend(sepiaNoneConstants[0][0], sepiaFullConstants[0][0], context)), 469 static_cast<float>(WebCore::blend(sepiaNoneConstants[0][1], sepiaFullConstants[0][1], context)), 470 static_cast<float>(WebCore::blend(sepiaNoneConstants[0][2], sepiaFullConstants[0][2], context)), 0, 0, 470 471 471 static_cast<float>(WebCore::blend(sepiaNoneConstants[1][0], sepiaFullConstants[1][0], t)),472 static_cast<float>(WebCore::blend(sepiaNoneConstants[1][1], sepiaFullConstants[1][1], t)),473 static_cast<float>(WebCore::blend(sepiaNoneConstants[1][2], sepiaFullConstants[1][2], t)), 0, 0,472 static_cast<float>(WebCore::blend(sepiaNoneConstants[1][0], sepiaFullConstants[1][0], context)), 473 static_cast<float>(WebCore::blend(sepiaNoneConstants[1][1], sepiaFullConstants[1][1], context)), 474 static_cast<float>(WebCore::blend(sepiaNoneConstants[1][2], sepiaFullConstants[1][2], context)), 0, 0, 474 475 475 static_cast<float>(WebCore::blend(sepiaNoneConstants[2][0], sepiaFullConstants[2][0], t)),476 static_cast<float>(WebCore::blend(sepiaNoneConstants[2][1], sepiaFullConstants[2][1], t)),477 static_cast<float>(WebCore::blend(sepiaNoneConstants[2][2], sepiaFullConstants[2][2], t)), 0, 0,476 static_cast<float>(WebCore::blend(sepiaNoneConstants[2][0], sepiaFullConstants[2][0], context)), 477 static_cast<float>(WebCore::blend(sepiaNoneConstants[2][1], sepiaFullConstants[2][1], context)), 478 static_cast<float>(WebCore::blend(sepiaNoneConstants[2][2], sepiaFullConstants[2][2], context)), 0, 0, 478 479 0, 0, 0, 1, 0 479 480 }; -
trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp
r275206 r276141 75 75 } 76 76 77 RefPtr<FilterOperation> BasicColorMatrixFilterOperation::blend(const FilterOperation* from, double progress, bool blendToPassthrough)77 RefPtr<FilterOperation> BasicColorMatrixFilterOperation::blend(const FilterOperation* from, const BlendingContext& context, bool blendToPassthrough) 78 78 { 79 79 if (from && !from->isSameType(*this)) … … 81 81 82 82 if (blendToPassthrough) 83 return BasicColorMatrixFilterOperation::create(WebCore::blend(m_amount, passthroughAmount(), progress), m_type);83 return BasicColorMatrixFilterOperation::create(WebCore::blend(m_amount, passthroughAmount(), context), m_type); 84 84 85 85 const BasicColorMatrixFilterOperation* fromOperation = downcast<BasicColorMatrixFilterOperation>(from); 86 86 double fromAmount = fromOperation ? fromOperation->amount() : passthroughAmount(); 87 return BasicColorMatrixFilterOperation::create(WebCore::blend(fromAmount, m_amount, progress), m_type);87 return BasicColorMatrixFilterOperation::create(WebCore::blend(fromAmount, m_amount, context), m_type); 88 88 } 89 89 … … 138 138 } 139 139 140 RefPtr<FilterOperation> BasicComponentTransferFilterOperation::blend(const FilterOperation* from, double progress, bool blendToPassthrough)140 RefPtr<FilterOperation> BasicComponentTransferFilterOperation::blend(const FilterOperation* from, const BlendingContext& context, bool blendToPassthrough) 141 141 { 142 142 if (from && !from->isSameType(*this)) … … 144 144 145 145 if (blendToPassthrough) 146 return BasicComponentTransferFilterOperation::create(WebCore::blend(m_amount, passthroughAmount(), progress), m_type);146 return BasicComponentTransferFilterOperation::create(WebCore::blend(m_amount, passthroughAmount(), context), m_type); 147 147 148 148 const BasicComponentTransferFilterOperation* fromOperation = downcast<BasicComponentTransferFilterOperation>(from); 149 149 double fromAmount = fromOperation ? fromOperation->amount() : passthroughAmount(); 150 return BasicComponentTransferFilterOperation::create(WebCore::blend(fromAmount, m_amount, progress), m_type);150 return BasicComponentTransferFilterOperation::create(WebCore::blend(fromAmount, m_amount, context), m_type); 151 151 } 152 152 … … 216 216 } 217 217 218 RefPtr<FilterOperation> InvertLightnessFilterOperation::blend(const FilterOperation* from, double, bool)218 RefPtr<FilterOperation> InvertLightnessFilterOperation::blend(const FilterOperation* from, const BlendingContext&, bool) 219 219 { 220 220 if (from && !from->isSameType(*this)) … … 332 332 } 333 333 334 RefPtr<FilterOperation> BlurFilterOperation::blend(const FilterOperation* from, double progress, bool blendToPassthrough)334 RefPtr<FilterOperation> BlurFilterOperation::blend(const FilterOperation* from, const BlendingContext& context, bool blendToPassthrough) 335 335 { 336 336 if (from && !from->isSameType(*this)) … … 340 340 341 341 if (blendToPassthrough) 342 return BlurFilterOperation::create(WebCore::blend(m_stdDeviation, Length(lengthType), progress));342 return BlurFilterOperation::create(WebCore::blend(m_stdDeviation, Length(lengthType), context)); 343 343 344 344 const BlurFilterOperation* fromOperation = downcast<BlurFilterOperation>(from); 345 345 Length fromLength = fromOperation ? fromOperation->m_stdDeviation : Length(lengthType); 346 return BlurFilterOperation::create(WebCore::blend(fromLength, m_stdDeviation, progress));346 return BlurFilterOperation::create(WebCore::blend(fromLength, m_stdDeviation, context)); 347 347 } 348 348 … … 355 355 } 356 356 357 RefPtr<FilterOperation> DropShadowFilterOperation::blend(const FilterOperation* from, double progress, bool blendToPassthrough)357 RefPtr<FilterOperation> DropShadowFilterOperation::blend(const FilterOperation* from, const BlendingContext& context, bool blendToPassthrough) 358 358 { 359 359 if (from && !from->isSameType(*this)) … … 362 362 if (blendToPassthrough) 363 363 return DropShadowFilterOperation::create( 364 WebCore::blend(m_location, IntPoint(), progress),365 WebCore::blend(m_stdDeviation, 0, progress),366 WebCore::blend(m_color, Color::transparentBlack, progress));364 WebCore::blend(m_location, IntPoint(), context), 365 WebCore::blend(m_stdDeviation, 0, context), 366 WebCore::blend(m_color, Color::transparentBlack, context)); 367 367 368 368 const DropShadowFilterOperation* fromOperation = downcast<DropShadowFilterOperation>(from); … … 372 372 373 373 return DropShadowFilterOperation::create( 374 WebCore::blend(fromLocation, m_location, progress),375 WebCore::blend(fromStdDeviation, m_stdDeviation, progress),376 WebCore::blend(fromColor, m_color, progress));374 WebCore::blend(fromLocation, m_location, context), 375 WebCore::blend(fromStdDeviation, m_stdDeviation, context), 376 WebCore::blend(fromColor, m_color, context)); 377 377 } 378 378 -
trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h
r272731 r276141 43 43 // CSS Filters 44 44 45 struct BlendingContext; 45 46 class CachedResourceLoader; 46 47 class CachedSVGDocumentReference; … … 75 76 bool operator!=(const FilterOperation& o) const { return !(*this == o); } 76 77 77 virtual RefPtr<FilterOperation> blend(const FilterOperation* /*from*/, double /*progress*/, bool /*blendToPassthrough*/ = false)78 virtual RefPtr<FilterOperation> blend(const FilterOperation* /*from*/, const BlendingContext&, bool /*blendToPassthrough*/ = false) 78 79 { 79 80 return nullptr; … … 216 217 double amount() const { return m_amount; } 217 218 218 RefPtr<FilterOperation> blend(const FilterOperation* from, double progress, bool blendToPassthrough = false) override;219 RefPtr<FilterOperation> blend(const FilterOperation* from, const BlendingContext&, bool blendToPassthrough = false) override; 219 220 220 221 private: … … 251 252 bool affectsOpacity() const override { return m_type == OPACITY; } 252 253 253 RefPtr<FilterOperation> blend(const FilterOperation* from, double progress, bool blendToPassthrough = false) override;254 RefPtr<FilterOperation> blend(const FilterOperation* from, const BlendingContext&, bool blendToPassthrough = false) override; 254 255 255 256 private: … … 281 282 } 282 283 283 RefPtr<FilterOperation> blend(const FilterOperation* from, double progress, bool blendToPassthrough = false) override;284 RefPtr<FilterOperation> blend(const FilterOperation* from, const BlendingContext&, bool blendToPassthrough = false) override; 284 285 285 286 private: … … 312 313 bool movesPixels() const override { return true; } 313 314 314 RefPtr<FilterOperation> blend(const FilterOperation* from, double progress, bool blendToPassthrough = false) override;315 RefPtr<FilterOperation> blend(const FilterOperation* from, const BlendingContext&, bool blendToPassthrough = false) override; 315 316 316 317 private: … … 347 348 bool movesPixels() const override { return true; } 348 349 349 RefPtr<FilterOperation> blend(const FilterOperation* from, double progress, bool blendToPassthrough = false) override;350 RefPtr<FilterOperation> blend(const FilterOperation* from, const BlendingContext&, bool blendToPassthrough = false) override; 350 351 351 352 private: -
trunk/Source/WebCore/platform/graphics/transforms/IdentityTransformOperation.h
r220503 r276141 30 30 namespace WebCore { 31 31 32 struct BlendingContext; 33 32 34 class IdentityTransformOperation final : public TransformOperation { 33 35 public: … … 55 57 } 56 58 57 Ref<TransformOperation> blend(const TransformOperation*, double, bool = false) override59 Ref<TransformOperation> blend(const TransformOperation*, const BlendingContext&, bool = false) override 58 60 { 59 61 return *this; -
trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.cpp
r234330 r276141 27 27 #include "Matrix3DTransformOperation.h" 28 28 29 #include "AnimationUtilities.h" 29 30 #include <algorithm> 30 31 #include <wtf/text/TextStream.h> … … 37 38 } 38 39 39 static Ref<TransformOperation> createOperation(TransformationMatrix& to, TransformationMatrix& from, double progress)40 static Ref<TransformOperation> createOperation(TransformationMatrix& to, TransformationMatrix& from, const BlendingContext& context) 40 41 { 41 to.blend(from, progress);42 to.blend(from, context.progress); 42 43 return Matrix3DTransformOperation::create(to); 43 44 } 44 45 45 Ref<TransformOperation> Matrix3DTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)46 Ref<TransformOperation> Matrix3DTransformOperation::blend(const TransformOperation* from, const BlendingContext& context, bool blendToIdentity) 46 47 { 47 48 if (from && !from->isSameType(*this)) … … 58 59 59 60 if (blendToIdentity) 60 return createOperation(fromT, toT, progress);61 return createOperation(toT, fromT, progress);61 return createOperation(fromT, toT, context); 62 return createOperation(toT, fromT, context); 62 63 } 63 64 -
trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h
r234330 r276141 31 31 namespace WebCore { 32 32 33 struct BlendingContext; 34 33 35 class Matrix3DTransformOperation final : public TransformOperation { 34 36 public: … … 59 61 } 60 62 61 Ref<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) override;63 Ref<TransformOperation> blend(const TransformOperation* from, const BlendingContext&, bool blendToIdentity = false) override; 62 64 63 65 void dump(WTF::TextStream&) const final; -
trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp
r223476 r276141 23 23 #include "MatrixTransformOperation.h" 24 24 25 #include "AnimationUtilities.h" 25 26 #include <algorithm> 26 27 #include <wtf/text/TextStream.h> … … 36 37 } 37 38 38 Ref<TransformOperation> MatrixTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)39 Ref<TransformOperation> MatrixTransformOperation::blend(const TransformOperation* from, const BlendingContext& context, bool blendToIdentity) 39 40 { 40 auto createOperation = [] (TransformationMatrix& to, TransformationMatrix& from, double progress) {41 to.blend(from, progress);41 auto createOperation = [] (TransformationMatrix& to, TransformationMatrix& from, const BlendingContext& context) { 42 to.blend(from, context.progress); 42 43 return MatrixTransformOperation::create(to); 43 44 }; … … 55 56 56 57 if (blendToIdentity) 57 return createOperation(fromT, toT, progress);58 return createOperation(toT, fromT, progress);58 return createOperation(fromT, toT, context); 59 return createOperation(toT, fromT, context); 59 60 } 60 61 -
trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h
r220503 r276141 30 30 31 31 namespace WebCore { 32 33 struct BlendingContext; 32 34 33 35 class MatrixTransformOperation final : public TransformOperation { … … 63 65 } 64 66 65 Ref<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) override;67 Ref<TransformOperation> blend(const TransformOperation* from, const BlendingContext&, bool blendToIdentity = false) override; 66 68 67 69 void dump(WTF::TextStream&) const final; -
trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp
r272805 r276141 40 40 } 41 41 42 Ref<TransformOperation> PerspectiveTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)42 Ref<TransformOperation> PerspectiveTransformOperation::blend(const TransformOperation* from, const BlendingContext& context, bool blendToIdentity) 43 43 { 44 44 if (from && !from->isSameType(*this)) … … 47 47 if (blendToIdentity) { 48 48 double p = floatValueForLength(m_p, 1); 49 p = WebCore::blend(p, 1.0, progress); // FIXME: this seems wrong. https://bugs.webkit.org/show_bug.cgi?id=5270049 p = WebCore::blend(p, 1.0, context); // FIXME: this seems wrong. https://bugs.webkit.org/show_bug.cgi?id=52700 50 50 return PerspectiveTransformOperation::create(Length(clampToPositiveInteger(p), LengthType::Fixed)); 51 51 } … … 59 59 fromT.applyPerspective(floatValueForLength(fromP, 1)); 60 60 toT.applyPerspective(floatValueForLength(toP, 1)); 61 toT.blend(fromT, progress);61 toT.blend(fromT, context.progress); 62 62 TransformationMatrix::Decomposed4Type decomp; 63 63 toT.decompose4(decomp); -
trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h
r234330 r276141 33 33 namespace WebCore { 34 34 35 struct BlendingContext; 36 35 37 class PerspectiveTransformOperation final : public TransformOperation { 36 38 public: … … 60 62 } 61 63 62 Ref<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) override;64 Ref<TransformOperation> blend(const TransformOperation* from, const BlendingContext&, bool blendToIdentity = false) override; 63 65 64 66 void dump(WTF::TextStream&) const final; -
trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp
r255559 r276141 38 38 } 39 39 40 Ref<TransformOperation> RotateTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)40 Ref<TransformOperation> RotateTransformOperation::blend(const TransformOperation* from, const BlendingContext& context, bool blendToIdentity) 41 41 { 42 42 if (from && !from->isSameType(*this)) … … 44 44 45 45 if (blendToIdentity) 46 return RotateTransformOperation::create(m_x, m_y, m_z, m_angle - m_angle * progress, type());46 return RotateTransformOperation::create(m_x, m_y, m_z, m_angle - m_angle * context.progress, type()); 47 47 48 48 const RotateTransformOperation* fromOp = downcast<RotateTransformOperation>(from); … … 56 56 fromOp ? fromOp->m_y : m_y, 57 57 fromOp ? fromOp->m_z : m_z, 58 WebCore::blend(fromAngle, m_angle, progress), type());58 WebCore::blend(fromAngle, m_angle, context), type()); 59 59 } 60 60 … … 75 75 76 76 // Blend them 77 toT.blend(fromT, progress);77 toT.blend(fromT, context.progress); 78 78 79 79 // Extract the result as a quaternion -
trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.h
r268547 r276141 30 30 namespace WebCore { 31 31 32 struct BlendingContext; 33 32 34 class RotateTransformOperation final : public TransformOperation { 33 35 public: … … 54 56 bool operator==(const TransformOperation&) const override; 55 57 56 Ref<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) final;58 Ref<TransformOperation> blend(const TransformOperation* from, const BlendingContext&, bool blendToIdentity = false) final; 57 59 58 60 bool isIdentity() const final { return !m_angle; } -
trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.cpp
r220503 r276141 36 36 } 37 37 38 Ref<TransformOperation> ScaleTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)38 Ref<TransformOperation> ScaleTransformOperation::blend(const TransformOperation* from, const BlendingContext& context, bool blendToIdentity) 39 39 { 40 40 if (from && !from->isSameType(*this)) … … 42 42 43 43 if (blendToIdentity) 44 return ScaleTransformOperation::create(WebCore::blend(m_x, 1.0, progress),45 WebCore::blend(m_y, 1.0, progress),46 WebCore::blend(m_z, 1.0, progress), type());44 return ScaleTransformOperation::create(WebCore::blend(m_x, 1.0, context), 45 WebCore::blend(m_y, 1.0, context), 46 WebCore::blend(m_z, 1.0, context), type()); 47 47 48 48 const ScaleTransformOperation* fromOp = downcast<ScaleTransformOperation>(from); … … 50 50 double fromY = fromOp ? fromOp->m_y : 1.0; 51 51 double fromZ = fromOp ? fromOp->m_z : 1.0; 52 return ScaleTransformOperation::create(WebCore::blend(fromX, m_x, progress),53 WebCore::blend(fromY, m_y, progress),54 WebCore::blend(fromZ, m_z, progress), type());52 return ScaleTransformOperation::create(WebCore::blend(fromX, m_x, context), 53 WebCore::blend(fromY, m_y, context), 54 WebCore::blend(fromZ, m_z, context), type()); 55 55 } 56 56 -
trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.h
r268547 r276141 30 30 namespace WebCore { 31 31 32 struct BlendingContext; 33 32 34 class ScaleTransformOperation final : public TransformOperation { 33 35 public: … … 53 55 bool operator==(const TransformOperation&) const final; 54 56 55 Ref<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) final;57 Ref<TransformOperation> blend(const TransformOperation* from, const BlendingContext&, bool blendToIdentity = false) final; 56 58 57 59 bool isIdentity() const final { return m_x == 1 && m_y == 1 && m_z == 1; } -
trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.cpp
r220503 r276141 36 36 } 37 37 38 Ref<TransformOperation> SkewTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)38 Ref<TransformOperation> SkewTransformOperation::blend(const TransformOperation* from, const BlendingContext& context, bool blendToIdentity) 39 39 { 40 40 if (from && !from->isSameType(*this)) … … 42 42 43 43 if (blendToIdentity) 44 return SkewTransformOperation::create(WebCore::blend(m_angleX, 0.0, progress), WebCore::blend(m_angleY, 0.0, progress), type());44 return SkewTransformOperation::create(WebCore::blend(m_angleX, 0.0, context), WebCore::blend(m_angleY, 0.0, context), type()); 45 45 46 46 const SkewTransformOperation* fromOp = downcast<SkewTransformOperation>(from); 47 47 double fromAngleX = fromOp ? fromOp->m_angleX : 0; 48 48 double fromAngleY = fromOp ? fromOp->m_angleY : 0; 49 return SkewTransformOperation::create(WebCore::blend(fromAngleX, m_angleX, progress), WebCore::blend(fromAngleY, m_angleY, progress), type());49 return SkewTransformOperation::create(WebCore::blend(fromAngleX, m_angleX, context), WebCore::blend(fromAngleY, m_angleY, context), type()); 50 50 } 51 51 -
trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.h
r220503 r276141 30 30 namespace WebCore { 31 31 32 struct BlendingContext; 33 32 34 class SkewTransformOperation final : public TransformOperation { 33 35 public: … … 57 59 } 58 60 59 Ref<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) override;61 Ref<TransformOperation> blend(const TransformOperation* from, const BlendingContext&, bool blendToIdentity = false) override; 60 62 61 63 void dump(WTF::TextStream&) const final; -
trunk/Source/WebCore/platform/graphics/transforms/TransformOperation.h
r234330 r276141 33 33 namespace WebCore { 34 34 35 // CSS Transforms (may become part of CSS3) 35 struct BlendingContext; 36 36 37 37 class TransformOperation : public RefCounted<TransformOperation> { … … 68 68 virtual bool apply(TransformationMatrix&, const FloatSize& borderBoxSize) const = 0; 69 69 70 virtual Ref<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) = 0;70 virtual Ref<TransformOperation> blend(const TransformOperation* from, const BlendingContext&, bool blendToIdentity = false) = 0; 71 71 72 72 OperationType type() const { return m_type; } -
trunk/Source/WebCore/platform/graphics/transforms/TransformOperations.cpp
r239535 r276141 23 23 #include "TransformOperations.h" 24 24 25 #include "AnimationUtilities.h" 25 26 #include "IdentityTransformOperation.h" 26 27 #include "Matrix3DTransformOperation.h" … … 74 75 } 75 76 76 TransformOperations TransformOperations::blendByMatchingOperations(const TransformOperations& from, const double& progress) const77 TransformOperations TransformOperations::blendByMatchingOperations(const TransformOperations& from, const BlendingContext& context) const 77 78 { 78 79 TransformOperations result; … … 84 85 RefPtr<TransformOperation> fromOperation = (i < fromSize) ? from.operations()[i].get() : nullptr; 85 86 RefPtr<TransformOperation> toOperation = (i < toSize) ? operations()[i].get() : nullptr; 86 RefPtr<TransformOperation> blendedOperation = toOperation ? toOperation->blend(fromOperation.get(), progress) : (fromOperation ? RefPtr<TransformOperation>(fromOperation->blend(nullptr, progress, true)) : nullptr);87 RefPtr<TransformOperation> blendedOperation = toOperation ? toOperation->blend(fromOperation.get(), context) : (fromOperation ? RefPtr<TransformOperation>(fromOperation->blend(nullptr, context, true)) : nullptr); 87 88 if (blendedOperation) 88 89 result.operations().append(blendedOperation); 89 90 else { 90 91 auto identityOperation = IdentityTransformOperation::create(); 91 if ( progress > 0.5)92 if (context.progress > 0.5) 92 93 result.operations().append(toOperation ? toOperation : WTFMove(identityOperation)); 93 94 else … … 99 100 } 100 101 101 TransformOperations TransformOperations::blendByUsingMatrixInterpolation(const TransformOperations& from, double progress, const LayoutSize& size) const102 TransformOperations TransformOperations::blendByUsingMatrixInterpolation(const TransformOperations& from, const BlendingContext& context, const LayoutSize& size) const 102 103 { 103 104 TransformOperations result; … … 109 110 apply(size, toTransform); 110 111 111 toTransform.blend(fromTransform, progress);112 toTransform.blend(fromTransform, context.progress); 112 113 113 114 // Append the result … … 117 118 } 118 119 119 TransformOperations TransformOperations::blend(const TransformOperations& from, double progress, const LayoutSize& size) const120 TransformOperations TransformOperations::blend(const TransformOperations& from, const BlendingContext& context, const LayoutSize& size) const 120 121 { 121 122 if (from == *this) … … 123 124 124 125 if (from.size() && from.operationsMatch(*this)) 125 return blendByMatchingOperations(from, progress);126 return blendByMatchingOperations(from, context); 126 127 127 return blendByUsingMatrixInterpolation(from, progress, size);128 return blendByUsingMatrixInterpolation(from, context, size); 128 129 } 129 130 -
trunk/Source/WebCore/platform/graphics/transforms/TransformOperations.h
r247504 r276141 31 31 32 32 namespace WebCore { 33 34 struct BlendingContext; 33 35 34 36 class TransformOperations { … … 84 86 const TransformOperation* at(size_t index) const { return index < m_operations.size() ? m_operations.at(index).get() : 0; } 85 87 86 TransformOperations blendByMatchingOperations(const TransformOperations& from, const double& progress) const;87 TransformOperations blendByUsingMatrixInterpolation(const TransformOperations& from, double progress, const LayoutSize&) const;88 TransformOperations blend(const TransformOperations& from, double progress, const LayoutSize&) const;88 TransformOperations blendByMatchingOperations(const TransformOperations& from, const BlendingContext&) const; 89 TransformOperations blendByUsingMatrixInterpolation(const TransformOperations& from, const BlendingContext&, const LayoutSize&) const; 90 TransformOperations blend(const TransformOperations& from, const BlendingContext&, const LayoutSize&) const; 89 91 90 92 private: -
trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp
r272805 r276141 23 23 #include "TranslateTransformOperation.h" 24 24 25 #include "AnimationUtilities.h" 25 26 #include "FloatConversion.h" 26 27 #include <wtf/text/TextStream.h> … … 36 37 } 37 38 38 Ref<TransformOperation> TranslateTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)39 Ref<TransformOperation> TranslateTransformOperation::blend(const TransformOperation* from, const BlendingContext& context, bool blendToIdentity) 39 40 { 40 41 if (from && !from->isSameType(*this)) … … 43 44 Length zeroLength(0, LengthType::Fixed); 44 45 if (blendToIdentity) 45 return TranslateTransformOperation::create(WebCore::blend(m_x, zeroLength, progress), WebCore::blend(m_y, zeroLength, progress), WebCore::blend(m_z, zeroLength, progress), type());46 return TranslateTransformOperation::create(WebCore::blend(m_x, zeroLength, context), WebCore::blend(m_y, zeroLength, context), WebCore::blend(m_z, zeroLength, context), type()); 46 47 47 48 const TranslateTransformOperation* fromOp = downcast<TranslateTransformOperation>(from); … … 49 50 Length fromY = fromOp ? fromOp->m_y : zeroLength; 50 51 Length fromZ = fromOp ? fromOp->m_z : zeroLength; 51 return TranslateTransformOperation::create(WebCore::blend(fromX, x(), progress), WebCore::blend(fromY, y(), progress), WebCore::blend(fromZ, z(), progress), type());52 return TranslateTransformOperation::create(WebCore::blend(fromX, x(), context), WebCore::blend(fromY, y(), context), WebCore::blend(fromZ, z(), context), type()); 52 53 } 53 54 -
trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h
r272805 r276141 31 31 32 32 namespace WebCore { 33 34 struct BlendingContext; 33 35 34 36 class TranslateTransformOperation final : public TransformOperation { … … 67 69 bool operator==(const TransformOperation&) const final; 68 70 69 Ref<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) final;71 Ref<TransformOperation> blend(const TransformOperation* from, const BlendingContext&, bool blendToIdentity = false) final; 70 72 71 73 bool isRepresentableIn2D() const final { return m_z.isZero(); } -
trunk/Source/WebCore/rendering/style/BasicShapes.cpp
r272805 r276141 31 31 #include "BasicShapes.h" 32 32 33 #include "AnimationUtilities.h" 33 34 #include "BasicShapeFunctions.h" 34 35 #include "CalculationValue.h" … … 190 191 } 191 192 192 Ref<BasicShape> BasicShapeCircle::blend(const BasicShape& other, double progress) const193 Ref<BasicShape> BasicShapeCircle::blend(const BasicShape& other, const BlendingContext& context) const 193 194 { 194 195 ASSERT(type() == other.type()); … … 196 197 auto result = BasicShapeCircle::create(); 197 198 198 result->setCenterX(m_centerX.blend(otherCircle.centerX(), progress));199 result->setCenterY(m_centerY.blend(otherCircle.centerY(), progress));200 result->setRadius(m_radius.blend(otherCircle.radius(), progress));199 result->setCenterX(m_centerX.blend(otherCircle.centerX(), context)); 200 result->setCenterY(m_centerY.blend(otherCircle.centerY(), context)); 201 result->setRadius(m_radius.blend(otherCircle.radius(), context)); 201 202 return result; 202 203 } … … 253 254 } 254 255 255 Ref<BasicShape> BasicShapeEllipse::blend(const BasicShape& other, double progress) const256 Ref<BasicShape> BasicShapeEllipse::blend(const BasicShape& other, const BlendingContext& context) const 256 257 { 257 258 ASSERT(type() == other.type()); … … 268 269 } 269 270 270 result->setCenterX(m_centerX.blend(otherEllipse.centerX(), progress));271 result->setCenterY(m_centerY.blend(otherEllipse.centerY(), progress));272 result->setRadiusX(m_radiusX.blend(otherEllipse.radiusX(), progress));273 result->setRadiusY(m_radiusY.blend(otherEllipse.radiusY(), progress));271 result->setCenterX(m_centerX.blend(otherEllipse.centerX(), context)); 272 result->setCenterY(m_centerY.blend(otherEllipse.centerY(), context)); 273 result->setRadiusX(m_radiusX.blend(otherEllipse.radiusX(), context)); 274 result->setRadiusY(m_radiusY.blend(otherEllipse.radiusY(), context)); 274 275 return result; 275 276 } … … 316 317 } 317 318 318 Ref<BasicShape> BasicShapePolygon::blend(const BasicShape& other, double progress) const319 Ref<BasicShape> BasicShapePolygon::blend(const BasicShape& other, const BlendingContext& context) const 319 320 { 320 321 ASSERT(type() == other.type()); … … 333 334 for (size_t i = 0; i < length; i = i + 2) { 334 335 result->appendPoint( 335 WebCore::blend(otherPolygon.values().at(i), m_values.at(i), progress),336 WebCore::blend(otherPolygon.values().at(i + 1), m_values.at(i + 1), progress));336 WebCore::blend(otherPolygon.values().at(i), m_values.at(i), context), 337 WebCore::blend(otherPolygon.values().at(i + 1), m_values.at(i + 1), context)); 337 338 } 338 339 … … 374 375 } 375 376 376 Ref<BasicShape> BasicShapePath::blend(const BasicShape& from, double progress) const377 Ref<BasicShape> BasicShapePath::blend(const BasicShape& from, const BlendingContext& context) const 377 378 { 378 379 ASSERT(type() == from.type()); … … 381 382 382 383 auto resultingPathBytes = makeUnique<SVGPathByteStream>(); 383 buildAnimatedSVGPathByteStream(*fromPath.m_byteStream, *m_byteStream, *resultingPathBytes, progress);384 buildAnimatedSVGPathByteStream(*fromPath.m_byteStream, *m_byteStream, *resultingPathBytes, context.progress); 384 385 auto result = BasicShapePath::create(WTFMove(resultingPathBytes)); 385 386 result->setWindRule(windRule()); … … 431 432 } 432 433 433 Ref<BasicShape> BasicShapeInset::blend(const BasicShape& from, double progress) const434 Ref<BasicShape> BasicShapeInset::blend(const BasicShape& from, const BlendingContext& context) const 434 435 { 435 436 ASSERT(type() == from.type()); … … 437 438 auto& fromInset = downcast<BasicShapeInset>(from); 438 439 auto result = BasicShapeInset::create(); 439 result->setTop(WebCore::blend(fromInset.top(), top(), progress));440 result->setRight(WebCore::blend(fromInset.right(), right(), progress));441 result->setBottom(WebCore::blend(fromInset.bottom(), bottom(), progress));442 result->setLeft(WebCore::blend(fromInset.left(), left(), progress));443 444 result->setTopLeftRadius(WebCore::blend(fromInset.topLeftRadius(), topLeftRadius(), progress));445 result->setTopRightRadius(WebCore::blend(fromInset.topRightRadius(), topRightRadius(), progress));446 result->setBottomRightRadius(WebCore::blend(fromInset.bottomRightRadius(), bottomRightRadius(), progress));447 result->setBottomLeftRadius(WebCore::blend(fromInset.bottomLeftRadius(), bottomLeftRadius(), progress));440 result->setTop(WebCore::blend(fromInset.top(), top(), context)); 441 result->setRight(WebCore::blend(fromInset.right(), right(), context)); 442 result->setBottom(WebCore::blend(fromInset.bottom(), bottom(), context)); 443 result->setLeft(WebCore::blend(fromInset.left(), left(), context)); 444 445 result->setTopLeftRadius(WebCore::blend(fromInset.topLeftRadius(), topLeftRadius(), context)); 446 result->setTopRightRadius(WebCore::blend(fromInset.topRightRadius(), topRightRadius(), context)); 447 result->setBottomRightRadius(WebCore::blend(fromInset.bottomRightRadius(), bottomRightRadius(), context)); 448 result->setBottomLeftRadius(WebCore::blend(fromInset.bottomLeftRadius(), bottomLeftRadius(), context)); 448 449 449 450 return result; -
trunk/Source/WebCore/rendering/style/BasicShapes.h
r272805 r276141 44 44 namespace WebCore { 45 45 46 struct BlendingContext; 46 47 class FloatRect; 47 48 class Path; … … 67 68 68 69 virtual bool canBlend(const BasicShape&) const = 0; 69 virtual Ref<BasicShape> blend(const BasicShape& from, double) const = 0;70 virtual Ref<BasicShape> blend(const BasicShape& from, const BlendingContext&) const = 0; 70 71 71 72 virtual bool operator==(const BasicShape&) const = 0; … … 97 98 const Length& computedLength() const { return m_computedLength; } 98 99 99 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& from, double progress) const100 { 101 return BasicShapeCenterCoordinate(TopLeft, WebCore::blend(from.m_computedLength, m_computedLength, progress));100 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& from, const BlendingContext& context) const 101 { 102 return BasicShapeCenterCoordinate(TopLeft, WebCore::blend(from.m_computedLength, m_computedLength, context)); 102 103 } 103 104 … … 145 146 } 146 147 147 BasicShapeRadius blend(const BasicShapeRadius& from, double progress) const148 BasicShapeRadius blend(const BasicShapeRadius& from, const BlendingContext& context) const 148 149 { 149 150 if (m_type != Value || from.type() != Value) 150 151 return BasicShapeRadius(from); 151 152 152 return BasicShapeRadius(WebCore::blend(from.value(), value(), progress));153 return BasicShapeRadius(WebCore::blend(from.value(), value(), context)); 153 154 } 154 155 … … 184 185 185 186 bool canBlend(const BasicShape&) const override; 186 Ref<BasicShape> blend(const BasicShape& from, double) const override;187 Ref<BasicShape> blend(const BasicShape& from, const BlendingContext&) const override; 187 188 188 189 bool operator==(const BasicShape&) const override; … … 218 219 219 220 bool canBlend(const BasicShape&) const override; 220 Ref<BasicShape> blend(const BasicShape& from, double) const override;221 Ref<BasicShape> blend(const BasicShape& from, const BlendingContext&) const override; 221 222 222 223 bool operator==(const BasicShape&) const override; … … 251 252 252 253 bool canBlend(const BasicShape&) const override; 253 Ref<BasicShape> blend(const BasicShape& from, double) const override;254 Ref<BasicShape> blend(const BasicShape& from, const BlendingContext&) const override; 254 255 255 256 bool operator==(const BasicShape&) const override; … … 283 284 284 285 bool canBlend(const BasicShape&) const override; 285 Ref<BasicShape> blend(const BasicShape& from, double) const override;286 Ref<BasicShape> blend(const BasicShape& from, const BlendingContext&) const override; 286 287 287 288 bool operator==(const BasicShape&) const override; … … 326 327 327 328 bool canBlend(const BasicShape&) const override; 328 Ref<BasicShape> blend(const BasicShape& from, double) const override;329 Ref<BasicShape> blend(const BasicShape& from, const BlendingContext&) const override; 329 330 330 331 bool operator==(const BasicShape&) const override; -
trunk/Source/WebCore/style/Styleable.cpp
r275422 r276141 235 235 { 236 236 if (auto* transition = transitions.get(property)) { 237 if (CSSPropertyAnimation::propertiesEqual(property, &style, &transition->targetStyle()))237 if (CSSPropertyAnimation::propertiesEqual(property, style, transition->targetStyle())) 238 238 return true; 239 239 } … … 357 357 358 358 if (!styleable.hasRunningTransitionForProperty(property) 359 && !CSSPropertyAnimation::propertiesEqual(property, &beforeChangeStyle, &afterChangeStyle)360 && CSSPropertyAnimation::canPropertyBeInterpolated(property, &beforeChangeStyle, &afterChangeStyle)359 && !CSSPropertyAnimation::propertiesEqual(property, beforeChangeStyle, afterChangeStyle) 360 && CSSPropertyAnimation::canPropertyBeInterpolated(property, beforeChangeStyle, afterChangeStyle) 361 361 && !propertyInStyleMatchesValueForTransitionInMap(property, afterChangeStyle, styleable.ensureCompletedTransitionsByProperty()) 362 362 && matchingBackingAnimation && transitionCombinedDuration(matchingBackingAnimation) > 0) { … … 404 404 // 4. If the element has a running transition for the property, there is a matching transition-property value, and the end value of the running 405 405 // transition is not equal to the value of the property in the after-change style, then: 406 if (CSSPropertyAnimation::propertiesEqual(property, &previouslyRunningTransitionCurrentStyle, &afterChangeStyle) || !CSSPropertyAnimation::canPropertyBeInterpolated(property, ¤tStyle, &afterChangeStyle)) {406 if (CSSPropertyAnimation::propertiesEqual(property, previouslyRunningTransitionCurrentStyle, afterChangeStyle) || !CSSPropertyAnimation::canPropertyBeInterpolated(property, currentStyle, afterChangeStyle)) { 407 407 // 1. If the current value of the property in the running transition is equal to the value of the property in the after-change style, 408 408 // or if these two values cannot be interpolated, then implementations must cancel the running transition. 409 409 previouslyRunningTransition->cancelFromStyle(); 410 } else if (transitionCombinedDuration(matchingBackingAnimation) <= 0.0 || !CSSPropertyAnimation::canPropertyBeInterpolated(property, &previouslyRunningTransitionCurrentStyle, &afterChangeStyle)) {410 } else if (transitionCombinedDuration(matchingBackingAnimation) <= 0.0 || !CSSPropertyAnimation::canPropertyBeInterpolated(property, previouslyRunningTransitionCurrentStyle, afterChangeStyle)) { 411 411 // 2. Otherwise, if the combined duration is less than or equal to 0s, or if the current value of the property in the running transition 412 412 // cannot be interpolated with the value of the property in the after-change style, then implementations must cancel the running transition. 413 413 previouslyRunningTransition->cancelFromStyle(); 414 } else if (CSSPropertyAnimation::propertiesEqual(property, &previouslyRunningTransition->reversingAdjustedStartStyle(), &afterChangeStyle)) {414 } else if (CSSPropertyAnimation::propertiesEqual(property, previouslyRunningTransition->reversingAdjustedStartStyle(), afterChangeStyle)) { 415 415 // 3. Otherwise, if the reversing-adjusted start value of the running transition is the same as the value of the property in the after-change 416 416 // style (see the section on reversing of transitions for why these case exists), implementations must cancel the running transition -
trunk/Source/WebCore/svg/SVGLengthValue.cpp
r263617 r276141 215 215 auto fromPercent = from.valueAsPercentage() * 100; 216 216 auto toPercent = to.valueAsPercentage() * 100; 217 return { WebCore::blend(fromPercent, toPercent, progress), SVGLengthType::Percentage };217 return { WebCore::blend(fromPercent, toPercent, { progress }), SVGLengthType::Percentage }; 218 218 } 219 219 … … 221 221 auto fromValue = from.valueInSpecifiedUnits(); 222 222 auto toValue = to.valueInSpecifiedUnits(); 223 return { WebCore::blend(fromValue, toValue, progress), to.isZero() ? from.lengthType() : to.lengthType() };223 return { WebCore::blend(fromValue, toValue, { progress }), to.isZero() ? from.lengthType() : to.lengthType() }; 224 224 } 225 225 … … 234 234 235 235 float toValue = to.valueInSpecifiedUnits(); 236 return { WebCore::blend(fromValue.releaseReturnValue(), toValue, progress), to.lengthType() };236 return { WebCore::blend(fromValue.releaseReturnValue(), toValue, { progress }), to.lengthType() }; 237 237 } 238 238 -
trunk/Source/WebCore/svg/SVGPathBlender.cpp
r267470 r276141 58 58 static inline FloatPoint blendFloatPoint(const FloatPoint& a, const FloatPoint& b, float progress) 59 59 { 60 return FloatPoint(blend(a.x(), b.x(), progress), blend(a.y(), b.y(), progress)); 60 BlendingContext context { progress }; 61 return FloatPoint(blend(a.x(), b.x(), context), blend(a.y(), b.y(), context)); 61 62 } 62 63 … … 69 70 70 71 if (m_fromMode == m_toMode) 71 return blend(from, to, progress);72 return blend(from, to, { progress }); 72 73 73 74 float fromValue = blendMode == BlendHorizontal ? m_fromCurrentPoint.x() : m_fromCurrentPoint.y(); … … 75 76 76 77 // Transform toY to the coordinate mode of fromY 77 float animValue = blend(from, m_fromMode == AbsoluteCoordinates ? to + toValue : to - toValue, progress);78 float animValue = blend(from, m_fromMode == AbsoluteCoordinates ? to + toValue : to - toValue, { progress }); 78 79 79 80 if (m_isInFirstHalfOfAnimation) … … 81 82 82 83 // Transform the animated point to the coordinate mode, needed for the current progress. 83 float currentValue = blend(fromValue, toValue, progress);84 float currentValue = blend(fromValue, toValue, { progress }); 84 85 return m_toMode == AbsoluteCoordinates ? animValue + currentValue : animValue - currentValue; 85 86 } … … 303 304 m_fromMode); 304 305 } else { 305 m_consumer->arcTo(blend(from.rx, to.rx, progress), 306 blend(from.ry, to.ry, progress), 307 blend(from.angle, to.angle, progress), 306 BlendingContext context { progress }; 307 m_consumer->arcTo(blend(from.rx, to.rx, context), 308 blend(from.ry, to.ry, context), 309 blend(from.angle, to.angle, context), 308 310 m_isInFirstHalfOfAnimation ? from.largeArc : to.largeArc, 309 311 m_isInFirstHalfOfAnimation ? from.sweep : to.sweep,
Note:
See TracChangeset
for help on using the changeset viewer.