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

Use CreatePropertyForCSSAnimation() directly where possible

There are a few cases where we know that calling
CreatePropertyForAnimation() will pick the CSS branch, so just call the
appropriate function directly.

Rename CreatePropertyForAnimation to ParseValue.

Bug: 1017723
Change-Id: I316da227a51b8ffd56e6a6b57b45910d836f3ede
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536443Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#827311}
parent ce09536e
......@@ -296,8 +296,7 @@ SVGPropertyBase* SVGAnimateElement::CreatePropertyForCSSAnimation(
return nullptr;
}
SVGPropertyBase* SVGAnimateElement::CreatePropertyForAnimation(
const String& value) const {
SVGPropertyBase* SVGAnimateElement::ParseValue(const String& value) const {
if (IsAnimatingSVGDom())
return CreatePropertyForAttributeAnimation(value);
DCHECK(IsAnimatingCSSProperty());
......@@ -309,6 +308,7 @@ SVGPropertyBase* SVGAnimateElement::AdjustForInheritance(
AnimatedPropertyValueType value_type) const {
if (value_type != kInheritValue)
return property_value;
DCHECK(IsAnimatingCSSProperty());
// TODO(fs): At the moment the computed style gets returned as a String and
// needs to get parsed again. In the future we might want to work with the
// value type directly to avoid the String parsing.
......@@ -319,7 +319,7 @@ SVGPropertyBase* SVGAnimateElement::AdjustForInheritance(
return property_value;
// Replace 'inherit' by its computed property value.
String value = ComputeCSSPropertyValue(svg_parent, css_property_id_);
return CreatePropertyForAnimation(value);
return CreatePropertyForCSSAnimation(value);
}
static SVGPropertyBase* DiscreteSelectValue(AnimationMode animation_mode,
......@@ -389,17 +389,16 @@ bool SVGAnimateElement::CalculateToAtEndOfDurationValue(
const String& to_at_end_of_duration_string) {
if (to_at_end_of_duration_string.IsEmpty())
return false;
to_at_end_of_duration_property_ =
CreatePropertyForAnimation(to_at_end_of_duration_string);
to_at_end_of_duration_property_ = ParseValue(to_at_end_of_duration_string);
return true;
}
bool SVGAnimateElement::CalculateFromAndToValues(const String& from_string,
const String& to_string) {
DCHECK(targetElement());
from_property_ = CreatePropertyForAnimation(from_string);
from_property_ = ParseValue(from_string);
from_property_value_type_ = PropertyValueType(AttributeName(), from_string);
to_property_ = CreatePropertyForAnimation(to_string);
to_property_ = ParseValue(to_string);
to_property_value_type_ = PropertyValueType(AttributeName(), to_string);
return true;
}
......@@ -417,9 +416,9 @@ bool SVGAnimateElement::CalculateFromAndByValues(const String& from_string,
DCHECK(!IsA<SVGSetElement>(*this));
from_property_ = CreatePropertyForAnimation(from_string);
from_property_ = ParseValue(from_string);
from_property_value_type_ = PropertyValueType(AttributeName(), from_string);
to_property_ = CreatePropertyForAnimation(by_string);
to_property_ = ParseValue(by_string);
to_property_value_type_ = PropertyValueType(AttributeName(), by_string);
to_property_->Add(from_property_, targetElement());
return true;
......@@ -444,7 +443,7 @@ SMILAnimationValue SVGAnimateElement::CreateAnimationValue(
needs_underlying_value
? ComputeCSSPropertyValue(targetElement(), css_property_id_)
: g_empty_string;
animation_value.property_value = CreatePropertyForAnimation(base_value);
animation_value.property_value = CreatePropertyForCSSAnimation(base_value);
}
return animation_value;
}
......@@ -522,8 +521,8 @@ float SVGAnimateElement::CalculateDistance(const String& from_string,
DCHECK(targetElement());
// FIXME: A return value of float is not enough to support paced animations on
// lists.
SVGPropertyBase* from_value = CreatePropertyForAnimation(from_string);
SVGPropertyBase* to_value = CreatePropertyForAnimation(to_string);
SVGPropertyBase* from_value = ParseValue(from_string);
SVGPropertyBase* to_value = ParseValue(to_string);
return from_value->CalculateDistance(to_value, targetElement());
}
......
......@@ -105,7 +105,7 @@ class CORE_EXPORT SVGAnimateElement : public SVGAnimationElement {
void WillChangeAnimatedType();
void DidChangeAnimatedType();
virtual SVGPropertyBase* CreatePropertyForAnimation(const String&) const;
virtual SVGPropertyBase* ParseValue(const String&) const;
SVGPropertyBase* CreatePropertyForAttributeAnimation(const String&) const;
SVGPropertyBase* CreatePropertyForCSSAnimation(const String&) const;
......
......@@ -55,7 +55,7 @@ void SVGAnimateTransformElement::ResolveTargetProperty() {
css_property_id_ = CSSPropertyID::kInvalid;
}
SVGPropertyBase* SVGAnimateTransformElement::CreatePropertyForAnimation(
SVGPropertyBase* SVGAnimateTransformElement::ParseValue(
const String& value) const {
DCHECK(IsAnimatingSVGDom());
return MakeGarbageCollected<SVGTransformList>(transform_type_, value);
......
......@@ -40,7 +40,7 @@ class SVGAnimateTransformElement final : public SVGAnimateElement {
void ParseAttribute(const AttributeModificationParams&) override;
SVGPropertyBase* CreatePropertyForAnimation(const String&) const override;
SVGPropertyBase* ParseValue(const String&) const override;
SVGTransformType transform_type_;
};
......
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