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