Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp

Issue 2617453003: Make CSSInterpolationType::maybeConvertSingle() final (Closed)
Patch Set: No lambdas Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp
diff --git a/third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp
index d7b611c06edf342f176f0c4840fb6ebfa9bdc3fb..6d678b071e4c208a07d0a36a939ee42d85541f61 100644
--- a/third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp
+++ b/third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp
@@ -35,12 +35,7 @@ struct Scale {
array[2] = z;
}
- std::unique_ptr<InterpolableValue> createInterpolableValue() const {
- std::unique_ptr<InterpolableList> result = InterpolableList::create(3);
- for (size_t i = 0; i < 3; i++)
- result->set(i, InterpolableNumber::create(array[i]));
- return std::move(result);
- }
+ InterpolationValue createInterpolationValue() const;
bool operator==(const Scale& other) const {
for (size_t i = 0; i < 3; i++) {
@@ -76,10 +71,9 @@ class CSSScaleNonInterpolableValue : public NonInterpolableValue {
public:
~CSSScaleNonInterpolableValue() final {}
- static PassRefPtr<CSSScaleNonInterpolableValue> create(const Scale& scale,
- bool isAdditive) {
+ static PassRefPtr<CSSScaleNonInterpolableValue> create(const Scale& scale) {
return adoptRef(
- new CSSScaleNonInterpolableValue(scale, scale, isAdditive, isAdditive));
+ new CSSScaleNonInterpolableValue(scale, scale, false, false));
}
static PassRefPtr<CSSScaleNonInterpolableValue> merge(
@@ -95,6 +89,11 @@ class CSSScaleNonInterpolableValue : public NonInterpolableValue {
bool isStartAdditive() const { return m_isStartAdditive; }
bool isEndAdditive() const { return m_isEndAdditive; }
+ void setIsAdditive() {
+ m_isStartAdditive = true;
+ m_isEndAdditive = true;
+ }
+
DECLARE_NON_INTERPOLABLE_VALUE_TYPE();
private:
@@ -109,23 +108,31 @@ class CSSScaleNonInterpolableValue : public NonInterpolableValue {
const Scale m_start;
const Scale m_end;
- const bool m_isStartAdditive;
- const bool m_isEndAdditive;
+ bool m_isStartAdditive;
+ bool m_isEndAdditive;
};
DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSScaleNonInterpolableValue);
DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSScaleNonInterpolableValue);
+InterpolationValue Scale::createInterpolationValue() const {
+ std::unique_ptr<InterpolableList> list = InterpolableList::create(3);
+ for (size_t i = 0; i < 3; i++)
+ list->set(i, InterpolableNumber::create(array[i]));
+ return InterpolationValue(std::move(list),
+ CSSScaleNonInterpolableValue::create(*this));
+}
+
InterpolationValue CSSScaleInterpolationType::maybeConvertNeutral(
const InterpolationValue&,
ConversionCheckers&) const {
- return InterpolationValue(Scale(1, 1, 1).createInterpolableValue());
+ return Scale(1, 1, 1).createInterpolationValue();
}
InterpolationValue CSSScaleInterpolationType::maybeConvertInitial(
const StyleResolverState&,
ConversionCheckers&) const {
- return InterpolationValue(Scale(1, 1, 1).createInterpolableValue());
+ return Scale(1, 1, 1).createInterpolationValue();
}
InterpolationValue CSSScaleInterpolationType::maybeConvertInherit(
@@ -133,7 +140,7 @@ InterpolationValue CSSScaleInterpolationType::maybeConvertInherit(
ConversionCheckers& conversionCheckers) const {
Scale inheritedScale(state.parentStyle()->scale());
conversionCheckers.push_back(InheritedScaleChecker::create(inheritedScale));
- return InterpolationValue(inheritedScale.createInterpolableValue());
+ return inheritedScale.createInterpolationValue();
}
InterpolationValue CSSScaleInterpolationType::maybeConvertValue(
@@ -158,22 +165,12 @@ InterpolationValue CSSScaleInterpolationType::maybeConvertValue(
if (list.length() == 1)
scale.array[1] = scale.array[0];
- return InterpolationValue(scale.createInterpolableValue());
+ return scale.createInterpolationValue();
}
-InterpolationValue CSSScaleInterpolationType::maybeConvertSingle(
- const PropertySpecificKeyframe& keyframe,
- const InterpolationEnvironment& environment,
- const InterpolationValue& underlying,
- ConversionCheckers& conversionCheckers) const {
- InterpolationValue result = CSSInterpolationType::maybeConvertSingle(
- keyframe, environment, underlying, conversionCheckers);
- if (!result)
- return nullptr;
- result.nonInterpolableValue = CSSScaleNonInterpolableValue::create(
- Scale(*result.interpolableValue),
- keyframe.composite() != EffectModel::CompositeReplace);
- return result;
+void CSSScaleInterpolationType::additiveKeyframeHook(
+ InterpolationValue& value) const {
+ toCSSScaleNonInterpolableValue(*value.nonInterpolableValue).setIsAdditive();
}
PairwiseInterpolationValue CSSScaleInterpolationType::maybeMergeSingles(
@@ -189,8 +186,7 @@ PairwiseInterpolationValue CSSScaleInterpolationType::maybeMergeSingles(
InterpolationValue
CSSScaleInterpolationType::maybeConvertStandardPropertyUnderlyingValue(
const StyleResolverState& state) const {
- return InterpolationValue(
- Scale(state.style()->scale()).createInterpolableValue());
+ return Scale(state.style()->scale()).createInterpolationValue();
}
void CSSScaleInterpolationType::composite(

Powered by Google App Engine
This is Rietveld 408576698