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>
class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase {
public:
Property* BaseValue() { return base_value_.Get(); }
Property* CurrentValue() {
return current_value_ ? current_value_.Get() : base_value_.Get();
}
Property* CurrentValue() { return current_value_.Get(); }
const Property* CurrentValue() const {
return const_cast<SVGAnimatedPropertyCommon*>(this)->CurrentValue();
......@@ -132,7 +129,7 @@ class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase {
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 {
static_assert(Property::kInitialValueBits <= kInitialValueStorageBits,
......@@ -160,8 +157,7 @@ class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase {
}
void AnimationEnded() override {
current_value_.Clear();
current_value_ = base_value_;
SVGAnimatedPropertyBase::AnimationEnded();
}
......@@ -183,7 +179,8 @@ class SVGAnimatedPropertyCommon : public SVGAnimatedPropertyBase {
attribute_name,
css_property_id,
initial_value_bits),
base_value_(initial_value) {}
base_value_(initial_value),
current_value_(initial_value) {}
private:
Member<Property> base_value_;
......@@ -201,7 +198,7 @@ class SVGAnimatedProperty : public SVGAnimatedPropertyCommon<Property> {
// SVGAnimated* DOM Spec implementations:
// 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(); }
void setBaseVal(PrimitiveType value, ExceptionState&) {
......@@ -288,11 +285,12 @@ class SVGAnimatedProperty<Property, TearOffType, void>
anim_val_tear_off_->SetTarget(this->CurrentValue());
}
// When still (not animated):
// Both m_animValTearOff and m_baseValTearOff target m_baseValue.
// When not animated:
// Both |anim_val_tear_off_| and |base_val_tear_off_| target
// |base_value_|.
// When animated:
// m_animValTearOff targets m_currentValue.
// m_baseValTearOff targets m_baseValue.
// |anim_val_tear_off_| targets |current_value_|.
// |base_val_tear_off_| targets |base_value_|.
Member<TearOffType> base_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