Chromium Code Reviews| Index: Source/core/animation/interpolation/DeferredLegacyStyleInterpolation.cpp |
| diff --git a/Source/core/animation/interpolation/DeferredLegacyStyleInterpolation.cpp b/Source/core/animation/interpolation/DeferredLegacyStyleInterpolation.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7107319034c679e7e61570cbe9883d18a60f18fb |
| --- /dev/null |
| +++ b/Source/core/animation/interpolation/DeferredLegacyStyleInterpolation.cpp |
| @@ -0,0 +1,129 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "core/animation/interpolation/DeferredLegacyStyleInterpolation.h" |
| + |
| +#include "core/animation/interpolation/LegacyStyleInterpolation.h" |
| +#include "core/css/CSSPrimitiveValue.h" |
| +#include "core/css/CSSShadowValue.h" |
| +#include "core/css/CSSValueList.h" |
| +#include "core/css/Pair.h" |
| +#include "core/css/Rect.h" |
| +#include "core/css/resolver/StyleResolver.h" |
| +#include "core/css/resolver/StyleResolverState.h" |
| + |
| +namespace WebCore { |
| + |
| +void DeferredLegacyStyleInterpolation::apply(StyleResolverState& state) const |
| +{ |
| + RefPtrWillBeRawPtr<LegacyStyleInterpolation> innerInterpolation = LegacyStyleInterpolation::create( |
| + StyleResolver::applyAndSnapshotAnimatableValue(*state.element(), m_id, *m_startCSSValue, state.style()), |
|
shans
2014/05/26 03:31:01
Have two different functions. I think a function t
Eric Willigers
2014/05/26 06:32:47
Agreed, done.
|
| + StyleResolver::applyAndSnapshotAnimatableValue(*state.element(), m_id, *m_endCSSValue, state.style()), |
| + m_id); |
| + innerInterpolation->interpolate(m_cachedIteration, m_cachedFraction); |
| + innerInterpolation->apply(state); |
| +} |
| + |
| +bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const CSSValue& value) |
| +{ |
| + switch (value.cssValueType()) { |
| + case CSSValue::CSS_INHERIT: |
| + return true; |
| + case CSSValue::CSS_PRIMITIVE_VALUE: |
| + return interpolationRequiresStyleResolve(toCSSPrimitiveValue(value)); |
| + case CSSValue::CSS_VALUE_LIST: |
| + return interpolationRequiresStyleResolve(toCSSValueList(value)); |
| + case CSSValue::CSS_CUSTOM: |
| + if (value.isShadowValue()) |
| + return interpolationRequiresStyleResolve(toCSSShadowValue(value)); |
| + return false; |
|
dstockwell
2014/05/26 01:16:04
Shouldn't the default be true?
Eric Willigers
2014/05/26 06:32:47
Done. Note this leads to a couple of extra failure
|
| + case CSSValue::CSS_INITIAL: |
| + return false; |
|
dstockwell
2014/05/26 01:16:04
Doesn't this depend on what the initial value is?
Eric Willigers
2014/05/26 06:32:47
Done.
|
| + default: |
| + ASSERT_NOT_REACHED(); |
| + return false; |
|
dstockwell
2014/05/26 01:16:04
Shouldn't the default be true?
Eric Willigers
2014/05/26 06:32:47
Done.
|
| + } |
| +} |
| + |
| +bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const CSSPrimitiveValue& primitiveValue) |
| +{ |
| + if (primitiveValue.isCalculated()) { |
| + CSSLengthArray lengthArray; |
| + CSSPrimitiveValue::zeroLengthArray(lengthArray); |
| + primitiveValue.accumulateLengthArray(lengthArray); |
| + return lengthArray[CSSPrimitiveValue::UnitTypeFontSize] != 0 |
| + || lengthArray[CSSPrimitiveValue::UnitTypeFontXSize] != 0 |
| + || lengthArray[CSSPrimitiveValue::UnitTypeRootFontSize] != 0 |
| + || lengthArray[CSSPrimitiveValue::UnitTypeZeroCharacterWidth] != 0 |
| + || lengthArray[CSSPrimitiveValue::UnitTypeViewportWidth] != 0 |
| + || lengthArray[CSSPrimitiveValue::UnitTypeViewportHeight] != 0 |
| + || lengthArray[CSSPrimitiveValue::UnitTypeViewportMin] != 0 |
| + || lengthArray[CSSPrimitiveValue::UnitTypeViewportMax] != 0; |
| + } |
| + |
| + if (primitiveValue.isLength()) |
| + return primitiveValue.isFontRelativeLength() || primitiveValue.isViewportPercentageLength(); |
| + |
| + if (Pair* pair = primitiveValue.getPairValue()) { |
| + return interpolationRequiresStyleResolve(*pair->first()) |
| + || interpolationRequiresStyleResolve(*pair->second()); |
| + } |
| + |
| + if (Rect* rect = primitiveValue.getRectValue()) { |
| + return interpolationRequiresStyleResolve(*rect->top()) |
| + || interpolationRequiresStyleResolve(*rect->right()) |
| + || interpolationRequiresStyleResolve(*rect->bottom()) |
| + || interpolationRequiresStyleResolve(*rect->left()); |
| + } |
| + |
| + if (Quad* quad = primitiveValue.getQuadValue()) { |
| + return interpolationRequiresStyleResolve(*quad->top()) |
| + || interpolationRequiresStyleResolve(*quad->right()) |
| + || interpolationRequiresStyleResolve(*quad->bottom()) |
| + || interpolationRequiresStyleResolve(*quad->left()); |
| + } |
| + |
| + switch (primitiveValue.getValueID()) { |
| + case CSSValueBolder: |
| + case CSSValueCurrentcolor: |
| + case CSSValueHigher: |
| + case CSSValueLarger: |
| + case CSSValueLighter: |
| + case CSSValueLower: |
| + case CSSValueSmaller: |
| + return true; |
| + default: |
| + return false; |
|
dstockwell
2014/05/26 01:16:04
Expand these cases and make the default true?
Eric Willigers
2014/05/26 06:32:47
I have made the color constants false and default
|
| + } |
| +} |
| + |
| +bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const CSSShadowValue& shadowValue) |
| +{ |
| + return (shadowValue.x && interpolationRequiresStyleResolve(*shadowValue.x)) |
| + || (shadowValue.y && interpolationRequiresStyleResolve(*shadowValue.y)) |
| + || (shadowValue.blur && interpolationRequiresStyleResolve(*shadowValue.blur)) |
| + || (shadowValue.spread && interpolationRequiresStyleResolve(*shadowValue.spread)) |
| + || (shadowValue.style && interpolationRequiresStyleResolve(*shadowValue.style)) |
| + || (shadowValue.color && interpolationRequiresStyleResolve(*shadowValue.color)); |
| +} |
| + |
| +bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const CSSValueList& valueList) |
| +{ |
| + size_t length = valueList.length(); |
| + for (size_t index = 0; index < length; ++index) { |
| + if (interpolationRequiresStyleResolve(*valueList.item(index))) |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +void DeferredLegacyStyleInterpolation::trace(Visitor* visitor) |
| +{ |
| + StyleInterpolation::trace(visitor); |
| + visitor->trace(m_startCSSValue); |
| + visitor->trace(m_endCSSValue); |
| +} |
| + |
| +} |