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

Unified Diff: Source/core/animation/LengthInterpolationType.cpp

Issue 1243313002: Migrate the remaining CSS properties interpolable as Lengths to LengthInterpolationType (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 5 years, 4 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: Source/core/animation/LengthInterpolationType.cpp
diff --git a/Source/core/animation/LengthInterpolationType.cpp b/Source/core/animation/LengthInterpolationType.cpp
index b623ac3d8eb0c4c100cd96d4a65a2e85e9d3177d..bc8d65ff076eb167c897e2e00354547fce99afca 100644
--- a/Source/core/animation/LengthInterpolationType.cpp
+++ b/Source/core/animation/LengthInterpolationType.cpp
@@ -32,6 +32,11 @@ static PassOwnPtrWillBeRawPtr<InterpolableList> createNeutralValue()
return listOfValuesAndTypes.release();
}
+float LengthInterpolationType::effectiveZoom(const ComputedStyle& style) const
+{
+ return LengthPropertyFunctions::hasZoomedLength(m_property) ? style.effectiveZoom() : 1;
+}
+
PassOwnPtrWillBeRawPtr<InterpolationValue> LengthInterpolationType::maybeConvertLength(const Length& length, float zoom) const
{
if (!length.isSpecified())
@@ -45,8 +50,8 @@ PassOwnPtrWillBeRawPtr<InterpolationValue> LengthInterpolationType::maybeConvert
values.set(CSSPrimitiveValue::UnitTypePercentage, InterpolableNumber::create(pixelsAndPercent.percent));
InterpolableList& types = toInterpolableList(*valuesAndTypes->get(1));
- types.set(CSSPrimitiveValue::UnitTypePixels, InterpolableNumber::create(1));
- types.set(CSSPrimitiveValue::UnitTypePercentage, InterpolableNumber::create(1));
+ types.set(CSSPrimitiveValue::UnitTypePixels, InterpolableNumber::create(pixelsAndPercent.pixels != 0));
+ types.set(CSSPrimitiveValue::UnitTypePercentage, InterpolableNumber::create(length.hasPercent()));
return InterpolationValue::create(*this, valuesAndTypes.release());
}
@@ -68,7 +73,7 @@ private:
{
Length parentLength;
if (!LengthPropertyFunctions::getLength(m_property, *state.parentStyle(), parentLength))
- return true;
+ return false;
return parentLength == m_length;
}
@@ -102,7 +107,7 @@ PassOwnPtrWillBeRawPtr<InterpolationValue> LengthInterpolationType::maybeConvert
if (!LengthPropertyFunctions::getLength(m_property, *state->parentStyle(), inheritedLength))
return nullptr;
conversionCheckers.append(ParentLengthChecker::create(m_property, inheritedLength));
- return maybeConvertLength(inheritedLength, state->parentStyle()->effectiveZoom());
+ return maybeConvertLength(inheritedLength, effectiveZoom(*state->parentStyle()));
}
PassOwnPtrWillBeRawPtr<InterpolationValue> LengthInterpolationType::maybeConvertValue(const CSSValue& value, const StyleResolverState* state, ConversionCheckers& conversionCheckers) const
@@ -151,7 +156,7 @@ PassOwnPtrWillBeRawPtr<InterpolationValue> LengthInterpolationType::maybeConvert
Length underlyingLength;
if (!LengthPropertyFunctions::getLength(m_property, *state.style(), underlyingLength))
return nullptr;
- return maybeConvertLength(underlyingLength, state.style()->effectiveZoom());
+ return maybeConvertLength(underlyingLength, effectiveZoom(*state.style()));
}
void LengthInterpolationType::apply(const InterpolableValue& interpolableValue, const NonInterpolableValue*, StyleResolverState& state) const
@@ -159,8 +164,7 @@ void LengthInterpolationType::apply(const InterpolableValue& interpolableValue,
// TODO(alancutter): Make all length interpolation functions operate on ValueRanges instead of InterpolationRanges.
InterpolationRange range = m_valueRange == ValueRangeNonNegative ? RangeNonNegative : RangeAll;
// TODO(alancutter): Set arbitrary property Lengths on ComputedStyle without using cross compilation unit member function getters (Windows runtime doesn't like it).
- ASSERT(m_property == CSSPropertyLeft);
- LengthStyleInterpolation::applyInterpolableValue(m_property, interpolableValue, range, state, &ComputedStyle::setLeft);
+ LengthStyleInterpolation::applyInterpolableValue(m_property, interpolableValue, range, state);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698