Changeset 274409 in webkit
- Timestamp:
- Mar 15, 2021 12:36:05 AM (3 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r274408 r274409 1 2021-03-13 Antoine Quint <graouts@webkit.org> 2 3 Improve coding style of CSSPropertyAnimation.cpp 4 https://bugs.webkit.org/show_bug.cgi?id=223148 5 6 Reviewed by Darin Adler. 7 8 As much as possible, do the following: 9 10 1. mark classes as final 11 2. mark overridden methods as final 12 3. move overridden methods in private sections 13 4. failing that, move them to protected sections 14 5. stay clear from abbreviated terms 15 - prop => property 16 - anim => client 17 - dst => destination 18 6. use from/to as parameter names instead of a/b for any method 19 where the role of the parameters warrant it (eg. blend, canInterpolate) 20 21 This should greatly improve the coding style used throughout CSSPropertyAnimation.cpp 22 and make it cohesive. 23 24 * animation/CSSPropertyAnimation.cpp: 25 (WebCore::blendFunc): 26 (WebCore::blendFilterOperations): 27 (WebCore::blendFilter): 28 (WebCore::AnimationPropertyWrapperBase::AnimationPropertyWrapperBase): 29 (WebCore::AnimationPropertyWrapperBase::property const): 30 (WebCore::PropertyWrapperGetter::PropertyWrapperGetter): 31 (WebCore::PropertyWrapperGetter::value const): 32 (WebCore::PropertyWrapper::PropertyWrapper): 33 (WebCore::RefCountedPropertyWrapper::RefCountedPropertyWrapper): 34 (WebCore::canInterpolateLengths): 35 (WebCore::canInterpolateLengthVariants): 36 (WebCore::NonNegativeFloatPropertyWrapper::NonNegativeFloatPropertyWrapper): 37 (WebCore::CSSPropertyAnimation::blendProperties): 38 (WebCore::CSSPropertyAnimation::isPropertyAnimatable): 39 (WebCore::CSSPropertyAnimation::animationOfPropertyIsAccelerated): 40 (WebCore::CSSPropertyAnimation::propertiesEqual): 41 (WebCore::CSSPropertyAnimation::canPropertyBeInterpolated): 42 (WebCore::DiscretePropertyWrapper::DiscretePropertyWrapper): Deleted. 43 (WebCore::LengthPropertyWrapper::LengthPropertyWrapper): Deleted. 44 (WebCore::LengthVariantPropertyWrapper::LengthVariantPropertyWrapper): Deleted. 45 (WebCore::LengthBoxPropertyWrapper::LengthBoxPropertyWrapper): Deleted. 46 (WebCore::PropertyWrapperClipPath::PropertyWrapperClipPath): Deleted. 47 (WebCore::PropertyWrapperFontVariationSettings::PropertyWrapperFontVariationSettings): Deleted. 48 (WebCore::PropertyWrapperShape::PropertyWrapperShape): Deleted. 49 (WebCore::StyleImagePropertyWrapper::StyleImagePropertyWrapper): Deleted. 50 (WebCore::AcceleratedPropertyWrapper::AcceleratedPropertyWrapper): Deleted. 51 (WebCore::PropertyWrapperFilter::PropertyWrapperFilter): Deleted. 52 (WebCore::PropertyWrapperShadow::PropertyWrapperShadow): Deleted. 53 (WebCore::PropertyWrapperShadow::blendSimpleOrMatchedShadowLists const): Deleted. 54 (WebCore::PropertyWrapperShadow::blendMismatchedShadowLists const): Deleted. 55 (WebCore::PropertyWrapperMaybeInvalidColor::PropertyWrapperMaybeInvalidColor): Deleted. 56 (WebCore::PropertyWrapperMaybeInvalidColor::value const): Deleted. 57 (WebCore::PropertyWrapperVisitedAffectedColor::PropertyWrapperVisitedAffectedColor): Deleted. 58 (WebCore::FillLayerPropertyWrapper::FillLayerPropertyWrapper): Deleted. 59 (WebCore::FillLayerPositionPropertyWrapper::FillLayerPositionPropertyWrapper): Deleted. 60 (WebCore::FillLayerStyleImagePropertyWrapper::FillLayerStyleImagePropertyWrapper): Deleted. 61 (WebCore::FillLayersPropertyWrapper::FillLayersPropertyWrapper): Deleted. 62 (WebCore::ShorthandPropertyWrapper::ShorthandPropertyWrapper): Deleted. 63 (WebCore::ShorthandPropertyWrapper:: const): Deleted. 64 (WebCore::PropertyWrapperFlex::PropertyWrapperFlex): Deleted. 65 (WebCore::PropertyWrapperSVGPaint::PropertyWrapperSVGPaint): Deleted. 66 (WebCore::PropertyWrapperFontStyle::PropertyWrapperFontStyle): Deleted. 67 (WebCore::AutoPropertyWrapper::AutoPropertyWrapper): Deleted. 68 (WebCore::PerspectiveWrapper::PerspectiveWrapper): Deleted. 69 (WebCore::CSSPropertyAnimationWrapperMap::singleton): Deleted. 70 (WebCore::CSSPropertyAnimationWrapperMap::wrapperForProperty): Deleted. 71 (WebCore::CSSPropertyAnimationWrapperMap::wrapperForIndex): Deleted. 72 (WebCore::CSSPropertyAnimationWrapperMap::size): Deleted. 73 (WebCore::CSSPropertyAnimationWrapperMap::indexFromPropertyID): Deleted. 74 1 75 2021-03-14 Sam Weinig <weinig@apple.com> 2 76 -
trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp
r274391 r274409 101 101 } 102 102 103 static inline LengthSize blendFunc(const CSSPropertyBlendingClient* anim, const LengthSize& from, const LengthSize& to, double progress)104 { 105 return { blendFunc( anim, from.width, to.width, progress, ValueRangeNonNegative),106 blendFunc( anim, from.height, to.height, progress, ValueRangeNonNegative) };107 } 108 109 static inline ShadowStyle blendFunc(const CSSPropertyBlendingClient* anim, ShadowStyle from, ShadowStyle to, double progress)103 static inline LengthSize blendFunc(const CSSPropertyBlendingClient* client, const LengthSize& from, const LengthSize& to, double progress) 104 { 105 return { blendFunc(client, from.width, to.width, progress, ValueRangeNonNegative), 106 blendFunc(client, from.height, to.height, progress, ValueRangeNonNegative) }; 107 } 108 109 static inline ShadowStyle blendFunc(const CSSPropertyBlendingClient* client, ShadowStyle from, ShadowStyle to, double progress) 110 110 { 111 111 if (from == to) … … 114 114 double fromVal = from == ShadowStyle::Normal ? 1 : 0; 115 115 double toVal = to == ShadowStyle::Normal ? 1 : 0; 116 double result = blendFunc( anim, fromVal, toVal, progress);116 double result = blendFunc(client, fromVal, toVal, progress); 117 117 return result > 0 ? ShadowStyle::Normal : ShadowStyle::Inset; 118 118 } 119 119 120 static inline std::unique_ptr<ShadowData> blendFunc(const CSSPropertyBlendingClient* anim, const ShadowData* from, const ShadowData* to, double progress)120 static inline std::unique_ptr<ShadowData> blendFunc(const CSSPropertyBlendingClient* client, const ShadowData* from, const ShadowData* to, double progress) 121 121 { 122 122 ASSERT(from && to); … … 127 127 blend(from->radius(), to->radius(), progress), 128 128 blend(from->spread(), to->spread(), progress), 129 blendFunc( anim, from->style(), to->style(), progress),129 blendFunc(client, from->style(), to->style(), progress), 130 130 from->isWebkitBoxShadow(), 131 131 blend(from->color(), to->color(), progress)); 132 132 } 133 133 134 static inline TransformOperations blendFunc(const CSSPropertyBlendingClient* animation, const TransformOperations& from, const TransformOperations& to, double progress)135 { 136 if ( animation->transformFunctionListsMatch())134 static inline TransformOperations blendFunc(const CSSPropertyBlendingClient* client, const TransformOperations& from, const TransformOperations& to, double progress) 135 { 136 if (client->transformFunctionListsMatch()) 137 137 return to.blendByMatchingOperations(from, progress); 138 return to.blendByUsingMatrixInterpolation(from, progress, is<RenderBox>( animation->renderer()) ? downcast<RenderBox>(*animation->renderer()).borderBoxRect().size() : LayoutSize());138 return to.blendByUsingMatrixInterpolation(from, progress, is<RenderBox>(client->renderer()) ? downcast<RenderBox>(*client->renderer()).borderBoxRect().size() : LayoutSize()); 139 139 } 140 140 … … 285 285 } 286 286 287 static inline RefPtr<FilterOperation> blendFunc(const CSSPropertyBlendingClient*, FilterOperation* from Op, FilterOperation* toOp, double progress, bool blendToPassthrough = false)288 { 289 ASSERT(to Op);290 return to Op->blend(fromOp, progress, blendToPassthrough);291 } 292 293 static inline FilterOperations blendFilterOperations(const CSSPropertyBlendingClient* anim, const FilterOperations& from, const FilterOperations& to, double progress)287 static inline RefPtr<FilterOperation> blendFunc(const CSSPropertyBlendingClient*, FilterOperation* from, FilterOperation* to, double progress, bool blendToPassthrough = false) 288 { 289 ASSERT(to); 290 return to->blend(from, progress, blendToPassthrough); 291 } 292 293 static inline FilterOperations blendFilterOperations(const CSSPropertyBlendingClient* client, const FilterOperations& from, const FilterOperations& to, double progress) 294 294 { 295 295 FilterOperations result; … … 300 300 RefPtr<FilterOperation> fromOp = (i < fromSize) ? from.operations()[i].get() : 0; 301 301 RefPtr<FilterOperation> toOp = (i < toSize) ? to.operations()[i].get() : 0; 302 RefPtr<FilterOperation> blendedOp = toOp ? blendFunc( anim, fromOp.get(), toOp.get(), progress) : (fromOp ? blendFunc(anim, 0, fromOp.get(), progress, true) : 0);302 RefPtr<FilterOperation> blendedOp = toOp ? blendFunc(client, fromOp.get(), toOp.get(), progress) : (fromOp ? blendFunc(client, 0, fromOp.get(), progress, true) : 0); 303 303 if (blendedOp) 304 304 result.operations().append(blendedOp); … … 314 314 } 315 315 316 static inline FilterOperations blendFunc(const CSSPropertyBlendingClient* anim, const FilterOperations& from, const FilterOperations& to, double progress, CSSPropertyID propertyID = CSSPropertyFilter)316 static inline FilterOperations blendFunc(const CSSPropertyBlendingClient* client, const FilterOperations& from, const FilterOperations& to, double progress, CSSPropertyID propertyID = CSSPropertyFilter) 317 317 { 318 318 FilterOperations result; … … 323 323 switch (propertyID) { 324 324 case CSSPropertyFilter: 325 listsMatch = anim->filterFunctionListsMatch();325 listsMatch = client->filterFunctionListsMatch(); 326 326 break; 327 327 #if ENABLE(FILTERS_LEVEL_2) 328 328 case CSSPropertyWebkitBackdropFilter: 329 listsMatch = anim->backdropFilterFunctionListsMatch();329 listsMatch = client->backdropFilterFunctionListsMatch(); 330 330 break; 331 331 #endif 332 332 case CSSPropertyAppleColorFilter: 333 listsMatch = anim->colorFilterFunctionListsMatch();333 listsMatch = client->colorFilterFunctionListsMatch(); 334 334 break; 335 335 default: … … 338 338 339 339 if (listsMatch) 340 result = blendFilterOperations( anim, from, to, progress);340 result = blendFilterOperations(client, from, to, progress); 341 341 else { 342 342 // 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. … … 348 348 } 349 349 350 static inline RefPtr<StyleImage> blendFilter(const CSSPropertyBlendingClient* anim, CachedImage* image, const FilterOperations& from, const FilterOperations& to, double progress)350 static inline RefPtr<StyleImage> blendFilter(const CSSPropertyBlendingClient* client, CachedImage* image, const FilterOperations& from, const FilterOperations& to, double progress) 351 351 { 352 352 ASSERT(image); 353 FilterOperations filterResult = blendFilterOperations( anim, from, to, progress);353 FilterOperations filterResult = blendFilterOperations(client, from, to, progress); 354 354 355 355 auto imageValue = CSSImageValue::create(*image); 356 auto filterValue = ComputedStyleExtractor::valueForFilter( anim->currentStyle(), filterResult, DoNotAdjustPixelValues);356 auto filterValue = ComputedStyleExtractor::valueForFilter(client->currentStyle(), filterResult, DoNotAdjustPixelValues); 357 357 358 358 auto result = CSSFilterImageValue::create(WTFMove(imageValue), WTFMove(filterValue)); … … 361 361 } 362 362 363 static inline Visibility blendFunc(const CSSPropertyBlendingClient* anim, Visibility from, Visibility to, double progress)363 static inline Visibility blendFunc(const CSSPropertyBlendingClient* client, Visibility from, Visibility to, double progress) 364 364 { 365 365 // Any non-zero result means we consider the object to be visible. Only at 0 do we consider the object to be … … 369 369 if (fromVal == toVal) 370 370 return to; 371 double result = blendFunc( anim, fromVal, toVal, progress);371 double result = blendFunc(client, fromVal, toVal, progress); 372 372 return result > 0. ? Visibility::Visible : (to != Visibility::Visible ? to : from); 373 373 } 374 374 375 static inline TextUnderlineOffset blendFunc(const CSSPropertyBlendingClient* anim, const TextUnderlineOffset& from, const TextUnderlineOffset& to, double progress)375 static inline TextUnderlineOffset blendFunc(const CSSPropertyBlendingClient* client, const TextUnderlineOffset& from, const TextUnderlineOffset& to, double progress) 376 376 { 377 377 if (from.isLength() && to.isLength()) 378 return TextUnderlineOffset::createWithLength(blendFunc( anim, from.lengthValue(), to.lengthValue(), progress));378 return TextUnderlineOffset::createWithLength(blendFunc(client, from.lengthValue(), to.lengthValue(), progress)); 379 379 return TextUnderlineOffset::createWithAuto(); 380 380 } 381 381 382 static inline TextDecorationThickness blendFunc(const CSSPropertyBlendingClient* anim, const TextDecorationThickness& from, const TextDecorationThickness& to, double progress)382 static inline TextDecorationThickness blendFunc(const CSSPropertyBlendingClient* client, const TextDecorationThickness& from, const TextDecorationThickness& to, double progress) 383 383 { 384 384 if (from.isLength() && to.isLength()) 385 return TextDecorationThickness::createWithLength(blendFunc( anim, from.lengthValue(), to.lengthValue(), progress));385 return TextDecorationThickness::createWithLength(blendFunc(client, from.lengthValue(), to.lengthValue(), progress)); 386 386 return TextDecorationThickness::createWithAuto(); 387 387 } 388 388 389 static inline LengthBox blendFunc(const CSSPropertyBlendingClient* anim, const LengthBox& from, const LengthBox& to, double progress, ValueRange valueRange = ValueRangeNonNegative) 390 { 391 LengthBox result(blendFunc(anim, from.top(), to.top(), progress, valueRange), 392 blendFunc(anim, from.right(), to.right(), progress, valueRange), 393 blendFunc(anim, from.bottom(), to.bottom(), progress, valueRange), 394 blendFunc(anim, from.left(), to.left(), progress, valueRange)); 395 389 static inline LengthBox blendFunc(const CSSPropertyBlendingClient* client, const LengthBox& from, const LengthBox& to, double progress, ValueRange valueRange = ValueRangeNonNegative) 390 { 391 LengthBox result(blendFunc(client, from.top(), to.top(), progress, valueRange), 392 blendFunc(client, from.right(), to.right(), progress, valueRange), 393 blendFunc(client, from.bottom(), to.bottom(), progress, valueRange), 394 blendFunc(client, from.left(), to.left(), progress, valueRange)); 396 395 return result; 397 396 } … … 442 441 } 443 442 444 static inline RefPtr<StyleImage> blendFunc(const CSSPropertyBlendingClient* anim, StyleImage* from, StyleImage* to, double progress)443 static inline RefPtr<StyleImage> blendFunc(const CSSPropertyBlendingClient* client, StyleImage* from, StyleImage* to, double progress) 445 444 { 446 445 if (!from || !to) … … 464 463 CSSFilterImageValue& toFilter = downcast<CSSFilterImageValue>(toGenerated); 465 464 if (fromFilter.equalInputImages(toFilter) && fromFilter.cachedImage()) 466 return blendFilter( anim, fromFilter.cachedImage(), fromFilter.filterOperations(), toFilter.filterOperations(), progress);465 return blendFilter(client, fromFilter.cachedImage(), fromFilter.filterOperations(), toFilter.filterOperations(), progress); 467 466 } 468 467 … … 483 482 CSSFilterImageValue& fromFilter = downcast<CSSFilterImageValue>(fromGenerated); 484 483 if (fromFilter.cachedImage() && downcast<StyleCachedImage>(*to).cachedImage() == fromFilter.cachedImage()) 485 return blendFilter( anim, fromFilter.cachedImage(), fromFilter.filterOperations(), FilterOperations(), progress);484 return blendFilter(client, fromFilter.cachedImage(), fromFilter.filterOperations(), FilterOperations(), progress); 486 485 } 487 486 // FIXME: Add interpolation between cross-fade and image source. … … 491 490 CSSFilterImageValue& toFilter = downcast<CSSFilterImageValue>(toGenerated); 492 491 if (toFilter.cachedImage() && downcast<StyleCachedImage>(*from).cachedImage() == toFilter.cachedImage()) 493 return blendFilter( anim, toFilter.cachedImage(), FilterOperations(), toFilter.filterOperations(), progress);492 return blendFilter(client, toFilter.cachedImage(), FilterOperations(), toFilter.filterOperations(), progress); 494 493 } 495 494 // FIXME: Add interpolation between image source and cross-fade. … … 499 498 // https://bugs.webkit.org/show_bug.cgi?id=78293 500 499 if (is<StyleCachedImage>(*from) && is<StyleCachedImage>(*to)) 501 return crossfadeBlend( anim, downcast<StyleCachedImage>(from), downcast<StyleCachedImage>(to), progress);500 return crossfadeBlend(client, downcast<StyleCachedImage>(from), downcast<StyleCachedImage>(to), progress); 502 501 503 502 return to; 504 503 } 505 504 506 static inline NinePieceImage blendFunc(const CSSPropertyBlendingClient* anim, const NinePieceImage& from, const NinePieceImage& to, double progress)505 static inline NinePieceImage blendFunc(const CSSPropertyBlendingClient* client, const NinePieceImage& from, const NinePieceImage& to, double progress) 507 506 { 508 507 if (!from.hasImage() || !to.hasImage()) … … 514 513 return to; 515 514 516 if (auto* renderer = anim->renderer()) {515 if (auto* renderer = client->renderer()) { 517 516 if (from.image()->imageSize(renderer, 1.0) != to.image()->imageSize(renderer, 1.0)) 518 517 return to; 519 518 } 520 519 521 return NinePieceImage(blendFunc( anim, from.image(), to.image(), progress),520 return NinePieceImage(blendFunc(client, from.image(), to.image(), progress), 522 521 from.imageSlices(), from.fill(), from.borderSlices(), from.outset(), from.horizontalRule(), from.verticalRule()); 523 522 } … … 525 524 #if ENABLE(VARIATION_FONTS) 526 525 527 static inline FontVariationSettings blendFunc(const CSSPropertyBlendingClient* anim, const FontVariationSettings& from, const FontVariationSettings& to, double progress)526 static inline FontVariationSettings blendFunc(const CSSPropertyBlendingClient* client, const FontVariationSettings& from, const FontVariationSettings& to, double progress) 528 527 { 529 528 if (!progress) … … 540 539 auto& toItem = to.at(i); 541 540 ASSERT(fromItem.tag() == toItem.tag()); 542 float interpolated = blendFunc( anim, fromItem.value(), toItem.value(), progress);541 float interpolated = blendFunc(client, fromItem.value(), toItem.value(), progress); 543 542 result.insert({ fromItem.tag(), interpolated }); 544 543 } … … 548 547 #endif 549 548 550 static inline FontSelectionValue blendFunc(const CSSPropertyBlendingClient* anim, FontSelectionValue from, FontSelectionValue to, double progress)551 { 552 return FontSelectionValue(blendFunc( anim, static_cast<float>(from), static_cast<float>(to), progress));553 } 554 555 static inline Optional<FontSelectionValue> blendFunc(const CSSPropertyBlendingClient* anim, Optional<FontSelectionValue> from, Optional<FontSelectionValue> to, double progress)556 { 557 return FontSelectionValue(blendFunc( anim, static_cast<float>(from.value()), static_cast<float>(to.value()), progress));549 static inline FontSelectionValue blendFunc(const CSSPropertyBlendingClient* client, FontSelectionValue from, FontSelectionValue to, double progress) 550 { 551 return FontSelectionValue(blendFunc(client, static_cast<float>(from), static_cast<float>(to), progress)); 552 } 553 554 static inline Optional<FontSelectionValue> blendFunc(const CSSPropertyBlendingClient* client, Optional<FontSelectionValue> from, Optional<FontSelectionValue> to, double progress) 555 { 556 return FontSelectionValue(blendFunc(client, static_cast<float>(from.value()), static_cast<float>(to.value()), progress)); 558 557 } 559 558 … … 562 561 WTF_MAKE_FAST_ALLOCATED; 563 562 public: 564 explicit AnimationPropertyWrapperBase(CSSPropertyID prop )565 : m_prop (prop)563 explicit AnimationPropertyWrapperBase(CSSPropertyID property) 564 : m_property(property) 566 565 { 567 566 } … … 569 568 570 569 virtual bool isShorthandWrapper() const { return false; } 571 virtual bool equals(const RenderStyle* a, const RenderStyle* b) const = 0;570 virtual bool equals(const RenderStyle*, const RenderStyle*) const = 0; 572 571 virtual bool canInterpolate(const RenderStyle*, const RenderStyle*) const { return true; } 573 572 virtual void blend(const CSSPropertyBlendingClient*, RenderStyle*, const RenderStyle*, const RenderStyle*, double) const = 0; 574 573 575 574 #if !LOG_DISABLED 576 virtual void logBlend(const RenderStyle* a, const RenderStyle* b, const RenderStyle* result, double) const = 0;575 virtual void logBlend(const RenderStyle*, const RenderStyle*, const RenderStyle*, double) const = 0; 577 576 #endif 578 577 579 CSSPropertyID property() const { return m_prop ; }578 CSSPropertyID property() const { return m_property; } 580 579 581 580 virtual bool animationIsAccelerated() const { return false; } 582 581 583 582 private: 584 CSSPropertyID m_prop ;583 CSSPropertyID m_property; 585 584 }; 586 585 … … 589 588 WTF_MAKE_FAST_ALLOCATED; 590 589 public: 591 PropertyWrapperGetter(CSSPropertyID prop , T (RenderStyle::*getter)() const)592 : AnimationPropertyWrapperBase(prop )590 PropertyWrapperGetter(CSSPropertyID property, T (RenderStyle::*getter)() const) 591 : AnimationPropertyWrapperBase(property) 593 592 , m_getter(getter) 594 593 { 595 594 } 596 595 596 T value(const RenderStyle* style) const 597 { 598 return (style->*m_getter)(); 599 } 600 601 private: 597 602 bool equals(const RenderStyle* a, const RenderStyle* b) const override 598 603 { … … 601 606 if (!a || !b) 602 607 return false; 603 return this->value(a) == this->value(b); 604 } 605 606 T value(const RenderStyle* a) const 607 { 608 return (a->*m_getter)(); 608 return value(a) == value(b); 609 609 } 610 610 611 611 #if !LOG_DISABLED 612 void logBlend(const RenderStyle* a, const RenderStyle* b, const RenderStyle* result, double progress) const final613 { 614 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value( a) << " to " << value(b) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(result));612 void logBlend(const RenderStyle* from, const RenderStyle* to, const RenderStyle* result, double progress) const final 613 { 614 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(result)); 615 615 } 616 616 #endif 617 617 618 protected:619 618 T (RenderStyle::*m_getter)() const; 620 619 }; … … 624 623 WTF_MAKE_FAST_ALLOCATED; 625 624 public: 626 PropertyWrapper(CSSPropertyID prop , T (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T))627 : PropertyWrapperGetter<T>(prop , getter)625 PropertyWrapper(CSSPropertyID property, T (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T)) 626 : PropertyWrapperGetter<T>(property, getter) 628 627 , m_setter(setter) 629 628 { 630 629 } 631 630 632 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override633 { 634 (d st->*m_setter)(blendFunc(anim, this->value(a), this->value(b), progress));631 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const override 632 { 633 (destination->*m_setter)(blendFunc(client, this->value(from), this->value(to), progress)); 635 634 } 636 635 … … 649 648 650 649 private: 651 652 650 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 653 651 { … … 658 656 659 657 template <typename T> 660 class DiscretePropertyWrapper : public PropertyWrapperGetter<T> {661 WTF_MAKE_FAST_ALLOCATED; 662 public: 663 DiscretePropertyWrapper(CSSPropertyID prop , T (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T))664 : PropertyWrapperGetter<T>(prop , getter)658 class DiscretePropertyWrapper final : public PropertyWrapperGetter<T> { 659 WTF_MAKE_FAST_ALLOCATED; 660 public: 661 DiscretePropertyWrapper(CSSPropertyID property, T (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T)) 662 : PropertyWrapperGetter<T>(property, getter) 665 663 , m_setter(setter) 666 664 { 667 665 } 668 666 667 private: 669 668 bool canInterpolate(const RenderStyle*, const RenderStyle*) const final { return false; } 670 669 671 void blend(const CSSPropertyBlendingClient*, RenderStyle* d st, const RenderStyle* a, const RenderStyle* b, double progress) const override670 void blend(const CSSPropertyBlendingClient*, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 672 671 { 673 672 ASSERT(!progress || progress == 1.0); 674 (dst->*m_setter)(this->value(progress ? b : a)); 675 } 676 677 protected: 673 (destination->*this->m_setter)(this->value(progress ? to : from)); 674 } 675 678 676 void (RenderStyle::*m_setter)(T); 679 677 }; … … 683 681 WTF_MAKE_FAST_ALLOCATED; 684 682 public: 685 RefCountedPropertyWrapper(CSSPropertyID prop , T* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(RefPtr<T>&&))686 : PropertyWrapperGetter<T*>(prop , getter)683 RefCountedPropertyWrapper(CSSPropertyID property, T* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(RefPtr<T>&&)) 684 : PropertyWrapperGetter<T*>(property, getter) 687 685 , m_setter(setter) 688 686 { 689 687 } 690 688 691 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override 692 {693 (dst->*m_setter)(blendFunc(anim, this->value(a), this->value(b), progress));694 }695 696 protected: 689 private: 690 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 691 { 692 (destination->*this->m_setter)(blendFunc(client, this->value(from), this->value(to), progress)); 693 } 694 697 695 void (RenderStyle::*m_setter)(RefPtr<T>&&); 698 696 }; 699 697 700 static bool canInterpolateLengths(const Length& a, const Length& b, bool isLengthPercentage)701 { 702 if ( a.type() == b.type())698 static bool canInterpolateLengths(const Length& from, const Length& to, bool isLengthPercentage) 699 { 700 if (from.type() == to.type()) 703 701 return true; 704 702 … … 708 706 // dealing with a <number> as opposed to a <length> or <percentage>. 709 707 if (isLengthPercentage) { 710 return ( a.isFixed() || a.isPercentOrCalculated() || a.isRelative())711 && ( b.isFixed() || b.isPercentOrCalculated() || b.isRelative())712 && a.isRelative() == b.isRelative();708 return (from.isFixed() || from.isPercentOrCalculated() || from.isRelative()) 709 && (to.isFixed() || to.isPercentOrCalculated() || to.isRelative()) 710 && from.isRelative() == to.isRelative(); 713 711 } 714 712 … … 716 714 } 717 715 718 class LengthPropertyWrapper : public PropertyWrapperGetter<const Length&> {716 class LengthPropertyWrapper final : public PropertyWrapperGetter<const Length&> { 719 717 WTF_MAKE_FAST_ALLOCATED; 720 718 public: … … 723 721 NegativeLengthsAreInvalid = 1 << 1, 724 722 }; 725 LengthPropertyWrapper(CSSPropertyID prop , const Length& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(Length&&), OptionSet<Flags> flags = { })726 : PropertyWrapperGetter<const Length&>(prop , getter)723 LengthPropertyWrapper(CSSPropertyID property, const Length& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(Length&&), OptionSet<Flags> flags = { }) 724 : PropertyWrapperGetter<const Length&>(property, getter) 727 725 , m_setter(setter) 728 726 , m_flags(flags) … … 730 728 } 731 729 732 bool canInterpolate(const RenderStyle* a, const RenderStyle* b) const override 733 { 734 return canInterpolateLengths(this->value(a), this->value(b), m_flags.contains(Flags::IsLengthPercentage)); 735 } 736 737 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override 730 private: 731 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const final 732 { 733 return canInterpolateLengths(value(from), value(to), m_flags.contains(Flags::IsLengthPercentage)); 734 } 735 736 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 738 737 { 739 738 auto valueRange = m_flags.contains(Flags::NegativeLengthsAreInvalid) ? ValueRangeNonNegative : ValueRangeAll; 740 (dst->*m_setter)(blendFunc(anim, this->value(a), this->value(b), progress, valueRange)); 741 } 742 743 protected: 739 (destination->*m_setter)(blendFunc(client, value(from), value(to), progress, valueRange)); 740 } 741 744 742 void (RenderStyle::*m_setter)(Length&&); 745 746 private:747 743 OptionSet<Flags> m_flags; 748 744 }; 749 745 750 static bool canInterpolateLengthVariants(const LengthSize& a, const LengthSize& b)746 static bool canInterpolateLengthVariants(const LengthSize& from, const LengthSize& to) 751 747 { 752 748 bool isLengthPercentage = true; 753 return canInterpolateLengths( a.width, b.width, isLengthPercentage)754 && canInterpolateLengths( a.height, b.height, isLengthPercentage);755 } 756 757 static bool canInterpolateLengthVariants(const GapLength& a, const GapLength& b)758 { 759 if ( a.isNormal() || b.isNormal())749 return canInterpolateLengths(from.width, to.width, isLengthPercentage) 750 && canInterpolateLengths(from.height, to.height, isLengthPercentage); 751 } 752 753 static bool canInterpolateLengthVariants(const GapLength& from, const GapLength& to) 754 { 755 if (from.isNormal() || to.isNormal()) 760 756 return false; 761 757 bool isLengthPercentage = true; 762 return canInterpolateLengths( a.length(), b.length(), isLengthPercentage);758 return canInterpolateLengths(from.length(), to.length(), isLengthPercentage); 763 759 } 764 760 765 761 template <typename T> 766 class LengthVariantPropertyWrapper : public PropertyWrapperGetter<const T&> {767 WTF_MAKE_FAST_ALLOCATED; 768 public: 769 LengthVariantPropertyWrapper(CSSPropertyID prop , const T& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T&&))770 : PropertyWrapperGetter<const T&>(prop , getter)762 class LengthVariantPropertyWrapper final : public PropertyWrapperGetter<const T&> { 763 WTF_MAKE_FAST_ALLOCATED; 764 public: 765 LengthVariantPropertyWrapper(CSSPropertyID property, const T& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T&&)) 766 : PropertyWrapperGetter<const T&>(property, getter) 771 767 , m_setter(setter) 772 768 { 773 769 } 774 770 775 bool canInterpolate(const RenderStyle* a, const RenderStyle* b) const override 776 {777 return canInterpolateLengthVariants(this->value(a), this->value(b));778 }779 780 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override 781 {782 (dst->*m_setter)(blendFunc(anim, this->value(a), this->value(b), progress));783 }784 785 protected: 771 private: 772 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const final 773 { 774 return canInterpolateLengthVariants(this->value(from), this->value(to)); 775 } 776 777 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 778 { 779 (destination->*m_setter)(blendFunc(client, this->value(from), this->value(to), progress)); 780 } 781 786 782 void (RenderStyle::*m_setter)(T&&); 787 783 }; 788 784 789 class LengthBoxPropertyWrapper : public PropertyWrapperGetter<const LengthBox&> {785 class LengthBoxPropertyWrapper final : public PropertyWrapperGetter<const LengthBox&> { 790 786 WTF_MAKE_FAST_ALLOCATED; 791 787 public: … … 795 791 AllowsNegativeValues = 1 << 2, 796 792 }; 797 LengthBoxPropertyWrapper(CSSPropertyID prop , const LengthBox& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(LengthBox&&), OptionSet<Flags> flags = { })798 : PropertyWrapperGetter<const LengthBox&>(prop , getter)793 LengthBoxPropertyWrapper(CSSPropertyID property, const LengthBox& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(LengthBox&&), OptionSet<Flags> flags = { }) 794 : PropertyWrapperGetter<const LengthBox&>(property, getter) 799 795 , m_setter(setter) 800 796 , m_flags(flags) … … 802 798 } 803 799 804 bool canInterpolate(const RenderStyle* a, const RenderStyle* b) const override 805 { 806 if (m_flags.contains(Flags::UsesFillKeyword) && a->borderImage().fill() != b->borderImage().fill()) 800 private: 801 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const final 802 { 803 if (m_flags.contains(Flags::UsesFillKeyword) && from->borderImage().fill() != to->borderImage().fill()) 807 804 return false; 808 805 809 auto& aLengthBox = this->value(a);810 auto& bLengthBox = this->value(b);806 auto& fromLengthBox = value(from); 807 auto& toLengthBox = value(to); 811 808 bool isLengthPercentage = m_flags.contains(Flags::IsLengthPercentage); 812 return canInterpolateLengths( aLengthBox.top(), bLengthBox.top(), isLengthPercentage)813 && canInterpolateLengths( aLengthBox.right(), bLengthBox.right(), isLengthPercentage)814 && canInterpolateLengths( aLengthBox.bottom(), bLengthBox.bottom(), isLengthPercentage)815 && canInterpolateLengths( aLengthBox.left(), bLengthBox.left(), isLengthPercentage);816 } 817 818 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override809 return canInterpolateLengths(fromLengthBox.top(), toLengthBox.top(), isLengthPercentage) 810 && canInterpolateLengths(fromLengthBox.right(), toLengthBox.right(), isLengthPercentage) 811 && canInterpolateLengths(fromLengthBox.bottom(), toLengthBox.bottom(), isLengthPercentage) 812 && canInterpolateLengths(fromLengthBox.left(), toLengthBox.left(), isLengthPercentage); 813 } 814 815 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 819 816 { 820 817 if (m_flags.contains(Flags::UsesFillKeyword)) 821 d st->setBorderImageSliceFill((!progress || canInterpolate(a, b) ? a : b)->borderImage().fill());818 destination->setBorderImageSliceFill((!progress || canInterpolate(from, to) ? from : to)->borderImage().fill()); 822 819 auto valueRange = m_flags.contains(Flags::AllowsNegativeValues) ? ValueRangeAll : ValueRangeNonNegative; 823 (dst->*m_setter)(blendFunc(anim, this->value(a), this->value(b), progress, valueRange)); 824 } 825 826 protected: 820 (destination->*m_setter)(blendFunc(client, value(from), value(to), progress, valueRange)); 821 } 822 827 823 void (RenderStyle::*m_setter)(LengthBox&&); 828 829 private:830 824 OptionSet<Flags> m_flags; 831 825 }; 832 826 833 class PropertyWrapperClipPath : public RefCountedPropertyWrapper<ClipPathOperation> { 834 WTF_MAKE_FAST_ALLOCATED; 835 public: 836 PropertyWrapperClipPath(CSSPropertyID prop, ClipPathOperation* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(RefPtr<ClipPathOperation>&&)) 837 : RefCountedPropertyWrapper<ClipPathOperation>(prop, getter, setter) 838 { 839 } 840 841 bool equals(const RenderStyle* a, const RenderStyle* b) const override 827 class PropertyWrapperClipPath final : public RefCountedPropertyWrapper<ClipPathOperation> { 828 WTF_MAKE_FAST_ALLOCATED; 829 public: 830 PropertyWrapperClipPath(CSSPropertyID property, ClipPathOperation* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(RefPtr<ClipPathOperation>&&)) 831 : RefCountedPropertyWrapper<ClipPathOperation>(property, getter, setter) 832 { 833 } 834 835 private: 836 bool equals(const RenderStyle* a, const RenderStyle* b) const final 842 837 { 843 838 // If the style pointers are the same, don't bother doing the test. … … 848 843 return false; 849 844 850 auto* clipPathA = this->value(a);851 auto* clipPathB = this->value(b);845 auto* clipPathA = value(a); 846 auto* clipPathB = value(b); 852 847 if (clipPathA == clipPathB) 853 848 return true; … … 859 854 860 855 #if ENABLE(VARIATION_FONTS) 861 class PropertyWrapperFontVariationSettings : public PropertyWrapper<FontVariationSettings> { 862 WTF_MAKE_FAST_ALLOCATED; 863 public: 864 PropertyWrapperFontVariationSettings(CSSPropertyID prop, FontVariationSettings (RenderStyle::*getter)() const, void (RenderStyle::*setter)(FontVariationSettings)) 865 : PropertyWrapper<FontVariationSettings>(prop, getter, setter) 866 { 867 } 868 869 bool equals(const RenderStyle* a, const RenderStyle* b) const override 856 class PropertyWrapperFontVariationSettings final : public PropertyWrapper<FontVariationSettings> { 857 WTF_MAKE_FAST_ALLOCATED; 858 public: 859 PropertyWrapperFontVariationSettings(CSSPropertyID property, FontVariationSettings (RenderStyle::*getter)() const, void (RenderStyle::*setter)(FontVariationSettings)) 860 : PropertyWrapper<FontVariationSettings>(property, getter, setter) 861 { 862 } 863 864 private: 865 bool equals(const RenderStyle* a, const RenderStyle* b) const final 870 866 { 871 867 // If the style pointers are the same, don't bother doing the test. … … 875 871 if (!a || !b) 876 872 return false; 877 return this->value(a) == this->value(b);878 } 879 880 bool canInterpolate(const RenderStyle* a, const RenderStyle* b) const override881 { 882 auto aVariationSettings = value(a);883 auto bVariationSettings = value(b);884 885 if ( aVariationSettings.size() != bVariationSettings.size())873 return value(a) == value(b); 874 } 875 876 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const final 877 { 878 auto fromVariationSettings = value(from); 879 auto toVariationSettings = value(to); 880 881 if (fromVariationSettings.size() != toVariationSettings.size()) 886 882 return false; 887 883 888 auto size = aVariationSettings.size();884 auto size = fromVariationSettings.size(); 889 885 for (unsigned i = 0; i < size; ++i) { 890 if ( aVariationSettings.at(i).tag() != bVariationSettings.at(i).tag())886 if (fromVariationSettings.at(i).tag() != toVariationSettings.at(i).tag()) 891 887 return false; 892 888 } … … 897 893 #endif 898 894 899 class PropertyWrapperShape : public RefCountedPropertyWrapper<ShapeValue> { 900 WTF_MAKE_FAST_ALLOCATED; 901 public: 902 PropertyWrapperShape(CSSPropertyID prop, ShapeValue* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(RefPtr<ShapeValue>&&)) 903 : RefCountedPropertyWrapper<ShapeValue>(prop, getter, setter) 904 { 905 } 906 907 bool equals(const RenderStyle* a, const RenderStyle* b) const override 895 class PropertyWrapperShape final : public RefCountedPropertyWrapper<ShapeValue> { 896 WTF_MAKE_FAST_ALLOCATED; 897 public: 898 PropertyWrapperShape(CSSPropertyID property, ShapeValue* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(RefPtr<ShapeValue>&&)) 899 : RefCountedPropertyWrapper<ShapeValue>(property, getter, setter) 900 { 901 } 902 903 private: 904 bool equals(const RenderStyle* a, const RenderStyle* b) const final 908 905 { 909 906 // If the style pointers are the same, don't bother doing the test. … … 914 911 return false; 915 912 916 auto* shapeA = this->value(a);917 auto* shapeB = this->value(b);913 auto* shapeA = value(a); 914 auto* shapeB = value(b); 918 915 if (shapeA == shapeB) 919 916 return true; … … 924 921 }; 925 922 926 class StyleImagePropertyWrapper : public RefCountedPropertyWrapper<StyleImage> { 927 WTF_MAKE_FAST_ALLOCATED; 928 public: 929 StyleImagePropertyWrapper(CSSPropertyID prop, StyleImage* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(RefPtr<StyleImage>&&)) 930 : RefCountedPropertyWrapper<StyleImage>(prop, getter, setter) 931 { 932 } 933 934 bool equals(const RenderStyle* a, const RenderStyle* b) const override 923 class StyleImagePropertyWrapper final : public RefCountedPropertyWrapper<StyleImage> { 924 WTF_MAKE_FAST_ALLOCATED; 925 public: 926 StyleImagePropertyWrapper(CSSPropertyID property, StyleImage* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(RefPtr<StyleImage>&&)) 927 : RefCountedPropertyWrapper<StyleImage>(property, getter, setter) 928 { 929 } 930 931 private: 932 bool equals(const RenderStyle* a, const RenderStyle* b) const final 935 933 { 936 934 if (a == b) … … 939 937 return false; 940 938 941 auto* imageA = this->value(a);942 auto* imageB = this->value(b);939 auto* imageA = value(a); 940 auto* imageB = value(b); 943 941 return arePointingToEqualData(imageA, imageB); 944 942 } … … 946 944 947 945 template <typename T> 948 class AcceleratedPropertyWrapper : public PropertyWrapper<T> {949 WTF_MAKE_FAST_ALLOCATED; 950 public: 951 AcceleratedPropertyWrapper(CSSPropertyID prop , T (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T))952 : PropertyWrapper<T>(prop , getter, setter)953 { 954 } 955 956 private: 957 bool animationIsAccelerated() const override{ return true; }946 class AcceleratedPropertyWrapper final : public PropertyWrapper<T> { 947 WTF_MAKE_FAST_ALLOCATED; 948 public: 949 AcceleratedPropertyWrapper(CSSPropertyID property, T (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T)) 950 : PropertyWrapper<T>(property, getter, setter) 951 { 952 } 953 954 private: 955 bool animationIsAccelerated() const final { return true; } 958 956 }; 959 957 … … 962 960 WTF_MAKE_FAST_ALLOCATED; 963 961 public: 964 AcceleratedIndividualTransformPropertyWrapper(CSSPropertyID prop , T* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(RefPtr<T>&&))965 : RefCountedPropertyWrapper<T>(prop , getter, setter)962 AcceleratedIndividualTransformPropertyWrapper(CSSPropertyID property, T* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(RefPtr<T>&&)) 963 : RefCountedPropertyWrapper<T>(property, getter, setter) 966 964 { 967 965 } … … 976 974 }; 977 975 978 class PropertyWrapperFilter : public PropertyWrapper<const FilterOperations&> {976 class PropertyWrapperFilter final : public PropertyWrapper<const FilterOperations&> { 979 977 WTF_MAKE_FAST_ALLOCATED; 980 978 public: … … 984 982 } 985 983 986 bool animationIsAccelerated() const override 984 private: 985 bool animationIsAccelerated() const final 987 986 { 988 987 return property() == CSSPropertyFilter … … 993 992 } 994 993 995 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override996 { 997 (d st->*m_setter)(blendFunc(anim, this->value(a), this->value(b), progress, property()));994 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 995 { 996 (destination->*m_setter)(blendFunc(client, value(from), value(to), progress, property())); 998 997 } 999 998 }; … … 1023 1022 } 1024 1023 1025 class PropertyWrapperShadow : public AnimationPropertyWrapperBase {1026 WTF_MAKE_FAST_ALLOCATED; 1027 public: 1028 PropertyWrapperShadow(CSSPropertyID prop , const ShadowData* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(std::unique_ptr<ShadowData>, bool))1029 : AnimationPropertyWrapperBase(prop )1024 class PropertyWrapperShadow final : public AnimationPropertyWrapperBase { 1025 WTF_MAKE_FAST_ALLOCATED; 1026 public: 1027 PropertyWrapperShadow(CSSPropertyID property, const ShadowData* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(std::unique_ptr<ShadowData>, bool)) 1028 : AnimationPropertyWrapperBase(property) 1030 1029 , m_getter(getter) 1031 1030 , m_setter(setter) … … 1033 1032 } 1034 1033 1035 bool equals(const RenderStyle* a, const RenderStyle* b) const override 1034 private: 1035 bool equals(const RenderStyle* a, const RenderStyle* b) const final 1036 1036 { 1037 1037 if (a == b) … … 1062 1062 } 1063 1063 1064 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override1065 { 1066 const ShadowData* shadowA = (a->*m_getter)();1067 const ShadowData* shadowB = (b->*m_getter)();1068 1069 int fromLength = shadowListLength( shadowA);1070 int toLength = shadowListLength( shadowB);1064 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 1065 { 1066 const ShadowData* fromShadow = (from->*m_getter)(); 1067 const ShadowData* toShadow = (to->*m_getter)(); 1068 1069 int fromLength = shadowListLength(fromShadow); 1070 int toLength = shadowListLength(toShadow); 1071 1071 1072 1072 if (fromLength == toLength || (fromLength <= 1 && toLength <= 1)) { 1073 (d st->*m_setter)(blendSimpleOrMatchedShadowLists(anim, progress, shadowA, shadowB), false);1073 (destination->*m_setter)(blendSimpleOrMatchedShadowLists(client, progress, fromShadow, toShadow), false); 1074 1074 return; 1075 1075 } 1076 1076 1077 (d st->*m_setter)(blendMismatchedShadowLists(anim, progress, shadowA, shadowB, fromLength, toLength), false);1077 (destination->*m_setter)(blendMismatchedShadowLists(client, progress, fromShadow, toShadow, fromLength, toLength), false); 1078 1078 } 1079 1079 … … 1086 1086 #endif 1087 1087 1088 private: 1089 std::unique_ptr<ShadowData> blendSimpleOrMatchedShadowLists(const CSSPropertyBlendingClient* anim, double progress, const ShadowData* shadowA, const ShadowData* shadowB) const 1088 std::unique_ptr<ShadowData> blendSimpleOrMatchedShadowLists(const CSSPropertyBlendingClient* client, double progress, const ShadowData* shadowA, const ShadowData* shadowB) const 1090 1089 { 1091 1090 std::unique_ptr<ShadowData> newShadowData; … … 1096 1095 const ShadowData* dstShadow = shadowForBlending(shadowB, shadowA); 1097 1096 1098 std::unique_ptr<ShadowData> blendedShadow = blendFunc( anim, srcShadow, dstShadow, progress);1097 std::unique_ptr<ShadowData> blendedShadow = blendFunc(client, srcShadow, dstShadow, progress); 1099 1098 ShadowData* blendedShadowPtr = blendedShadow.get(); 1100 1099 … … 1113 1112 } 1114 1113 1115 std::unique_ptr<ShadowData> blendMismatchedShadowLists(const CSSPropertyBlendingClient* anim, double progress, const ShadowData* shadowA, const ShadowData* shadowB, int fromLength, int toLength) const1114 std::unique_ptr<ShadowData> blendMismatchedShadowLists(const CSSPropertyBlendingClient* client, double progress, const ShadowData* shadowA, const ShadowData* shadowB, int fromLength, int toLength) const 1116 1115 { 1117 1116 // The shadows in ShadowData are stored in reverse order, so when animating mismatched lists, … … 1139 1138 const ShadowData* dstShadow = shadowForBlending(toShadow, fromShadow); 1140 1139 1141 std::unique_ptr<ShadowData> blendedShadow = blendFunc( anim, srcShadow, dstShadow, progress);1140 std::unique_ptr<ShadowData> blendedShadow = blendFunc(client, srcShadow, dstShadow, progress); 1142 1141 // Insert at the start of the list to preserve the order. 1143 1142 blendedShadow->setNext(WTFMove(newShadowData)); … … 1152 1151 }; 1153 1152 1154 class PropertyWrapperMaybeInvalidColor : public AnimationPropertyWrapperBase {1155 WTF_MAKE_FAST_ALLOCATED; 1156 public: 1157 PropertyWrapperMaybeInvalidColor(CSSPropertyID prop , const Color& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&))1158 : AnimationPropertyWrapperBase(prop )1153 class PropertyWrapperMaybeInvalidColor final : public AnimationPropertyWrapperBase { 1154 WTF_MAKE_FAST_ALLOCATED; 1155 public: 1156 PropertyWrapperMaybeInvalidColor(CSSPropertyID property, const Color& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&)) 1157 : AnimationPropertyWrapperBase(property) 1159 1158 , m_getter(getter) 1160 1159 , m_setter(setter) … … 1162 1161 } 1163 1162 1164 bool equals(const RenderStyle* a, const RenderStyle* b) const override 1163 private: 1164 bool equals(const RenderStyle* a, const RenderStyle* b) const final 1165 1165 { 1166 1166 if (a == b) … … 1183 1183 } 1184 1184 1185 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override1186 { 1187 Color fromColor = value( a);1188 Color toColor = value( b);1185 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 1186 { 1187 Color fromColor = value(from); 1188 Color toColor = value(to); 1189 1189 1190 1190 if (!fromColor.isValid() && !toColor.isValid()) … … 1192 1192 1193 1193 if (!fromColor.isValid()) 1194 fromColor = a->color();1194 fromColor = from->color(); 1195 1195 if (!toColor.isValid()) 1196 toColor = b->color();1197 (d st->*m_setter)(blendFunc(anim, fromColor, toColor, progress));1198 } 1199 1200 Color value(const RenderStyle* a) const1201 { 1202 return ( a->*m_getter)();1196 toColor = to->color(); 1197 (destination->*m_setter)(blendFunc(client, fromColor, toColor, progress)); 1198 } 1199 1200 Color value(const RenderStyle* style) const 1201 { 1202 return (style->*m_getter)(); 1203 1203 } 1204 1204 1205 1205 #if !LOG_DISABLED 1206 void logBlend(const RenderStyle* a, const RenderStyle* b, const RenderStyle* result, double progress) const final1206 void logBlend(const RenderStyle* from, const RenderStyle* to, const RenderStyle* result, double progress) const final 1207 1207 { 1208 1208 // FIXME: better logging. 1209 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value( a) << " to " << value(b) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(result));1209 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(result)); 1210 1210 } 1211 1211 #endif 1212 1212 1213 private:1214 1213 const Color& (RenderStyle::*m_getter)() const; 1215 1214 void (RenderStyle::*m_setter)(const Color&); … … 1218 1217 1219 1218 enum MaybeInvalidColorTag { MaybeInvalidColor }; 1220 class PropertyWrapperVisitedAffectedColor : public AnimationPropertyWrapperBase { 1221 WTF_MAKE_FAST_ALLOCATED; 1222 public: 1223 PropertyWrapperVisitedAffectedColor(CSSPropertyID prop, const Color& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&), const Color& (RenderStyle::*visitedGetter)() const, void (RenderStyle::*visitedSetter)(const Color&)) 1224 : AnimationPropertyWrapperBase(prop) 1225 , m_wrapper(makeUnique<PropertyWrapper<const Color&>>(prop, getter, setter)) 1226 , m_visitedWrapper(makeUnique<PropertyWrapper<const Color&>>(prop, visitedGetter, visitedSetter)) 1227 { 1228 } 1229 PropertyWrapperVisitedAffectedColor(CSSPropertyID prop, MaybeInvalidColorTag, const Color& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&), const Color& (RenderStyle::*visitedGetter)() const, void (RenderStyle::*visitedSetter)(const Color&)) 1230 : AnimationPropertyWrapperBase(prop) 1231 , m_wrapper(makeUnique<PropertyWrapperMaybeInvalidColor>(prop, getter, setter)) 1232 , m_visitedWrapper(makeUnique<PropertyWrapperMaybeInvalidColor>(prop, visitedGetter, visitedSetter)) 1233 { 1234 } 1235 bool equals(const RenderStyle* a, const RenderStyle* b) const override 1219 class PropertyWrapperVisitedAffectedColor final : public AnimationPropertyWrapperBase { 1220 WTF_MAKE_FAST_ALLOCATED; 1221 public: 1222 PropertyWrapperVisitedAffectedColor(CSSPropertyID property, const Color& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&), const Color& (RenderStyle::*visitedGetter)() const, void (RenderStyle::*visitedSetter)(const Color&)) 1223 : AnimationPropertyWrapperBase(property) 1224 , m_wrapper(makeUnique<PropertyWrapper<const Color&>>(property, getter, setter)) 1225 , m_visitedWrapper(makeUnique<PropertyWrapper<const Color&>>(property, visitedGetter, visitedSetter)) 1226 { 1227 } 1228 PropertyWrapperVisitedAffectedColor(CSSPropertyID property, MaybeInvalidColorTag, const Color& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&), const Color& (RenderStyle::*visitedGetter)() const, void (RenderStyle::*visitedSetter)(const Color&)) 1229 : AnimationPropertyWrapperBase(property) 1230 , m_wrapper(makeUnique<PropertyWrapperMaybeInvalidColor>(property, getter, setter)) 1231 , m_visitedWrapper(makeUnique<PropertyWrapperMaybeInvalidColor>(property, visitedGetter, visitedSetter)) 1232 { 1233 } 1234 1235 private: 1236 bool equals(const RenderStyle* a, const RenderStyle* b) const final 1236 1237 { 1237 1238 return m_wrapper->equals(a, b) && m_visitedWrapper->equals(a, b); 1238 1239 } 1239 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override 1240 { 1241 m_wrapper->blend(anim, dst, a, b, progress); 1242 m_visitedWrapper->blend(anim, dst, a, b, progress); 1240 1241 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 1242 { 1243 m_wrapper->blend(client, destination, from, to, progress); 1244 m_visitedWrapper->blend(client, destination, from, to, progress); 1243 1245 } 1244 1246 1245 1247 #if !LOG_DISABLED 1246 void logBlend(const RenderStyle* a, const RenderStyle* b, const RenderStyle* result, double progress) const final1247 { 1248 m_wrapper->logBlend( a, b, result, progress);1249 m_visitedWrapper->logBlend( a, b, result, progress);1248 void logBlend(const RenderStyle* from, const RenderStyle* to, const RenderStyle* result, double progress) const final 1249 { 1250 m_wrapper->logBlend(from, to, result, progress); 1251 m_visitedWrapper->logBlend(from, to, result, progress); 1250 1252 } 1251 1253 #endif 1252 1254 1253 private:1254 1255 std::unique_ptr<AnimationPropertyWrapperBase> m_wrapper; 1255 1256 std::unique_ptr<AnimationPropertyWrapperBase> m_visitedWrapper; … … 1275 1276 virtual void logBlend(const FillLayer* result, const FillLayer*, const FillLayer*, double) const = 0; 1276 1277 #endif 1278 1277 1279 private: 1278 1280 CSSPropertyID m_property; … … 1290 1292 } 1291 1293 1294 protected: 1292 1295 bool equals(const FillLayer* a, const FillLayer* b) const override 1293 1296 { … … 1296 1299 if (!a || !b) 1297 1300 return false; 1298 return this->value(a) == this->value(b);1301 return value(a) == value(b); 1299 1302 } 1300 1303 … … 1305 1308 1306 1309 #if !LOG_DISABLED 1307 void logBlend(const FillLayer* result, const FillLayer* a, const FillLayer* b, double progress) const override1308 { 1309 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value( a) << " to " << value(b) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(result));1310 void logBlend(const FillLayer* result, const FillLayer* from, const FillLayer* to, double progress) const override 1311 { 1312 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(result)); 1310 1313 } 1311 1314 #endif 1312 1315 1313 pr otected:1316 private: 1314 1317 T (FillLayer::*m_getter)() const; 1315 1318 }; 1316 1319 1317 1320 template <typename T> 1318 class FillLayerPropertyWrapper : public FillLayerPropertyWrapperGetter<const T&> {1321 class FillLayerPropertyWrapper final : public FillLayerPropertyWrapperGetter<const T&> { 1319 1322 WTF_MAKE_FAST_ALLOCATED; 1320 1323 public: … … 1325 1328 } 1326 1329 1327 void blend(const CSSPropertyBlendingClient* anim, FillLayer* dst, const FillLayer* a, const FillLayer* b, double progress) const override 1328 { 1329 (dst->*m_setter)(blendFunc(anim, this->value(a), this->value(b), progress)); 1330 } 1331 1332 bool canInterpolate(const FillLayer* a, const FillLayer* b) const override 1333 { 1334 return canInterpolateLengthVariants(this->value(a), this->value(b)); 1330 private: 1331 void blend(const CSSPropertyBlendingClient* client, FillLayer* destination, const FillLayer* from, const FillLayer* to, double progress) const final 1332 { 1333 (destination->*this->m_setter)(blendFunc(client, this->value(from), this->value(to), progress)); 1334 } 1335 1336 bool canInterpolate(const FillLayer* from, const FillLayer* to) const final 1337 { 1338 return canInterpolateLengthVariants(this->value(from), this->value(to)); 1335 1339 } 1336 1340 1337 1341 #if !LOG_DISABLED 1338 void logBlend(const FillLayer* result, const FillLayer* a, const FillLayer* b, double progress) const override1342 void logBlend(const FillLayer* result, const FillLayer* from, const FillLayer* to, double progress) const final 1339 1343 { 1340 1344 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(FillLayerPropertyWrapperGetter<const T&>::property()) 1341 << " from " << FillLayerPropertyWrapperGetter<const T&>::value( a)1342 << " to " << FillLayerPropertyWrapperGetter<const T&>::value( b)1345 << " from " << FillLayerPropertyWrapperGetter<const T&>::value(from) 1346 << " to " << FillLayerPropertyWrapperGetter<const T&>::value(to) 1343 1347 << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << FillLayerPropertyWrapperGetter<const T&>::value(result)); 1344 1348 } 1345 1349 #endif 1346 1350 1347 protected:1348 1351 void (FillLayer::*m_setter)(T); 1349 1352 }; 1350 1353 1351 class FillLayerPositionPropertyWrapper : public FillLayerPropertyWrapperGetter<const Length&> {1354 class FillLayerPositionPropertyWrapper final : public FillLayerPropertyWrapperGetter<const Length&> { 1352 1355 WTF_MAKE_FAST_ALLOCATED; 1353 1356 public: … … 1361 1364 } 1362 1365 1363 bool equals(const FillLayer* a, const FillLayer* b) const override 1366 private: 1367 bool equals(const FillLayer* a, const FillLayer* b) const final 1364 1368 { 1365 1369 if (a == b) … … 1368 1372 return false; 1369 1373 1370 auto fromLength = this->value(a);1371 auto toLength = this->value(b);1374 auto fromLength = value(a); 1375 auto toLength = value(b); 1372 1376 1373 1377 Edge fromEdge = (a->*m_originGetter)(); … … 1377 1381 } 1378 1382 1379 void blend(const CSSPropertyBlendingClient* anim, FillLayer* dst, const FillLayer* a, const FillLayer* b, double progress) const override1380 { 1381 auto fromLength = this->value(a);1382 auto toLength = this->value(b);1383 void blend(const CSSPropertyBlendingClient* client, FillLayer* destination, const FillLayer* from, const FillLayer* to, double progress) const final 1384 { 1385 auto fromLength = value(from); 1386 auto toLength = value(to); 1383 1387 1384 Edge fromEdge = ( a->*m_originGetter)();1385 Edge toEdge = ( b->*m_originGetter)();1388 Edge fromEdge = (from->*m_originGetter)(); 1389 Edge toEdge = (to->*m_originGetter)(); 1386 1390 1387 1391 if (fromEdge != toEdge) { … … 1391 1395 else if (toEdge == m_farEdge) { 1392 1396 toLength = convertTo100PercentMinusLength(toLength); 1393 (d st->*m_originSetter)(fromEdge); // Now we have a calc(100% - l), it's relative to the left/top edge.1397 (destination->*m_originSetter)(fromEdge); // Now we have a calc(100% - l), it's relative to the left/top edge. 1394 1398 } 1395 1399 } 1396 1400 1397 (d st->*m_lengthSetter)(blendFunc(anim, fromLength, toLength, progress));1401 (destination->*m_lengthSetter)(blendFunc(client, fromLength, toLength, progress)); 1398 1402 } 1399 1403 1400 1404 #if !LOG_DISABLED 1401 void logBlend(const FillLayer* result, const FillLayer* a, const FillLayer* b, double progress) const override1402 { 1403 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value( a) << " to " << value(b) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(result));1405 void logBlend(const FillLayer* result, const FillLayer* from, const FillLayer* to, double progress) const final 1406 { 1407 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(result)); 1404 1408 } 1405 1409 #endif 1406 1410 1407 protected:1408 1411 void (FillLayer::*m_lengthSetter)(Length); 1409 1412 Edge (FillLayer::*m_originGetter)() const; … … 1422 1425 } 1423 1426 1424 void blend(const CSSPropertyBlendingClient* anim, FillLayer* dst, const FillLayer* a, const FillLayer* b, double progress) const override 1425 { 1426 (dst->*m_setter)(blendFunc(anim, this->value(a), this->value(b), progress)); 1427 private: 1428 void blend(const CSSPropertyBlendingClient* client, FillLayer* destination, const FillLayer* from, const FillLayer* to, double progress) const final 1429 { 1430 (destination->*this->m_setter)(blendFunc(client, this->value(from), this->value(to), progress)); 1427 1431 } 1428 1432 1429 1433 #if !LOG_DISABLED 1430 void logBlend(const FillLayer* result, const FillLayer* a, const FillLayer* b, double progress) const override1434 void logBlend(const FillLayer* result, const FillLayer* from, const FillLayer* to, double progress) const override 1431 1435 { 1432 1436 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(FillLayerPropertyWrapperGetter<T*>::property()) 1433 << " from " << FillLayerPropertyWrapperGetter<T*>::value( a)1434 << " to " << FillLayerPropertyWrapperGetter<T*>::value( b)1437 << " from " << FillLayerPropertyWrapperGetter<T*>::value(from) 1438 << " to " << FillLayerPropertyWrapperGetter<T*>::value(to) 1435 1439 << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << FillLayerPropertyWrapperGetter<T*>::value(result)); 1436 1440 } 1437 1441 #endif 1438 1442 1439 protected:1440 1443 void (FillLayer::*m_setter)(RefPtr<T>&&); 1441 1444 }; 1442 1445 1443 class FillLayerStyleImagePropertyWrapper : public FillLayerRefCountedPropertyWrapper<StyleImage> {1446 class FillLayerStyleImagePropertyWrapper final : public FillLayerRefCountedPropertyWrapper<StyleImage> { 1444 1447 WTF_MAKE_FAST_ALLOCATED; 1445 1448 public: … … 1449 1452 } 1450 1453 1451 bool equals(const FillLayer* a, const FillLayer* b) const override 1454 private: 1455 bool equals(const FillLayer* a, const FillLayer* b) const final 1452 1456 { 1453 1457 if (a == b) … … 1455 1459 if (!a || !b) 1456 1460 return false; 1457 return arePointingToEqualData( this->value(a), this->value(b));1461 return arePointingToEqualData(value(a), value(b)); 1458 1462 } 1459 1463 1460 1464 #if !LOG_DISABLED 1461 void logBlend(const FillLayer* result, const FillLayer* a, const FillLayer* b, double progress) const override1462 { 1463 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value( a) << " to " << value(b) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(result));1465 void logBlend(const FillLayer* result, const FillLayer* from, const FillLayer* to, double progress) const final 1466 { 1467 LOG_WITH_STREAM(Animations, stream << " blending " << getPropertyName(property()) << " from " << value(from) << " to " << value(to) << " at " << TextStream::FormatNumberRespectingIntegers(progress) << " -> " << value(result)); 1464 1468 } 1465 1469 #endif 1466 1470 }; 1467 1471 1468 class FillLayersPropertyWrapper : public AnimationPropertyWrapperBase {1472 class FillLayersPropertyWrapper final : public AnimationPropertyWrapperBase { 1469 1473 WTF_MAKE_FAST_ALLOCATED; 1470 1474 public: … … 1499 1503 } 1500 1504 1501 bool equals(const RenderStyle* a, const RenderStyle* b) const override 1505 private: 1506 bool equals(const RenderStyle* a, const RenderStyle* b) const final 1502 1507 { 1503 1508 if (a == b) … … 1520 1525 } 1521 1526 1522 bool canInterpolate(const RenderStyle* a, const RenderStyle* b) const override1523 { 1524 auto* fromLayer = &( a->*m_layersGetter)();1525 auto* toLayer = &( b->*m_layersGetter)();1527 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const final 1528 { 1529 auto* fromLayer = &(from->*m_layersGetter)(); 1530 auto* toLayer = &(to->*m_layersGetter)(); 1526 1531 1527 1532 while (fromLayer && toLayer) { … … 1536 1541 } 1537 1542 1538 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override1539 { 1540 auto* aLayer = &(a->*m_layersGetter)();1541 auto* bLayer = &(b->*m_layersGetter)();1542 auto* dstLayer = &(d st->*m_layersAccessor)();1543 1544 while ( aLayer && bLayer && dstLayer) {1545 m_fillLayerPropertyWrapper->blend( anim, dstLayer, aLayer, bLayer, progress);1546 aLayer = aLayer->next();1547 bLayer = bLayer->next();1543 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 1544 { 1545 auto* fromLayer = &(from->*m_layersGetter)(); 1546 auto* toLayer = &(to->*m_layersGetter)(); 1547 auto* dstLayer = &(destination->*m_layersAccessor)(); 1548 1549 while (fromLayer && toLayer && dstLayer) { 1550 m_fillLayerPropertyWrapper->blend(client, dstLayer, fromLayer, toLayer, progress); 1551 fromLayer = fromLayer->next(); 1552 toLayer = toLayer->next(); 1548 1553 dstLayer = dstLayer->next(); 1549 1554 } … … 1553 1558 void logBlend(const RenderStyle* from, const RenderStyle* to, const RenderStyle* result, double progress) const final 1554 1559 { 1555 auto* aLayer = &(from->*m_layersGetter)();1556 auto* bLayer = &(to->*m_layersGetter)();1560 auto* fromLayer = &(from->*m_layersGetter)(); 1561 auto* toLayer = &(to->*m_layersGetter)(); 1557 1562 auto* dstLayer = &(result->*m_layersGetter)(); 1558 1563 1559 while ( aLayer && bLayer && dstLayer) {1560 m_fillLayerPropertyWrapper->logBlend(dstLayer, aLayer, bLayer, progress);1561 aLayer = aLayer->next();1562 bLayer = bLayer->next();1564 while (fromLayer && toLayer && dstLayer) { 1565 m_fillLayerPropertyWrapper->logBlend(dstLayer, fromLayer, toLayer, progress); 1566 fromLayer = fromLayer->next(); 1567 toLayer = toLayer->next(); 1563 1568 dstLayer = dstLayer->next(); 1564 1569 } … … 1566 1571 #endif 1567 1572 1568 private:1569 1573 std::unique_ptr<FillLayerAnimationPropertyWrapperBase> m_fillLayerPropertyWrapper; 1570 1571 1574 LayersGetter m_layersGetter; 1572 1575 LayersAccessor m_layersAccessor; 1573 1576 }; 1574 1577 1575 class ShorthandPropertyWrapper : public AnimationPropertyWrapperBase {1578 class ShorthandPropertyWrapper final : public AnimationPropertyWrapperBase { 1576 1579 WTF_MAKE_FAST_ALLOCATED; 1577 1580 public: … … 1582 1585 } 1583 1586 1584 bool isShorthandWrapper() const override { return true; } 1585 1586 bool equals(const RenderStyle* a, const RenderStyle* b) const override 1587 bool isShorthandWrapper() const final { return true; } 1588 1589 const Vector<AnimationPropertyWrapperBase*>& propertyWrappers() const { return m_propertyWrappers; } 1590 1591 private: 1592 bool equals(const RenderStyle* a, const RenderStyle* b) const final 1587 1593 { 1588 1594 if (a == b) … … 1598 1604 } 1599 1605 1600 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override1606 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 1601 1607 { 1602 1608 for (auto& wrapper : m_propertyWrappers) 1603 wrapper->blend( anim, dst, a, b, progress);1609 wrapper->blend(client, destination, from, to, progress); 1604 1610 } 1605 1611 1606 1612 #if !LOG_DISABLED 1607 void logBlend(const RenderStyle* a, const RenderStyle* b, const RenderStyle* dst, double progress) const final1613 void logBlend(const RenderStyle* from, const RenderStyle* to, const RenderStyle* destination, double progress) const final 1608 1614 { 1609 1615 for (auto& wrapper : m_propertyWrappers) 1610 wrapper->logBlend( a, b, dst, progress);1616 wrapper->logBlend(from, to, destination, progress); 1611 1617 } 1612 1618 #endif 1613 1619 1614 const Vector<AnimationPropertyWrapperBase*>& propertyWrappers() const { return m_propertyWrappers; }1615 1616 private:1617 1620 Vector<AnimationPropertyWrapperBase*> m_propertyWrappers; 1618 1621 }; 1619 1622 1620 class PropertyWrapperFlex : public AnimationPropertyWrapperBase {1623 class PropertyWrapperFlex final : public AnimationPropertyWrapperBase { 1621 1624 WTF_MAKE_FAST_ALLOCATED; 1622 1625 public: … … 1626 1629 } 1627 1630 1628 bool equals(const RenderStyle* a, const RenderStyle* b) const override 1631 private: 1632 bool equals(const RenderStyle* a, const RenderStyle* b) const final 1629 1633 { 1630 1634 if (a == b) … … 1636 1640 } 1637 1641 1638 bool canInterpolate(const RenderStyle* a, const RenderStyle* b) const override1639 { 1640 return a->flexGrow() != b->flexGrow() && a->flexShrink() != b->flexShrink() && canInterpolateLengths(a->flexBasis(), b->flexBasis(), false);1641 } 1642 1643 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override1644 { 1645 d st->setFlexBasis(blendFunc(anim, a->flexBasis(), b->flexBasis(), progress));1646 d st->setFlexGrow(blendFunc(anim, a->flexGrow(), b->flexGrow(), progress));1647 d st->setFlexShrink(blendFunc(anim, a->flexShrink(), b->flexShrink(), progress));1642 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const final 1643 { 1644 return from->flexGrow() != to->flexGrow() && from->flexShrink() != to->flexShrink() && canInterpolateLengths(from->flexBasis(), to->flexBasis(), false); 1645 } 1646 1647 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 1648 { 1649 destination->setFlexBasis(blendFunc(client, from->flexBasis(), to->flexBasis(), progress)); 1650 destination->setFlexGrow(blendFunc(client, from->flexGrow(), to->flexGrow(), progress)); 1651 destination->setFlexShrink(blendFunc(client, from->flexShrink(), to->flexShrink(), progress)); 1648 1652 } 1649 1653 … … 1657 1661 }; 1658 1662 1659 class PropertyWrapperSVGPaint : public AnimationPropertyWrapperBase {1660 WTF_MAKE_FAST_ALLOCATED; 1661 public: 1662 PropertyWrapperSVGPaint(CSSPropertyID prop , SVGPaintType (RenderStyle::*paintTypeGetter)() const, Color (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&))1663 : AnimationPropertyWrapperBase(prop )1663 class PropertyWrapperSVGPaint final : public AnimationPropertyWrapperBase { 1664 WTF_MAKE_FAST_ALLOCATED; 1665 public: 1666 PropertyWrapperSVGPaint(CSSPropertyID property, SVGPaintType (RenderStyle::*paintTypeGetter)() const, Color (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&)) 1667 : AnimationPropertyWrapperBase(property) 1664 1668 , m_paintTypeGetter(paintTypeGetter) 1665 1669 , m_getter(getter) … … 1668 1672 } 1669 1673 1670 bool equals(const RenderStyle* a, const RenderStyle* b) const override 1674 private: 1675 bool equals(const RenderStyle* a, const RenderStyle* b) const final 1671 1676 { 1672 1677 if (a == b) … … 1698 1703 } 1699 1704 1700 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const override1701 { 1702 if (( a->*m_paintTypeGetter)() != SVGPaintType::RGBColor1703 || ( b->*m_paintTypeGetter)() != SVGPaintType::RGBColor)1705 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 1706 { 1707 if ((from->*m_paintTypeGetter)() != SVGPaintType::RGBColor 1708 || (to->*m_paintTypeGetter)() != SVGPaintType::RGBColor) 1704 1709 return; 1705 1710 1706 Color fromColor = ( a->*m_getter)();1707 Color toColor = ( b->*m_getter)();1711 Color fromColor = (from->*m_getter)(); 1712 Color toColor = (to->*m_getter)(); 1708 1713 1709 1714 if (!fromColor.isValid() && !toColor.isValid()) … … 1714 1719 if (!toColor.isValid()) 1715 1720 toColor = Color(); 1716 (d st->*m_setter)(blendFunc(anim, fromColor, toColor, progress));1721 (destination->*m_setter)(blendFunc(client, fromColor, toColor, progress)); 1717 1722 } 1718 1723 … … 1725 1730 #endif 1726 1731 1727 private:1728 1732 SVGPaintType (RenderStyle::*m_paintTypeGetter)() const; 1729 1733 Color (RenderStyle::*m_getter)() const; … … 1731 1735 }; 1732 1736 1733 class PropertyWrapperFontStyle : public PropertyWrapper<Optional<FontSelectionValue>> {1737 class PropertyWrapperFontStyle final : public PropertyWrapper<Optional<FontSelectionValue>> { 1734 1738 WTF_MAKE_FAST_ALLOCATED; 1735 1739 public: … … 1739 1743 } 1740 1744 1741 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const override 1745 private: 1746 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const final 1742 1747 { 1743 1748 return from->fontItalic() && to->fontItalic() && from->fontDescription().fontStyleAxis() == FontStyleAxis::slnt && to->fontDescription().fontStyleAxis() == FontStyleAxis::slnt; 1744 1749 } 1745 1750 1746 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* from, const RenderStyle* to, double progress) const override1751 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 1747 1752 { 1748 1753 auto discrete = !canInterpolate(from, to); … … 1756 1761 auto blendedFontItalic = progress < 0.5 ? fromFontItalic : toFontItalic; 1757 1762 if (!discrete) 1758 blendedFontItalic = blendFunc( anim, fromFontItalic, toFontItalic, progress);1759 1760 FontSelector* currentFontSelector = d st->fontCascade().fontSelector();1761 auto description = d st->fontDescription();1763 blendedFontItalic = blendFunc(client, fromFontItalic, toFontItalic, progress); 1764 1765 FontSelector* currentFontSelector = destination->fontCascade().fontSelector(); 1766 auto description = destination->fontDescription(); 1762 1767 description.setItalic(blendedFontItalic); 1763 1768 description.setFontStyleAxis(blendedStyleAxis); 1764 d st->setFontDescription(WTFMove(description));1765 d st->fontCascade().update(currentFontSelector);1769 destination->setFontDescription(WTFMove(description)); 1770 destination->fontCascade().update(currentFontSelector); 1766 1771 } 1767 1772 }; 1768 1773 1769 1774 template <typename T> 1770 class AutoPropertyWrapper : public PropertyWrapper<T> {1771 WTF_MAKE_FAST_ALLOCATED; 1772 public: 1773 AutoPropertyWrapper(CSSPropertyID prop , T (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T), bool (RenderStyle::*autoGetter)() const, void (RenderStyle::*autoSetter)(), Optional<T> minValue = WTF::nullopt)1774 : PropertyWrapper<T>(prop , getter, setter)1775 class AutoPropertyWrapper final : public PropertyWrapper<T> { 1776 WTF_MAKE_FAST_ALLOCATED; 1777 public: 1778 AutoPropertyWrapper(CSSPropertyID property, T (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T), bool (RenderStyle::*autoGetter)() const, void (RenderStyle::*autoSetter)(), Optional<T> minValue = WTF::nullopt) 1779 : PropertyWrapper<T>(property, getter, setter) 1775 1780 , m_autoGetter(autoGetter) 1776 1781 , m_autoSetter(autoSetter) … … 1779 1784 } 1780 1785 1781 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const override 1786 private: 1787 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const final 1782 1788 { 1783 1789 return !(from->*m_autoGetter)() && !(to->*m_autoGetter)(); 1784 1790 } 1785 1791 1786 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* from, const RenderStyle* to, double progress) const override1787 { 1788 auto blendedValue = blendFunc( anim, this->value(from), this->value(to), progress);1789 if ( this->m_minValue)1790 blendedValue = blendedValue > * this->m_minValue ? blendedValue : *this->m_minValue;1791 (d st->*this->m_setter)(blendedValue);1792 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 1793 { 1794 auto blendedValue = blendFunc(client, this->value(from), this->value(to), progress); 1795 if (m_minValue) 1796 blendedValue = blendedValue > *m_minValue ? blendedValue : *m_minValue; 1797 (destination->*this->m_setter)(blendedValue); 1792 1798 1793 1799 if (canInterpolate(from, to)) … … 1797 1803 if (!progress) { 1798 1804 if ((from->*m_autoGetter)()) 1799 (d st->*m_autoSetter)();1805 (destination->*m_autoSetter)(); 1800 1806 } else { 1801 1807 if ((to->*m_autoGetter)()) 1802 (dst->*m_autoSetter)(); 1803 } 1804 } 1805 1806 private: 1808 (destination->*m_autoSetter)(); 1809 } 1810 } 1811 1807 1812 bool (RenderStyle::*m_autoGetter)() const; 1808 1813 void (RenderStyle::*m_autoSetter)(); … … 1813 1818 WTF_MAKE_FAST_ALLOCATED; 1814 1819 public: 1815 NonNegativeFloatPropertyWrapper(CSSPropertyID prop, float (RenderStyle::*getter)() const, void (RenderStyle::*setter)(float)) 1816 : PropertyWrapper<float>(prop, getter, setter) 1817 { 1818 } 1819 1820 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* from, const RenderStyle* to, double progress) const override 1821 { 1822 auto blendedValue = blendFunc(anim, value(from), value(to), progress); 1823 (dst->*m_setter)(blendedValue > 0 ? blendedValue : 0); 1824 } 1825 }; 1826 1827 class PerspectiveWrapper : public NonNegativeFloatPropertyWrapper { 1820 NonNegativeFloatPropertyWrapper(CSSPropertyID property, float (RenderStyle::*getter)() const, void (RenderStyle::*setter)(float)) 1821 : PropertyWrapper<float>(property, getter, setter) 1822 { 1823 } 1824 1825 protected: 1826 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const override 1827 { 1828 auto blendedValue = blendFunc(client, value(from), value(to), progress); 1829 (destination->*m_setter)(blendedValue > 0 ? blendedValue : 0); 1830 } 1831 }; 1832 1833 class PerspectiveWrapper final : public NonNegativeFloatPropertyWrapper { 1828 1834 WTF_MAKE_FAST_ALLOCATED; 1829 1835 public: … … 1833 1839 } 1834 1840 1835 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const override 1841 private: 1842 bool canInterpolate(const RenderStyle* from, const RenderStyle* to) const final 1836 1843 { 1837 1844 if (!from->hasPerspective() || !to->hasPerspective()) … … 1840 1847 } 1841 1848 1842 void blend(const CSSPropertyBlendingClient* anim, RenderStyle* dst, const RenderStyle* from, const RenderStyle* to, double progress) const override1849 void blend(const CSSPropertyBlendingClient* client, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) const final 1843 1850 { 1844 1851 if (!canInterpolate(from, to)) 1845 (d st->*m_setter)(progress ? value(to) : value(from));1852 (destination->*m_setter)(progress ? value(to) : value(from)); 1846 1853 else 1847 NonNegativeFloatPropertyWrapper::blend( anim, dst, from, to, progress);1848 } 1849 }; 1850 1851 class CSSPropertyAnimationWrapperMap {1854 NonNegativeFloatPropertyWrapper::blend(client, destination, from, to, progress); 1855 } 1856 }; 1857 1858 class CSSPropertyAnimationWrapperMap final { 1852 1859 WTF_MAKE_FAST_ALLOCATED; 1853 1860 public: … … 2239 2246 } 2240 2247 2241 // Returns true if we need to start animation timers 2242 void CSSPropertyAnimation::blendProperties(const CSSPropertyBlendingClient* anim, CSSPropertyID prop, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) 2243 { 2244 ASSERT(prop != CSSPropertyInvalid); 2245 2246 AnimationPropertyWrapperBase* wrapper = CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(prop); 2248 void CSSPropertyAnimation::blendProperties(const CSSPropertyBlendingClient* client, CSSPropertyID property, RenderStyle* destination, const RenderStyle* from, const RenderStyle* to, double progress) 2249 { 2250 ASSERT(property != CSSPropertyInvalid); 2251 2252 AnimationPropertyWrapperBase* wrapper = CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(property); 2247 2253 if (wrapper) { 2248 2254 // https://drafts.csswg.org/web-animations-1/#discrete 2249 2255 // The property’s values cannot be meaningfully combined, thus it is not additive and 2250 2256 // interpolation swaps from Va to Vb at 50% (p=0.5). 2251 if (!wrapper->canInterpolate( a, b))2257 if (!wrapper->canInterpolate(from, to)) 2252 2258 progress = progress < 0.5 ? 0 : 1; 2253 wrapper->blend( anim, dst, a, b, progress);2259 wrapper->blend(client, destination, from, to, progress); 2254 2260 #if !LOG_DISABLED 2255 wrapper->logBlend( a, b, dst, progress);2261 wrapper->logBlend(from, to, destination, progress); 2256 2262 #endif 2257 2263 } 2258 2264 } 2259 2265 2260 bool CSSPropertyAnimation::isPropertyAnimatable(CSSPropertyID prop )2261 { 2262 return CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(prop );2263 } 2264 2265 bool CSSPropertyAnimation::animationOfPropertyIsAccelerated(CSSPropertyID prop )2266 { 2267 AnimationPropertyWrapperBase* wrapper = CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(prop );2266 bool CSSPropertyAnimation::isPropertyAnimatable(CSSPropertyID property) 2267 { 2268 return CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(property); 2269 } 2270 2271 bool CSSPropertyAnimation::animationOfPropertyIsAccelerated(CSSPropertyID property) 2272 { 2273 AnimationPropertyWrapperBase* wrapper = CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(property); 2268 2274 return wrapper ? wrapper->animationIsAccelerated() : false; 2269 2275 } … … 2281 2287 } 2282 2288 2283 bool CSSPropertyAnimation::propertiesEqual(CSSPropertyID prop , const RenderStyle* a, const RenderStyle* b)2284 { 2285 AnimationPropertyWrapperBase* wrapper = CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(prop );2289 bool CSSPropertyAnimation::propertiesEqual(CSSPropertyID property, const RenderStyle* a, const RenderStyle* b) 2290 { 2291 AnimationPropertyWrapperBase* wrapper = CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(property); 2286 2292 if (wrapper) 2287 2293 return wrapper->equals(a, b); … … 2289 2295 } 2290 2296 2291 bool CSSPropertyAnimation::canPropertyBeInterpolated(CSSPropertyID prop , const RenderStyle* a, const RenderStyle* b)2292 { 2293 AnimationPropertyWrapperBase* wrapper = CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(prop );2297 bool CSSPropertyAnimation::canPropertyBeInterpolated(CSSPropertyID property, const RenderStyle* from, const RenderStyle* to) 2298 { 2299 AnimationPropertyWrapperBase* wrapper = CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(property); 2294 2300 if (wrapper) 2295 return wrapper->canInterpolate( a, b);2301 return wrapper->canInterpolate(from, to); 2296 2302 return false; 2297 2303 }
Note: See TracChangeset
for help on using the changeset viewer.