Commit ff407634 authored by suzyh's avatar suzyh Committed by Commit bot

Remove unused code in InvalidatableInterpolation

This patch removes two functions in InvalidatableInterpolation that are
unreached: apply and getCachedValueForTesting.

Since InvalidatableInterpolation has cached values, I had originally intended to
supply a meaningful implementation for getCachedValueForTesting. However, after
further consultation, I'm instead removing the virtual function from the
Interpolation superclass and modifying the tests that use it to make it explicit
that they will be executing LegacyStyleInterpolation::getCachedValueForTesting.

BUG=678875

Review-Url: https://codereview.chromium.org/2627793002
Cr-Commit-Position: refs/heads/master@{#443055}
parent 0f71ff05
...@@ -14,7 +14,7 @@ namespace { ...@@ -14,7 +14,7 @@ namespace {
class SampleInterpolation : public LegacyStyleInterpolation { class SampleInterpolation : public LegacyStyleInterpolation {
public: public:
static PassRefPtr<Interpolation> create( static PassRefPtr<LegacyStyleInterpolation> create(
std::unique_ptr<InterpolableValue> start, std::unique_ptr<InterpolableValue> start,
std::unique_ptr<InterpolableValue> end) { std::unique_ptr<InterpolableValue> end) {
return adoptRef(new SampleInterpolation(std::move(start), std::move(end))); return adoptRef(new SampleInterpolation(std::move(start), std::move(end)));
...@@ -32,12 +32,13 @@ class SampleInterpolation : public LegacyStyleInterpolation { ...@@ -32,12 +32,13 @@ class SampleInterpolation : public LegacyStyleInterpolation {
class AnimationInterpolableValueTest : public ::testing::Test { class AnimationInterpolableValueTest : public ::testing::Test {
protected: protected:
InterpolableValue* interpolationValue(Interpolation& interpolation) { InterpolableValue* interpolationValue(
LegacyStyleInterpolation& interpolation) {
return interpolation.getCachedValueForTesting(); return interpolation.getCachedValueForTesting();
} }
double interpolateNumbers(double a, double b, double progress) { double interpolateNumbers(double a, double b, double progress) {
RefPtr<Interpolation> i = SampleInterpolation::create( RefPtr<LegacyStyleInterpolation> i = SampleInterpolation::create(
InterpolableNumber::create(a), InterpolableNumber::create(b)); InterpolableNumber::create(a), InterpolableNumber::create(b));
i->interpolate(0, progress); i->interpolate(0, progress);
return toInterpolableNumber(interpolationValue(*i.get()))->value(); return toInterpolableNumber(interpolationValue(*i.get()))->value();
...@@ -49,11 +50,11 @@ class AnimationInterpolableValueTest : public ::testing::Test { ...@@ -49,11 +50,11 @@ class AnimationInterpolableValueTest : public ::testing::Test {
base.scaleAndAdd(scale, add); base.scaleAndAdd(scale, add);
} }
PassRefPtr<Interpolation> interpolateLists( PassRefPtr<LegacyStyleInterpolation> interpolateLists(
std::unique_ptr<InterpolableList> listA, std::unique_ptr<InterpolableList> listA,
std::unique_ptr<InterpolableList> listB, std::unique_ptr<InterpolableList> listB,
double progress) { double progress) {
RefPtr<Interpolation> i = RefPtr<LegacyStyleInterpolation> i =
SampleInterpolation::create(std::move(listA), std::move(listB)); SampleInterpolation::create(std::move(listA), std::move(listB));
i->interpolate(0, progress); i->interpolate(0, progress);
return i; return i;
...@@ -80,7 +81,7 @@ TEST_F(AnimationInterpolableValueTest, SimpleList) { ...@@ -80,7 +81,7 @@ TEST_F(AnimationInterpolableValueTest, SimpleList) {
listB->set(1, InterpolableNumber::create(-200)); listB->set(1, InterpolableNumber::create(-200));
listB->set(2, InterpolableNumber::create(300)); listB->set(2, InterpolableNumber::create(300));
RefPtr<Interpolation> i = RefPtr<LegacyStyleInterpolation> i =
interpolateLists(std::move(listA), std::move(listB), 0.3); interpolateLists(std::move(listA), std::move(listB), 0.3);
InterpolableList* outList = toInterpolableList(interpolationValue(*i.get())); InterpolableList* outList = toInterpolableList(interpolationValue(*i.get()));
EXPECT_FLOAT_EQ(30, toInterpolableNumber(outList->get(0))->value()); EXPECT_FLOAT_EQ(30, toInterpolableNumber(outList->get(0))->value());
...@@ -103,7 +104,7 @@ TEST_F(AnimationInterpolableValueTest, NestedList) { ...@@ -103,7 +104,7 @@ TEST_F(AnimationInterpolableValueTest, NestedList) {
listB->set(1, std::move(subListB)); listB->set(1, std::move(subListB));
listB->set(2, InterpolableNumber::create(1)); listB->set(2, InterpolableNumber::create(1));
RefPtr<Interpolation> i = RefPtr<LegacyStyleInterpolation> i =
interpolateLists(std::move(listA), std::move(listB), 0.5); interpolateLists(std::move(listA), std::move(listB), 0.5);
InterpolableList* outList = toInterpolableList(interpolationValue(*i.get())); InterpolableList* outList = toInterpolableList(interpolationValue(*i.get()));
EXPECT_FLOAT_EQ(50, toInterpolableNumber(outList->get(0))->value()); EXPECT_FLOAT_EQ(50, toInterpolableNumber(outList->get(0))->value());
......
...@@ -33,13 +33,6 @@ class CORE_EXPORT Interpolation : public RefCounted<Interpolation> { ...@@ -33,13 +33,6 @@ class CORE_EXPORT Interpolation : public RefCounted<Interpolation> {
protected: protected:
Interpolation() {} Interpolation() {}
virtual InterpolableValue* getCachedValueForTesting() const = 0;
friend class AnimationInterpolableValueTest;
friend class AnimationInterpolationEffectTest;
friend class AnimationDoubleStyleInterpolationTest;
friend class AnimationVisibilityStyleInterpolationTest;
}; };
using ActiveInterpolations = Vector<RefPtr<Interpolation>, 1>; using ActiveInterpolations = Vector<RefPtr<Interpolation>, 1>;
......
...@@ -14,7 +14,7 @@ namespace { ...@@ -14,7 +14,7 @@ namespace {
class SampleInterpolation : public LegacyStyleInterpolation { class SampleInterpolation : public LegacyStyleInterpolation {
public: public:
static PassRefPtr<Interpolation> create( static PassRefPtr<LegacyStyleInterpolation> create(
std::unique_ptr<InterpolableValue> start, std::unique_ptr<InterpolableValue> start,
std::unique_ptr<InterpolableValue> end) { std::unique_ptr<InterpolableValue> end) {
return adoptRef(new SampleInterpolation(std::move(start), std::move(end))); return adoptRef(new SampleInterpolation(std::move(start), std::move(end)));
...@@ -34,12 +34,15 @@ const double duration = 1.0; ...@@ -34,12 +34,15 @@ const double duration = 1.0;
class AnimationInterpolationEffectTest : public ::testing::Test { class AnimationInterpolationEffectTest : public ::testing::Test {
protected: protected:
InterpolableValue* interpolationValue(Interpolation& interpolation) { InterpolableValue* interpolationValue(
LegacyStyleInterpolation& interpolation) {
return interpolation.getCachedValueForTesting(); return interpolation.getCachedValueForTesting();
} }
double getInterpolableNumber(PassRefPtr<Interpolation> value) { double getInterpolableNumber(PassRefPtr<Interpolation> value) {
return toInterpolableNumber(interpolationValue(*value.get()))->value(); LegacyStyleInterpolation& interpolation =
toLegacyStyleInterpolation(*value.get());
return toInterpolableNumber(interpolationValue(interpolation))->value();
} }
}; };
......
...@@ -30,7 +30,6 @@ class CORE_EXPORT InvalidatableInterpolation : public Interpolation { ...@@ -30,7 +30,6 @@ class CORE_EXPORT InvalidatableInterpolation : public Interpolation {
PropertyHandle getProperty() const final { return m_property; } PropertyHandle getProperty() const final { return m_property; }
virtual void interpolate(int iteration, double fraction); virtual void interpolate(int iteration, double fraction);
bool dependsOnUnderlyingValue() const final; bool dependsOnUnderlyingValue() const final;
virtual void apply(InterpolationEnvironment&) const { NOTREACHED(); }
static void applyStack(const ActiveInterpolations&, static void applyStack(const ActiveInterpolations&,
InterpolationEnvironment&); InterpolationEnvironment&);
...@@ -51,11 +50,6 @@ class CORE_EXPORT InvalidatableInterpolation : public Interpolation { ...@@ -51,11 +50,6 @@ class CORE_EXPORT InvalidatableInterpolation : public Interpolation {
using ConversionCheckers = InterpolationType::ConversionCheckers; using ConversionCheckers = InterpolationType::ConversionCheckers;
InterpolableValue* getCachedValueForTesting() const final {
// TODO(suzyh): Add meaningful implementation here
NOTREACHED();
return nullptr;
}
std::unique_ptr<TypedInterpolationValue> maybeConvertUnderlyingValue( std::unique_ptr<TypedInterpolationValue> maybeConvertUnderlyingValue(
const InterpolationEnvironment&) const; const InterpolationEnvironment&) const;
const TypedInterpolationValue* ensureValidConversion( const TypedInterpolationValue* ensureValidConversion(
......
...@@ -64,9 +64,12 @@ class CORE_EXPORT LegacyStyleInterpolation : public Interpolation { ...@@ -64,9 +64,12 @@ class CORE_EXPORT LegacyStyleInterpolation : public Interpolation {
mutable int m_cachedIteration; mutable int m_cachedIteration;
mutable std::unique_ptr<InterpolableValue> m_cachedValue; mutable std::unique_ptr<InterpolableValue> m_cachedValue;
InterpolableValue* getCachedValueForTesting() const final { InterpolableValue* getCachedValueForTesting() const {
return m_cachedValue.get(); return m_cachedValue.get();
} }
friend class AnimationInterpolableValueTest;
friend class AnimationInterpolationEffectTest;
}; };
DEFINE_TYPE_CASTS(LegacyStyleInterpolation, DEFINE_TYPE_CASTS(LegacyStyleInterpolation,
......
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