Commit 2ed1ad81 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Have SVGAnimatedPropertyCommon::current_value_ always be set

Rather than having |current_value_| be null when an animation is not
active, have it point to the same value as |base_value_|. This avoids
having to null-check |current_value_| for each access (in CurrentValue).

Bug: 1017723
Change-Id: I39c56ec30ee9c92692db4f68be49a8094bf012b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1932542Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#719070}
parent 36e22f8d
...@@ -119,10 +119,7 @@ template <typename Property> ...@@ -119,10 +119,7 @@ template <typename Property>
class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase { class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase {
public: public:
Property* BaseValue() { return base_value_.Get(); } Property* BaseValue() { return base_value_.Get(); }
Property* CurrentValue() { return current_value_.Get(); }
Property* CurrentValue() {
return current_value_ ? current_value_.Get() : base_value_.Get();
}
const Property* CurrentValue() const { const Property* CurrentValue() const {
return const_cast<SVGAnimatedPropertyCommon*>(this)->CurrentValue(); return const_cast<SVGAnimatedPropertyCommon*>(this)->CurrentValue();
...@@ -132,7 +129,7 @@ class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase { ...@@ -132,7 +129,7 @@ class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase {
const SVGPropertyBase& BaseValueBase() const override { return *base_value_; } const SVGPropertyBase& BaseValueBase() const override { return *base_value_; }
bool IsAnimating() const override { return current_value_; } bool IsAnimating() const override { return current_value_ != base_value_; }
SVGParsingError AttributeChanged(const String& value) override { SVGParsingError AttributeChanged(const String& value) override {
static_assert(Property::kInitialValueBits <= kInitialValueStorageBits, static_assert(Property::kInitialValueBits <= kInitialValueStorageBits,
...@@ -160,8 +157,7 @@ class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase { ...@@ -160,8 +157,7 @@ class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase {
} }
void AnimationEnded() override { void AnimationEnded() override {
current_value_.Clear(); current_value_ = base_value_;
SVGAnimatedPropertyBase::AnimationEnded(); SVGAnimatedPropertyBase::AnimationEnded();
} }
...@@ -183,7 +179,8 @@ class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase { ...@@ -183,7 +179,8 @@ class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase {
attribute_name, attribute_name,
css_property_id, css_property_id,
initial_value_bits), initial_value_bits),
base_value_(initial_value) {} base_value_(initial_value),
current_value_(initial_value) {}
private: private:
Member<Property> base_value_; Member<Property> base_value_;
...@@ -201,7 +198,7 @@ class SVGAnimatedProperty : public SVGAnimatedPropertyCommon<Property> { ...@@ -201,7 +198,7 @@ class SVGAnimatedProperty : public SVGAnimatedPropertyCommon<Property> {
// SVGAnimated* DOM Spec implementations: // SVGAnimated* DOM Spec implementations:
// baseVal()/setBaseVal()/animVal() are only to be used from SVG DOM // baseVal()/setBaseVal()/animVal() are only to be used from SVG DOM
// implementation. Use currentValue() from C++ code. // implementation. Use CurrentValue() from C++ code.
PrimitiveType baseVal() { return this->BaseValue()->Value(); } PrimitiveType baseVal() { return this->BaseValue()->Value(); }
void setBaseVal(PrimitiveType value, ExceptionState&) { void setBaseVal(PrimitiveType value, ExceptionState&) {
...@@ -288,11 +285,12 @@ class SVGAnimatedProperty<Property, TearOffType, void> ...@@ -288,11 +285,12 @@ class SVGAnimatedProperty<Property, TearOffType, void>
anim_val_tear_off_->SetTarget(this->CurrentValue()); anim_val_tear_off_->SetTarget(this->CurrentValue());
} }
// When still (not animated): // When not animated:
// Both m_animValTearOff and m_baseValTearOff target m_baseValue. // Both |anim_val_tear_off_| and |base_val_tear_off_| target
// |base_value_|.
// When animated: // When animated:
// m_animValTearOff targets m_currentValue. // |anim_val_tear_off_| targets |current_value_|.
// m_baseValTearOff targets m_baseValue. // |base_val_tear_off_| targets |base_value_|.
Member<TearOffType> base_val_tear_off_; Member<TearOffType> base_val_tear_off_;
Member<TearOffType> anim_val_tear_off_; Member<TearOffType> anim_val_tear_off_;
}; };
......
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