diff --git a/third_party/blink/renderer/core/svg/properties/svg_animated_property.h b/third_party/blink/renderer/core/svg/properties/svg_animated_property.h index 5295fdf4a024c..430b793431d0c 100644 --- a/third_party/blink/renderer/core/svg/properties/svg_animated_property.h +++ b/third_party/blink/renderer/core/svg/properties/svg_animated_property.h @@ -54,7 +54,6 @@ class SVGAnimatedPropertyBase : public GarbageCollectedMixin { virtual const SVGPropertyBase& BaseValueBase() const = 0; virtual bool IsAnimating() const = 0; - virtual SVGPropertyBase* CreateAnimatedValue() = 0; virtual void SetAnimatedValue(SVGPropertyBase*) = 0; virtual void AnimationEnded() = 0; @@ -142,10 +141,6 @@ class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase { return parse_status; } - SVGPropertyBase* CreateAnimatedValue() override { - return base_value_->Clone(); - } - void SetAnimatedValue(SVGPropertyBase* value) override { DCHECK_EQ(value->GetType(), Property::ClassType()); current_value_ = static_cast(value); diff --git a/third_party/blink/renderer/core/svg/svg_animate_element.cc b/third_party/blink/renderer/core/svg/svg_animate_element.cc index bd639e3f29229..a6e5a894e1a16 100644 --- a/third_party/blink/renderer/core/svg/svg_animate_element.cc +++ b/third_party/blink/renderer/core/svg/svg_animate_element.cc @@ -32,10 +32,20 @@ #include "third_party/blink/renderer/core/svg/animation/smil_animation_value.h" #include "third_party/blink/renderer/core/svg/properties/svg_animated_property.h" #include "third_party/blink/renderer/core/svg/properties/svg_property.h" +#include "third_party/blink/renderer/core/svg/svg_angle.h" #include "third_party/blink/renderer/core/svg/svg_animated_color.h" +#include "third_party/blink/renderer/core/svg/svg_boolean.h" +#include "third_party/blink/renderer/core/svg/svg_integer.h" +#include "third_party/blink/renderer/core/svg/svg_integer_optional_integer.h" #include "third_party/blink/renderer/core/svg/svg_length.h" #include "third_party/blink/renderer/core/svg/svg_length_list.h" #include "third_party/blink/renderer/core/svg/svg_number.h" +#include "third_party/blink/renderer/core/svg/svg_number_list.h" +#include "third_party/blink/renderer/core/svg/svg_number_optional_number.h" +#include "third_party/blink/renderer/core/svg/svg_path.h" +#include "third_party/blink/renderer/core/svg/svg_point_list.h" +#include "third_party/blink/renderer/core/svg/svg_preserve_aspect_ratio.h" +#include "third_party/blink/renderer/core/svg/svg_rect.h" #include "third_party/blink/renderer/core/svg/svg_string.h" #include "third_party/blink/renderer/core/xlink_names.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" @@ -233,6 +243,58 @@ SVGPropertyBase* SVGAnimateElement::CreatePropertyForAttributeAnimation( return target_property_->BaseValueBase().CloneForAnimation(value); } +SVGPropertyBase* SVGAnimateElement::CreateUnderlyingValueForAttributeAnimation() + const { + // SVG DOM animVal animation code-path. + DCHECK_NE(type_, kAnimatedTransformList); + DCHECK(target_property_); + const SVGPropertyBase& base_value = target_property_->BaseValueBase(); + switch (base_value.GetType()) { + case kAnimatedAngle: + return To(base_value).Clone(); + case kAnimatedBoolean: + return To(base_value).Clone(); + case kAnimatedEnumeration: + return To(base_value).Clone(); + case kAnimatedInteger: + return To(base_value).Clone(); + case kAnimatedIntegerOptionalInteger: + return To(base_value).Clone(); + case kAnimatedLength: + return To(base_value).Clone(); + case kAnimatedLengthList: + return To(base_value).Clone(); + case kAnimatedNumber: + return To(base_value).Clone(); + case kAnimatedNumberList: + return To(base_value).Clone(); + case kAnimatedNumberOptionalNumber: + return To(base_value).Clone(); + case kAnimatedPath: + return To(base_value).Clone(); + case kAnimatedPoints: + return To(base_value).Clone(); + case kAnimatedPreserveAspectRatio: + return To(base_value).Clone(); + case kAnimatedRect: + return To(base_value).Clone(); + case kAnimatedString: + return To(base_value).Clone(); + + // The following are either not animated or are not animated as + // attributeType=XML. handles the transform-list case. + case kAnimatedUnknown: + case kAnimatedColor: + case kAnimatedPoint: + case kAnimatedStringList: + case kAnimatedTransform: + case kAnimatedTransformList: + default: + NOTREACHED(); + return nullptr; + } +} + SVGPropertyBase* SVGAnimateElement::CreatePropertyForCSSAnimation( const String& value) const { // CSS properties animation code-path. @@ -416,24 +478,26 @@ bool SVGAnimateElement::CalculateFromAndByValues(const String& from_string, return true; } -SMILAnimationValue SVGAnimateElement::CreateAnimationValue() const { +SVGPropertyBase* SVGAnimateElement::CreateUnderlyingValueForAnimation() const { DCHECK(targetElement()); - SMILAnimationValue animation_value; if (IsAnimatingSVGDom()) { // SVG DOM animVal animation code-path. - animation_value.property_value = target_property_->CreateAnimatedValue(); - DCHECK_EQ(animation_value.property_value->GetType(), type_); - } else { - DCHECK(IsAnimatingCSSProperty()); - // Presentation attributes that have an SVG DOM representation should use - // the "SVG DOM" code-path (above.) - DCHECK(SVGElement::IsAnimatableCSSProperty(AttributeName())); - - // CSS properties animation code-path. - String base_value = - ComputeCSSPropertyValue(targetElement(), css_property_id_); - animation_value.property_value = CreatePropertyForCSSAnimation(base_value); + return CreateUnderlyingValueForAttributeAnimation(); } + DCHECK(IsAnimatingCSSProperty()); + // Presentation attributes that have an SVG DOM representation should use + // the "SVG DOM" code-path (above.) + DCHECK(SVGElement::IsAnimatableCSSProperty(AttributeName())); + + // CSS properties animation code-path. + String base_value = + ComputeCSSPropertyValue(targetElement(), css_property_id_); + return CreatePropertyForCSSAnimation(base_value); +} + +SMILAnimationValue SVGAnimateElement::CreateAnimationValue() const { + SMILAnimationValue animation_value; + animation_value.property_value = CreateUnderlyingValueForAnimation(); return animation_value; } diff --git a/third_party/blink/renderer/core/svg/svg_animate_element.h b/third_party/blink/renderer/core/svg/svg_animate_element.h index f39f766c3d25a..45c03044ded16 100644 --- a/third_party/blink/renderer/core/svg/svg_animate_element.h +++ b/third_party/blink/renderer/core/svg/svg_animate_element.h @@ -104,7 +104,9 @@ class CORE_EXPORT SVGAnimateElement : public SVGAnimationElement { void WillChangeAnimatedType(); void DidChangeAnimatedType(); + virtual SVGPropertyBase* CreateUnderlyingValueForAnimation() const; virtual SVGPropertyBase* ParseValue(const String&) const; + SVGPropertyBase* CreateUnderlyingValueForAttributeAnimation() const; SVGPropertyBase* CreatePropertyForAttributeAnimation(const String&) const; SVGPropertyBase* CreatePropertyForCSSAnimation(const String&) const; diff --git a/third_party/blink/renderer/core/svg/svg_animate_transform_element.cc b/third_party/blink/renderer/core/svg/svg_animate_transform_element.cc index 6c3111d931133..e6b4a638eb7a4 100644 --- a/third_party/blink/renderer/core/svg/svg_animate_transform_element.cc +++ b/third_party/blink/renderer/core/svg/svg_animate_transform_element.cc @@ -55,6 +55,12 @@ void SVGAnimateTransformElement::ResolveTargetProperty() { css_property_id_ = CSSPropertyID::kInvalid; } +SVGPropertyBase* SVGAnimateTransformElement::CreateUnderlyingValueForAnimation() + const { + DCHECK(IsAnimatingSVGDom()); + return To(target_property_->BaseValueBase()).Clone(); +} + SVGPropertyBase* SVGAnimateTransformElement::ParseValue( const String& value) const { DCHECK(IsAnimatingSVGDom()); diff --git a/third_party/blink/renderer/core/svg/svg_animate_transform_element.h b/third_party/blink/renderer/core/svg/svg_animate_transform_element.h index 7a5f0601ef584..7a42b36348cf9 100644 --- a/third_party/blink/renderer/core/svg/svg_animate_transform_element.h +++ b/third_party/blink/renderer/core/svg/svg_animate_transform_element.h @@ -40,6 +40,7 @@ class SVGAnimateTransformElement final : public SVGAnimateElement { void ParseAttribute(const AttributeModificationParams&) override; + SVGPropertyBase* CreateUnderlyingValueForAnimation() const override; SVGPropertyBase* ParseValue(const String&) const override; SVGTransformType transform_type_; diff --git a/third_party/blink/renderer/core/svg/svg_boolean.h b/third_party/blink/renderer/core/svg/svg_boolean.h index 9cf71b3548c3b..efa3622f649d2 100644 --- a/third_party/blink/renderer/core/svg/svg_boolean.h +++ b/third_party/blink/renderer/core/svg/svg_boolean.h @@ -34,6 +34,7 @@ #include "third_party/blink/renderer/core/svg/properties/svg_property_helper.h" #include "third_party/blink/renderer/core/svg/svg_parsing_error.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink { @@ -71,6 +72,13 @@ class SVGBoolean final : public SVGPropertyHelper { bool value_; }; +template <> +struct DowncastTraits { + static bool AllowFrom(const SVGPropertyBase& value) { + return value.GetType() == SVGBoolean::ClassType(); + } +}; + } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_BOOLEAN_H_ diff --git a/third_party/blink/renderer/core/svg/svg_enumeration.h b/third_party/blink/renderer/core/svg/svg_enumeration.h index d153bbad2fb66..9cad3aeb0ca97 100644 --- a/third_party/blink/renderer/core/svg/svg_enumeration.h +++ b/third_party/blink/renderer/core/svg/svg_enumeration.h @@ -35,6 +35,7 @@ #include "third_party/blink/renderer/core/svg/properties/svg_property.h" #include "third_party/blink/renderer/core/svg/svg_parsing_error.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink { @@ -115,6 +116,13 @@ class SVGEnumeration : public SVGPropertyBase { const SVGEnumerationMap& map_; }; +template <> +struct DowncastTraits { + static bool AllowFrom(const SVGPropertyBase& value) { + return value.GetType() == SVGEnumeration::ClassType(); + } +}; + #define DECLARE_SVG_ENUM_MAP(cpp_enum_type) \ template <> \ const SVGEnumerationMap& GetEnumerationMap() diff --git a/third_party/blink/renderer/core/svg/svg_preserve_aspect_ratio.h b/third_party/blink/renderer/core/svg/svg_preserve_aspect_ratio.h index 23512ad45a3b4..0b1ec3c27a766 100644 --- a/third_party/blink/renderer/core/svg/svg_preserve_aspect_ratio.h +++ b/third_party/blink/renderer/core/svg/svg_preserve_aspect_ratio.h @@ -23,6 +23,7 @@ #include "third_party/blink/renderer/core/svg/properties/svg_property_helper.h" #include "third_party/blink/renderer/core/svg/svg_parsing_error.h" +#include "third_party/blink/renderer/platform/wtf/casting.h" namespace gfx { class RectF; @@ -114,6 +115,13 @@ class SVGPreserveAspectRatio final SVGMeetOrSliceType meet_or_slice_; }; +template <> +struct DowncastTraits { + static bool AllowFrom(const SVGPropertyBase& value) { + return value.GetType() == SVGPreserveAspectRatio::ClassType(); + } +}; + } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_PRESERVE_ASPECT_RATIO_H_ diff --git a/third_party/blink/renderer/core/svg/svg_static_string_list.cc b/third_party/blink/renderer/core/svg/svg_static_string_list.cc index b05672a87d00a..443097d4550e3 100644 --- a/third_party/blink/renderer/core/svg/svg_static_string_list.cc +++ b/third_party/blink/renderer/core/svg/svg_static_string_list.cc @@ -61,11 +61,6 @@ bool SVGStaticStringList::IsAnimating() const { return false; } -SVGPropertyBase* SVGStaticStringList::CreateAnimatedValue() { - NOTREACHED(); - return nullptr; -} - void SVGStaticStringList::SetAnimatedValue(SVGPropertyBase*) { NOTREACHED(); } diff --git a/third_party/blink/renderer/core/svg/svg_static_string_list.h b/third_party/blink/renderer/core/svg/svg_static_string_list.h index bd08cf0737374..c6501b626d3b8 100644 --- a/third_party/blink/renderer/core/svg/svg_static_string_list.h +++ b/third_party/blink/renderer/core/svg/svg_static_string_list.h @@ -61,7 +61,6 @@ class SVGStaticStringList final : public GarbageCollected, // SVGAnimatedPropertyBase: const SVGPropertyBase& BaseValueBase() const override; bool IsAnimating() const override; - SVGPropertyBase* CreateAnimatedValue() override; void SetAnimatedValue(SVGPropertyBase*) override; void AnimationEnded() override; diff --git a/third_party/blink/renderer/core/svg/svg_string.h b/third_party/blink/renderer/core/svg/svg_string.h index 04deeed657442..b562b8d1980d3 100644 --- a/third_party/blink/renderer/core/svg/svg_string.h +++ b/third_party/blink/renderer/core/svg/svg_string.h @@ -34,6 +34,7 @@ #include "third_party/blink/renderer/core/svg/properties/svg_property.h" #include "third_party/blink/renderer/core/svg/svg_parsing_error.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink { @@ -79,6 +80,13 @@ class SVGString final : public SVGPropertyBase { String value_; }; +template <> +struct DowncastTraits { + static bool AllowFrom(const SVGPropertyBase& value) { + return value.GetType() == SVGString::ClassType(); + } +}; + } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_STRING_H_