Commit 96c79582 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Fold SVGAnimateElement::GetAnimatedPropertyType()

This has only one actual user - AnimatedPropertyTypeSupportsAddition()
which is only called when the animation has a target.
Since a test reads the type add GetAnimatedPropertyTypeForTesting().

Bug: 1017723
Change-Id: Iaada97a2d281c0067f73f44a80f9e84837ca951d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2403471Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#805853}
parent e36dd269
......@@ -215,11 +215,6 @@ void SVGAnimateElement::UpdateTargetProperty() {
ClearTargetProperty();
}
AnimatedPropertyType SVGAnimateElement::GetAnimatedPropertyType() const {
// TODO(fs): Should be possible to DCHECK targetElement() here instead.
return !targetElement() ? kAnimatedUnknown : type_;
}
bool SVGAnimateElement::HasValidAnimation() const {
if (AttributeName() == AnyQName())
return false;
......@@ -347,15 +342,14 @@ void SVGAnimateElement::CalculateAnimatedValue(
return;
DCHECK(percentage >= 0 && percentage <= 1);
DCHECK_NE(GetAnimatedPropertyType(), kAnimatedUnknown);
DCHECK_NE(type_, kAnimatedUnknown);
DCHECK(from_property_);
DCHECK_EQ(from_property_->GetType(), GetAnimatedPropertyType());
DCHECK_EQ(from_property_->GetType(), type_);
DCHECK(to_property_);
auto* result_animation_element = To<SVGAnimateElement>(result_element);
DCHECK(result_animation_element->animated_value_);
DCHECK_EQ(result_animation_element->GetAnimatedPropertyType(),
GetAnimatedPropertyType());
DCHECK_EQ(result_animation_element->type_, type_);
if (IsA<SVGSetElement>(*this))
percentage = 1;
......@@ -475,9 +469,9 @@ void SVGAnimateElement::ClearAnimatedType() {
}
void SVGAnimateElement::ApplyResultsToTarget() {
DCHECK_NE(GetAnimatedPropertyType(), kAnimatedUnknown);
DCHECK(animated_value_);
DCHECK(targetElement());
DCHECK_NE(type_, kAnimatedUnknown);
// We do update the style and the animation property independent of each
// other.
......@@ -507,8 +501,9 @@ void SVGAnimateElement::ApplyResultsToTarget() {
}
bool SVGAnimateElement::AnimatedPropertyTypeSupportsAddition() const {
DCHECK(targetElement());
// http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndProperties.
switch (GetAnimatedPropertyType()) {
switch (type_) {
case kAnimatedBoolean:
case kAnimatedEnumeration:
case kAnimatedPreserveAspectRatio:
......
......@@ -50,7 +50,9 @@ class CORE_EXPORT SVGAnimateElement : public SVGAnimationElement {
const Attribute&) const override;
const QualifiedName& AttributeName() const { return attribute_name_; }
AnimatedPropertyType GetAnimatedPropertyType() const;
AnimatedPropertyType GetAnimatedPropertyTypeForTesting() const {
return type_;
}
bool AnimatedPropertyTypeSupportsAddition() const;
protected:
......
......@@ -221,14 +221,14 @@ TEST(UnsafeSVGAttributeSanitizationTest, stringsShouldNotSupportAddition) {
element->SetAttributeName(xlink_names::kHrefAttr);
// Sanity check that xlink:href was identified as a "string" attribute
EXPECT_EQ(kAnimatedString, element->GetAnimatedPropertyType());
EXPECT_EQ(kAnimatedString, element->GetAnimatedPropertyTypeForTesting());
EXPECT_FALSE(element->AnimatedPropertyTypeSupportsAddition());
element->SetAttributeName(svg_names::kHrefAttr);
// Sanity check that href was identified as a "string" attribute
EXPECT_EQ(kAnimatedString, element->GetAnimatedPropertyType());
EXPECT_EQ(kAnimatedString, element->GetAnimatedPropertyTypeForTesting());
EXPECT_FALSE(element->AnimatedPropertyTypeSupportsAddition());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment